-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmxit.rb
57 lines (47 loc) · 1.49 KB
/
mxit.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require 'cgi'
class Mxit
@@mock_mxit_headers = {
"HTTP_X_MXIT_LOCATION"=>"ZA,,06,,,Germiston,83354,81131486,7efb4d", #
"HTTP_X_MXIT_LOGIN"=>"emilesilvis7",
"HTTP_X_MXIT_USERID_R"=>"web_client", #
"HTTP_X_MXIT_HOME"=>"http://aws1.tobykurien.com/app",
"HTTP_X_MXIT_NICK"=>"Emile+Silvis", #
#"HTTP_X_MXIT_USER_INPUT"=>"This+is+my+message+", #
"HTTP_X_MXIT_PROFILE"=>"en,ZA,1976-05-12,Male,1", #
"HTTP_X_MXIT_CONTACT"=>"gauteng_events", #
"HTTP_UA_PIXELS"=>"800x1280", #
"HTTP_X_FORWARDED_FOR"=>"41.56.72.123", #
"HTTP_X_DEVICE_USER_AGENT" => "Mock" #
}
@@province_codes = {
"01" => "North-Western Province",
"02" => "KwaZulu-Natal",
"03" => "Free State",
"05" => "Eastern Cape",
"06" => "Gauteng",
"07" => "Mpumalanga",
"08" => "Northern Cape",
"09" => "Limpopo",
"10" => "North-West",
"11" => "Western Cape"
}
def initialize(request_env)
@env = @@mock_mxit_headers.merge request_env
end
def user_id
@env['HTTP_X_MXIT_USERID_R']
end
def nickname
CGI::unescape @env['HTTP_X_MXIT_NICK']
end
def message
CGI::unescape @env['HTTP_X_MXIT_USER_INPUT'] rescue nil
end
def country_code
@env['HTTP_X_MXIT_LOCATION'].split(',')[0]
end
def province_name
code = @env['HTTP_X_MXIT_LOCATION'].split(',')[2]
@@province_codes[code]
end
end