mxit_api 0.2.2.pre → 0.2.3.pre

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,17 +1,17 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
- gem "activesupport", ">= 3.0.0"
5
- gem "i18n", ">= 0.5.0"
4
+ gem 'activesupport', '>= 3.0.0'
5
+ gem 'i18n', '>= 0.5.0'
6
6
 
7
7
  # Add dependencies to develop your gem here.
8
8
  # Include everything needed to run rake, tests, features, etc.
9
9
  group :development do
10
- gem "rspec"
11
- gem "rdoc"
12
- gem "bundler"
13
- gem "jeweler"
14
- gem "simplecov"
15
- gem "webmock"
16
- gem "timecop"
10
+ gem 'rspec'
11
+ gem 'rdoc'
12
+ gem 'bundler'
13
+ gem 'jeweler'
14
+ gem 'simplecov'
15
+ gem 'webmock'
16
+ gem 'timecop'
17
17
  end
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ begin
6
6
  Bundler.setup(:default, :development)
7
7
  rescue Bundler::BundlerError => e
8
8
  $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
9
+ $stderr.puts 'Run `bundle install` to install missing gems'
10
10
  exit e.status_code
11
11
  end
12
12
  require 'rake'
@@ -14,13 +14,13 @@ require 'rake'
14
14
  require 'jeweler'
15
15
  require './lib/mxit_api/version.rb'
16
16
  Jeweler::Tasks.new do |gem|
17
- gem.name = "mxit_api"
18
- gem.homepage = "http://github.com/unboxed/mxit_api"
19
- gem.license = "MIT"
20
- gem.summary = %Q{gem to use Mxit APIs}
21
- gem.description = %Q{gem to use the Mxit APIs at http://dev.mxit.com/docs/ }
22
- gem.email = "grant.speelman@unboxedconsulting.com"
23
- gem.authors = ["Grant Speelman"]
17
+ gem.name = 'mxit_api'
18
+ gem.homepage = 'http://github.com/unboxed/mxit_api'
19
+ gem.license = 'MIT'
20
+ gem.summary = 'gem to use Mxit APIs'
21
+ gem.description = 'gem to use the Mxit APIs at http://dev.mxit.com/docs/ '
22
+ gem.email = 'grant.speelman@unboxedconsulting.com'
23
+ gem.authors = ['Grant Speelman']
24
24
  gem.version = MxitApi::Version::STRING
25
25
  # dependencies defined in Gemfile
26
26
  gem.add_dependency 'activesupport', '>= 3.0.0'
@@ -43,7 +43,7 @@ task :default => :spec
43
43
 
44
44
  require 'rdoc/task'
45
45
  Rake::RDocTask.new do |rdoc|
46
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ''
47
47
 
48
48
  rdoc.rdoc_dir = 'rdoc'
49
49
  rdoc.title = "mxit_api #{version}"
@@ -2,9 +2,8 @@ class MxitApi
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- PATCH = 2
5
+ PATCH = 3
6
6
  BUILD = 'pre'
7
-
8
7
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
9
8
  end
10
- end
9
+ end
@@ -1,6 +1,6 @@
1
1
  class MxitMoneyApi
2
2
 
3
- BASE_URL = "https://api.mxitmoney.co.za"
3
+ BASE_URL = 'https://api.mxitmoney.co.za'
4
4
  attr_reader :api_key, :balance
5
5
 
6
6
  def initialize(api_key)
@@ -17,7 +17,7 @@ class MxitMoneyApi
17
17
  return @balance unless @balance.nil?
18
18
  url = URI.parse("#{BASE_URL}/paymentsplatform/rest/v3/push/")
19
19
  req = Net::HTTP::Get.new(url.path, 'Accept'=>'application/json')
20
- req.basic_auth(api_key,"mxit_money_api")
20
+ req.basic_auth(api_key, 'mxit_money_api')
21
21
  response = Net::HTTP.start(url.host, url.port,
22
22
  :use_ssl => url.scheme == 'https',
23
23
  :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|
@@ -30,4 +30,4 @@ class MxitMoneyApi
30
30
  @balance
31
31
  end
32
32
 
33
- end
33
+ end
@@ -6,7 +6,7 @@ class MxitMoneyApi
6
6
  req = Net::HTTP::Post.new(url.to_s,
7
7
  'Accept'=>'application/json',
8
8
  'Content-Type' =>'application/json')
9
- req.basic_auth(api_key,"mxit_money_api".to_s)
9
+ req.basic_auth(api_key, 'mxit_money_api'.to_s)
10
10
  response = Net::HTTP.start(url.host, url.port,
11
11
  :use_ssl => url.scheme == 'https',
12
12
  :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|
@@ -19,4 +19,4 @@ class MxitMoneyApi
19
19
  end
20
20
  end
21
21
 
22
- end
22
+ end
@@ -4,9 +4,10 @@ class MxitMoneyApi
4
4
  params.symbolize_keys!
5
5
  url = URI.parse("#{BASE_URL}/paymentsplatform/rest/v3/user/#{params[:id]}?idType=#{(params[:id_type] || 'mxit_id').to_s.camelize(:lower)}")
6
6
  req = Net::HTTP::Get.new(url.to_s, 'Accept'=>'application/json')
7
- req.basic_auth(api_key,"mxit_money_api".to_s)
7
+ req.basic_auth(api_key, 'mxit_money_api'.to_s)
8
8
  http = Net::HTTP.new(url.host, url.port)
9
9
  http.use_ssl = true
10
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
10
11
  response = http.request(req)
11
12
  if response.code == '200' || response.code == '401' || response.code == '500' || response.code == '400'
12
13
  data = ActiveSupport::JSON.decode(response.body)
@@ -14,4 +15,4 @@ class MxitMoneyApi
14
15
  end
15
16
  end
16
17
 
17
- end
18
+ end
data/mxit_api.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "mxit_api"
8
- s.version = "0.2.2.pre"
8
+ s.version = "0.2.3.pre"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Grant Speelman"]
12
- s.date = "2013-03-07"
12
+ s.date = "2014-03-24"
13
13
  s.description = "gem to use the Mxit APIs at http://dev.mxit.com/docs/ "
14
14
  s.email = "grant.speelman@unboxedconsulting.com"
15
15
  s.extra_rdoc_files = [
@@ -42,7 +42,7 @@ Gem::Specification.new do |s|
42
42
  s.homepage = "http://github.com/unboxed/mxit_api"
43
43
  s.licenses = ["MIT"]
44
44
  s.require_paths = ["lib"]
45
- s.rubygems_version = "1.8.24"
45
+ s.rubygems_version = "1.8.25"
46
46
  s.summary = "gem to use Mxit APIs"
47
47
 
48
48
  if s.respond_to? :specification_version then
@@ -3,104 +3,104 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  describe MxitApi do
4
4
 
5
5
  before :each do
6
- token_body = %&{"access_token":"c71219af53f5409e9d1db61db8a08248",
6
+ token_body = '{"access_token":"c71219af53f5409e9d1db61db8a08248",
7
7
  "token_type":"bearer",
8
8
  "expires_in":3600,
9
9
  "refresh_token":"7f4b56bda11e4f7ba84c9e35c76b7aea",
10
- "scope":"message"}&
11
- stub_request(:post, "https://1:1@auth.mxit.com/token").to_return(:status => 200, :body => token_body, :headers => {})
10
+ "scope":"message"}'
11
+ stub_request(:post, 'https://1:1@auth.mxit.com/token').to_return(:status => 200, :body => token_body, :headers => {})
12
12
  end
13
13
 
14
- context "new" do
14
+ context 'new' do
15
15
 
16
- it "must post to mxit api requesting token" do
17
- MxitApi.new("1","1",
16
+ it 'must post to mxit api requesting token' do
17
+ MxitApi.new('1', '1',
18
18
  :grant_type => 'authorization_code',
19
- :code => "456",
20
- :redirect_uri => "http://www.test.dev/users/mxit_oauth")
21
- assert_requested(:post, "https://1:1@auth.mxit.com/token",
22
- :body => "grant_type=authorization_code&code=456&redirect_uri=http%3A%2F%2Fwww.test.dev%2Fusers%2Fmxit_oauth",
19
+ :code => '456',
20
+ :redirect_uri => 'http://www.test.dev/users/mxit_oauth')
21
+ assert_requested(:post, 'https://1:1@auth.mxit.com/token',
22
+ :body => 'grant_type=authorization_code&code=456&redirect_uri=http%3A%2F%2Fwww.test.dev%2Fusers%2Fmxit_oauth',
23
23
  :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Ruby'})
24
24
  end
25
25
 
26
- it "must set the access_token" do
27
- connection = MxitApi.new("1","1",
26
+ it 'must set the access_token' do
27
+ connection = MxitApi.new('1', '1',
28
28
  :grant_type => 'authorization_code',
29
- :code => "456",
30
- :redirect_uri => "/")
31
- connection.access_token.should == "c71219af53f5409e9d1db61db8a08248"
29
+ :code => '456',
30
+ :redirect_uri => '/')
31
+ connection.access_token.should == 'c71219af53f5409e9d1db61db8a08248'
32
32
  end
33
33
 
34
- it "must set the token_type" do
35
- connection = MxitApi.new("1","1",
34
+ it 'must set the token_type' do
35
+ connection = MxitApi.new('1', '1',
36
36
  :grant_type => 'authorization_code',
37
- :code => "456",
38
- :redirect_uri => "/")
39
- connection.token_type.should == "bearer"
37
+ :code => '456',
38
+ :redirect_uri => '/')
39
+ connection.token_type.should == 'bearer'
40
40
  end
41
41
 
42
- it "must set expire_at" do
42
+ it 'must set expire_at' do
43
43
  Timecop.freeze do
44
- connection = MxitApi.new("1","1",
44
+ connection = MxitApi.new('1', '1',
45
45
  :grant_type => 'authorization_code',
46
- :code => "456",
47
- :redirect_uri => "/")
46
+ :code => '456',
47
+ :redirect_uri => '/')
48
48
  connection.expire_at.should == 1.hour.from_now
49
49
  end
50
50
  end
51
51
 
52
- it "must set the refresh_token" do
53
- connection = MxitApi.new("1","1",
52
+ it 'must set the refresh_token' do
53
+ connection = MxitApi.new('1', '1',
54
54
  :grant_type => 'authorization_code',
55
- :code => "456",
56
- :redirect_uri => "/")
57
- connection.refresh_token.should == "7f4b56bda11e4f7ba84c9e35c76b7aea"
55
+ :code => '456',
56
+ :redirect_uri => '/')
57
+ connection.refresh_token.should == '7f4b56bda11e4f7ba84c9e35c76b7aea'
58
58
  end
59
59
 
60
- it "must set the scope" do
61
- connection = MxitApi.new("1","1",
60
+ it 'must set the scope' do
61
+ connection = MxitApi.new('1', '1',
62
62
  :grant_type => 'authorization_code',
63
- :code => "456",
64
- :redirect_uri => "/")
65
- connection.scope.should == "message"
63
+ :code => '456',
64
+ :redirect_uri => '/')
65
+ connection.scope.should == 'message'
66
66
  end
67
67
 
68
- it "must handle a failed response" do
69
- stub_request(:post, "https://1:1@auth.mxit.com/token").to_return(:status => 401, :body => '', :headers => {})
70
- connection = MxitApi.new("1","1",
68
+ it 'must handle a failed response' do
69
+ stub_request(:post, 'https://1:1@auth.mxit.com/token').to_return(:status => 401, :body => '', :headers => {})
70
+ connection = MxitApi.new('1', '1',
71
71
  :grant_type => 'authorization_code',
72
- :code => "456",
73
- :redirect_uri => "/")
72
+ :code => '456',
73
+ :redirect_uri => '/')
74
74
  connection.access_token.should be_nil
75
75
  end
76
76
 
77
77
  end
78
78
 
79
- context "connect" do
79
+ context 'connect' do
80
80
 
81
- it "must return connection if has access_token" do
82
- connection = mock('MxitApi', access_token: "123")
81
+ it 'must return connection if has access_token' do
82
+ connection = mock('MxitApi', access_token: '123')
83
83
  MxitApi.should_receive(:new).with(:grant_type => 'authorization_code',
84
- :code => "456",
85
- :redirect_uri => "/").and_return(connection)
84
+ :code => '456',
85
+ :redirect_uri => '/').and_return(connection)
86
86
  MxitApi.connect(:grant_type => 'authorization_code',
87
- :code => "456",
88
- :redirect_uri => "/").should == connection
87
+ :code => '456',
88
+ :redirect_uri => '/').should == connection
89
89
  end
90
90
 
91
- it "wont return connection if not access_token" do
91
+ it 'wont return connection if not access_token' do
92
92
  connection = mock('MxitApi', access_token: nil)
93
93
  MxitApi.should_receive(:new).with(:grant_type => 'authorization_code',
94
- :code => "456",
95
- :redirect_uri => "/").and_return(connection)
94
+ :code => '456',
95
+ :redirect_uri => '/').and_return(connection)
96
96
  MxitApi.connect(:grant_type => 'authorization_code',
97
- :code => "456",
98
- :redirect_uri => "/").should be_nil
97
+ :code => '456',
98
+ :redirect_uri => '/').should be_nil
99
99
  end
100
100
 
101
101
  end
102
102
 
103
- context "profile" do
103
+ context 'profile' do
104
104
 
105
105
  before :each do
106
106
  body = %&{ "DisplayName":"String content",
@@ -133,51 +133,51 @@ describe MxitApi do
133
133
  "RelationshipStatus":0,
134
134
  "WhereAmI":"String content"
135
135
  }&
136
- stub_request(:get, "https://api.mxit.com/user/profile").to_return(:status => 200, :body => body, :headers => {})
137
- @connection = MxitApi.new("1","1",
136
+ stub_request(:get, 'https://api.mxit.com/user/profile').to_return(:status => 200, :body => body, :headers => {})
137
+ @connection = MxitApi.new('1', '1',
138
138
  :grant_type => 'authorization_code',
139
- :code => "456",
140
- :redirect_uri => "/")
139
+ :code => '456',
140
+ :redirect_uri => '/')
141
141
  end
142
142
 
143
- it "must return a hash of the profile" do
143
+ it 'must return a hash of the profile' do
144
144
  profile = @connection.profile
145
145
  profile.should be_kind_of(Hash)
146
- profile[:first_name].should == "Grant"
147
- profile[:last_name].should == "Speelman"
148
- profile[:mobile_number].should == "0821234567"
146
+ profile[:first_name].should == 'Grant'
147
+ profile[:last_name].should == 'Speelman'
148
+ profile[:mobile_number].should == '0821234567'
149
149
  end
150
150
 
151
- it "must make the correct api request" do
152
- @connection.stub(:access_token).and_return("c71219af53f5409e9d1db61db8a08248")
153
- @connection.stub(:token_type).and_return("bearer")
151
+ it 'must make the correct api request' do
152
+ @connection.stub(:access_token).and_return('c71219af53f5409e9d1db61db8a08248')
153
+ @connection.stub(:token_type).and_return('bearer')
154
154
  @connection.profile
155
- assert_requested(:get, "https://api.mxit.com/user/profile",
155
+ assert_requested(:get, 'https://api.mxit.com/user/profile',
156
156
  :headers => {'Accept'=>'application/json',
157
157
  'Authorization'=>'bearer c71219af53f5409e9d1db61db8a08248',
158
158
  'User-Agent'=>'Ruby'})
159
159
  end
160
160
 
161
- it "must handle a failed response" do
162
- stub_request(:get, "https://api.mxit.com/user/profile").to_return(:status => 401, :body => '', :headers => {})
161
+ it 'must handle a failed response' do
162
+ stub_request(:get, 'https://api.mxit.com/user/profile').to_return(:status => 401, :body => '', :headers => {})
163
163
  profile = @connection.profile
164
164
  profile.should be_empty
165
165
  end
166
166
 
167
167
  end
168
168
 
169
- context "send_message" do
169
+ context 'send_message' do
170
170
 
171
171
  before :each do
172
- stub_request(:post, "https://api.mxit.com/message/send/").to_return(:status => 200, :body => '', :headers => {})
173
- @connection = MxitApi.new("1","1")
172
+ stub_request(:post, 'https://api.mxit.com/message/send/').to_return(:status => 200, :body => '', :headers => {})
173
+ @connection = MxitApi.new('1', '1')
174
174
  end
175
175
 
176
- it "must make the correct api request" do
177
- @connection.stub(:access_token).and_return("c71219af53f5409e9d1db61db8a08248")
178
- @connection.stub(:token_type).and_return("bearer")
179
- @connection.send_message(:to => "m123", :body => "Hello from the Mxit Api", :from => "tester", :spool_timeout => 23.hours.to_i)
180
- assert_requested(:post, "https://api.mxit.com/message/send/",
176
+ it 'must make the correct api request' do
177
+ @connection.stub(:access_token).and_return('c71219af53f5409e9d1db61db8a08248')
178
+ @connection.stub(:token_type).and_return('bearer')
179
+ @connection.send_message(:to => 'm123', :body => 'Hello from the Mxit Api', :from => 'tester', :spool_timeout => 23.hours.to_i)
180
+ assert_requested(:post, 'https://api.mxit.com/message/send/',
181
181
  :body => '{"To":"m123","Body":"Hello from the Mxit Api","From":"tester","SpoolTimeout":82800,"ContainsMarkup":"true"}',
182
182
  :headers => {'Accept'=>'application/json',
183
183
  'Authorization'=>'bearer c71219af53f5409e9d1db61db8a08248',
@@ -187,19 +187,19 @@ describe MxitApi do
187
187
 
188
188
  end
189
189
 
190
- context "send_invite" do
190
+ context 'send_invite' do
191
191
 
192
192
  before :each do
193
- stub_request(:put, "https://api.mxit.com/user/socialgraph/contact/contactname").
193
+ stub_request(:put, 'https://api.mxit.com/user/socialgraph/contact/contactname').
194
194
  to_return(:status => 200, :body => '', :headers => {})
195
- @connection = MxitApi.new("1","1")
195
+ @connection = MxitApi.new('1', '1')
196
196
  end
197
197
 
198
- it "must make the correct api request" do
199
- @connection.stub(:access_token).and_return("c71219af53f5409e9d1db61db8a08248")
200
- @connection.stub(:token_type).and_return("bearer")
201
- @connection.send_invite("contactname")
202
- assert_requested(:put, "https://api.mxit.com/user/socialgraph/contact/contactname",
198
+ it 'must make the correct api request' do
199
+ @connection.stub(:access_token).and_return('c71219af53f5409e9d1db61db8a08248')
200
+ @connection.stub(:token_type).and_return('bearer')
201
+ @connection.send_invite('contactname')
202
+ assert_requested(:put, 'https://api.mxit.com/user/socialgraph/contact/contactname',
203
203
  :headers => {'Accept'=>'application/json',
204
204
  'Authorization'=>'bearer c71219af53f5409e9d1db61db8a08248',
205
205
  'User-Agent'=>'Ruby'})
@@ -207,4 +207,4 @@ describe MxitApi do
207
207
 
208
208
  end
209
209
 
210
- end
210
+ end
@@ -3,84 +3,84 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  describe MxitMoneyApi do
4
4
 
5
5
  before :each do
6
- token_body = %&{
6
+ token_body = '{
7
7
  "balance": 5000
8
- }&
9
- stub_request(:get, "https://3:mxit_money_api@api.mxitmoney.co.za/paymentsplatform/rest/v3/push/").to_return(:status => 200, :body => token_body, :headers => {})
8
+ }'
9
+ stub_request(:get, 'https://3:mxit_money_api@api.mxitmoney.co.za/paymentsplatform/rest/v3/push/').to_return(:status => 200, :body => token_body, :headers => {})
10
10
  end
11
11
 
12
- context "new" do
12
+ context 'new' do
13
13
 
14
- it "must post to mxit api requesting token" do
15
- MxitMoneyApi.new("3")
16
- assert_requested(:get, "https://3:mxit_money_api@api.mxitmoney.co.za/paymentsplatform/rest/v3/push/",
14
+ it 'must post to mxit api requesting token' do
15
+ MxitMoneyApi.new('3')
16
+ assert_requested(:get, 'https://3:mxit_money_api@api.mxitmoney.co.za/paymentsplatform/rest/v3/push/',
17
17
  :headers => {'Accept'=>'application/json', 'User-Agent'=>'Ruby'})
18
18
  end
19
19
 
20
- it "must set the balance" do
21
- connection = MxitMoneyApi.new("3")
20
+ it 'must set the balance' do
21
+ connection = MxitMoneyApi.new('3')
22
22
  connection.balance.should == 5000
23
23
  end
24
24
 
25
25
  end
26
26
 
27
- context "connect" do
27
+ context 'connect' do
28
28
 
29
- it "must return connection if has access_token" do
30
- connection = mock('MxitMoneyApi', balance: "123")
31
- MxitMoneyApi.should_receive(:new).with("3").and_return(connection)
32
- MxitMoneyApi.connect("3").should == connection
29
+ it 'must return connection if has access_token' do
30
+ connection = mock('MxitMoneyApi', balance: '123')
31
+ MxitMoneyApi.should_receive(:new).with('3').and_return(connection)
32
+ MxitMoneyApi.connect('3').should == connection
33
33
  end
34
34
 
35
- it "wont return connection if no balance" do
35
+ it 'wont return connection if no balance' do
36
36
  connection = mock('MxitApi', balance: nil)
37
- MxitMoneyApi.should_receive(:new).with("3").and_return(connection)
38
- MxitMoneyApi.connect("3").should be_nil
37
+ MxitMoneyApi.should_receive(:new).with('3').and_return(connection)
38
+ MxitMoneyApi.connect('3').should be_nil
39
39
  end
40
40
 
41
41
  end
42
42
 
43
- context "user_info" do
43
+ context 'user_info' do
44
44
 
45
45
  before :each do
46
- @body = %&{ "isRegistered": true,
46
+ @body = '{ "isRegistered": true,
47
47
  "loginName": "gbox21",
48
48
  "mxitId": "m40000000000",
49
49
  "msisdn": "27712345678"
50
- }&
51
- @connection = MxitMoneyApi.new("3")
50
+ }'
51
+ @connection = MxitMoneyApi.new('3')
52
52
  end
53
53
 
54
- it "must return a hash for search by mxitId" do
55
- stub_request(:get, "https://3:mxit_money_api@api.mxitmoney.co.za/paymentsplatform/rest/v3/user/m40000000000?idType=mxitId").
54
+ it 'must return a hash for search by mxitId' do
55
+ stub_request(:get, 'https://3:mxit_money_api@api.mxitmoney.co.za/paymentsplatform/rest/v3/user/m40000000000?idType=mxitId').
56
56
  with(:headers => {'Accept'=>'application/json', 'User-Agent'=>'Ruby'}).
57
57
  to_return(:status => 200, :body => @body, :headers => {})
58
58
  profile = @connection.user_info(:id => 'm40000000000')
59
59
  profile.should be_kind_of(Hash)
60
60
  profile[:is_registered].should == true
61
- profile[:login_name].should == "gbox21"
62
- profile[:mxit_id].should == "m40000000000"
63
- profile[:msisdn].should == "27712345678"
61
+ profile[:login_name].should == 'gbox21'
62
+ profile[:mxit_id].should == 'm40000000000'
63
+ profile[:msisdn].should == '27712345678'
64
64
  end
65
65
 
66
- it "must return a hash for search by phoneNumber" do
67
- stub_request(:get, "https://3:mxit_money_api@api.mxitmoney.co.za/paymentsplatform/rest/v3/user/0712345678?idType=phoneNumber").
66
+ it 'must return a hash for search by phoneNumber' do
67
+ stub_request(:get, 'https://3:mxit_money_api@api.mxitmoney.co.za/paymentsplatform/rest/v3/user/0712345678?idType=phoneNumber').
68
68
  with(:headers => {'Accept'=>'application/json', 'User-Agent'=>'Ruby'}).
69
69
  to_return(:status => 200, :body => @body, :headers => {})
70
70
  profile = @connection.user_info(:id => '0712345678', :id_type => :phone_number)
71
71
  profile.should be_kind_of(Hash)
72
72
  profile[:is_registered].should == true
73
- profile[:login_name].should == "gbox21"
74
- profile[:mxit_id].should == "m40000000000"
75
- profile[:msisdn].should == "27712345678"
73
+ profile[:login_name].should == 'gbox21'
74
+ profile[:mxit_id].should == 'm40000000000'
75
+ profile[:msisdn].should == '27712345678'
76
76
  end
77
77
 
78
- it "must handle a failed response" do
79
- body = %&{
78
+ it 'must handle a failed response' do
79
+ body = '{
80
80
  "errorType": "INVALID_MSISDN",
81
81
  "message": "The phone number is incorrect."
82
- }&
83
- stub_request(:get, "https://3:mxit_money_api@api.mxitmoney.co.za/paymentsplatform/rest/v3/user/m40000000001?idType=mxitId").
82
+ }'
83
+ stub_request(:get, 'https://3:mxit_money_api@api.mxitmoney.co.za/paymentsplatform/rest/v3/user/m40000000001?idType=mxitId').
84
84
  with(:headers => {'Accept'=>'application/json', 'User-Agent'=>'Ruby'}).
85
85
  to_return(:status => 500, :body => body, :headers => {})
86
86
  profile = @connection.user_info(:id => 'm40000000001')
@@ -89,34 +89,34 @@ describe MxitMoneyApi do
89
89
 
90
90
  end
91
91
 
92
- context "issue_money" do
92
+ context 'issue_money' do
93
93
 
94
94
  before :each do
95
- @body = %&{
95
+ @body = '{
96
96
  "m2_reference": "886e797d-ff9b-4743-a6a6-908bf588b2f8"
97
- }&
98
- stub_request(:post, "https://3:mxit_money_api@api.mxitmoney.co.za/paymentsplatform/rest/v3/push/issue/0761234567?amountInCents=123&merchantReference=000000001").
97
+ }'
98
+ stub_request(:post, 'https://3:mxit_money_api@api.mxitmoney.co.za/paymentsplatform/rest/v3/push/issue/0761234567?amountInCents=123&merchantReference=000000001').
99
99
  to_return(:status => 200, :body => @body, :headers => {})
100
- @connection = MxitMoneyApi.new("3")
100
+ @connection = MxitMoneyApi.new('3')
101
101
  end
102
102
 
103
- it "must make the correct api request" do
104
- @connection.issue_money(:phone_number => "0761234567",
105
- :merchant_reference => "000000001",
106
- :amount_in_cents => "123")
107
- assert_requested(:post, "https://3:mxit_money_api@api.mxitmoney.co.za/paymentsplatform/rest/v3/push/issue/0761234567?amountInCents=123&merchantReference=000000001",
103
+ it 'must make the correct api request' do
104
+ @connection.issue_money(:phone_number => '0761234567',
105
+ :merchant_reference => '000000001',
106
+ :amount_in_cents => '123')
107
+ assert_requested(:post, 'https://3:mxit_money_api@api.mxitmoney.co.za/paymentsplatform/rest/v3/push/issue/0761234567?amountInCents=123&merchantReference=000000001',
108
108
  :headers => {'Accept'=>'application/json',
109
109
  'User-Agent'=>'Ruby',
110
110
  'Content-Type' =>'application/json'})
111
111
  end
112
112
 
113
- it "must handle a response" do
114
- profile = @connection.issue_money(:phone_number => "0761234567",
115
- :merchant_reference => "000000001",
116
- :amount_in_cents => "123")
113
+ it 'must handle a response' do
114
+ profile = @connection.issue_money(:phone_number => '0761234567',
115
+ :merchant_reference => '000000001',
116
+ :amount_in_cents => '123')
117
117
  profile.should_not be_empty
118
118
  end
119
119
 
120
120
  end
121
121
 
122
- end
122
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mxit_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2.pre
4
+ version: 0.2.3.pre
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-07 00:00:00.000000000 Z
12
+ date: 2014-03-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -231,7 +231,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
231
231
  version: '0'
232
232
  segments:
233
233
  - 0
234
- hash: 3521331508407363701
234
+ hash: -437369432245690590
235
235
  required_rubygems_version: !ruby/object:Gem::Requirement
236
236
  none: false
237
237
  requirements:
@@ -240,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
240
  version: 1.3.1
241
241
  requirements: []
242
242
  rubyforge_project:
243
- rubygems_version: 1.8.24
243
+ rubygems_version: 1.8.25
244
244
  signing_key:
245
245
  specification_version: 3
246
246
  summary: gem to use Mxit APIs