mxit_api 0.2.3.pre → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,6 +5,7 @@ require 'mxit_api/initialize'
5
5
  require 'mxit_api/profile'
6
6
  require 'mxit_api/send_invite'
7
7
  require 'mxit_api/send_message'
8
+ require 'mxit_api/user_id'
8
9
  require 'mxit_api/version'
9
10
  require 'mxit_money_api/initialize'
10
11
  require 'mxit_money_api/user'
@@ -14,4 +14,4 @@ class MxitApi
14
14
  http.request(req)
15
15
  end
16
16
 
17
- end
17
+ end
@@ -0,0 +1,16 @@
1
+ class MxitApi
2
+ def user_id
3
+ url = URI.parse('https://auth.mxit.com/userinfo?schema=openid')
4
+ req = Net::HTTP::Get.new('/userinfo?schema=openid',
5
+ 'Authorization' => "#{token_type} #{access_token}",
6
+ 'Accept'=>'application/json',
7
+ 'Content-Type' =>'application/json')
8
+ http = Net::HTTP.new(url.host, url.port)
9
+ http.use_ssl = true
10
+ response = http.request(req)
11
+ if response.code == '200'
12
+ data = ActiveSupport::JSON.decode(response.body)
13
+ data['sub']
14
+ end
15
+ end
16
+ end
@@ -1,9 +1,8 @@
1
1
  class MxitApi
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 2
5
- PATCH = 3
6
- BUILD = 'pre'
7
- STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
4
+ MINOR = 3
5
+ PATCH = 0
6
+ STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
7
  end
9
8
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "mxit_api"
8
- s.version = "0.2.3.pre"
8
+ s.version = "0.3.0"
9
9
 
10
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Grant Speelman"]
12
- s.date = "2014-03-24"
12
+ s.date = "2014-08-14"
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 = [
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
30
30
  "lib/mxit_api/profile.rb",
31
31
  "lib/mxit_api/send_invite.rb",
32
32
  "lib/mxit_api/send_message.rb",
33
+ "lib/mxit_api/user_id.rb",
33
34
  "lib/mxit_api/version.rb",
34
35
  "lib/mxit_money_api/initialize.rb",
35
36
  "lib/mxit_money_api/issue_money.rb",
@@ -1,7 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe MxitApi do
4
-
5
4
  before :each do
6
5
  token_body = '{"access_token":"c71219af53f5409e9d1db61db8a08248",
7
6
  "token_type":"bearer",
@@ -11,8 +10,7 @@ describe MxitApi do
11
10
  stub_request(:post, 'https://1:1@auth.mxit.com/token').to_return(:status => 200, :body => token_body, :headers => {})
12
11
  end
13
12
 
14
- context 'new' do
15
-
13
+ describe 'new' do
16
14
  it 'must post to mxit api requesting token' do
17
15
  MxitApi.new('1', '1',
18
16
  :grant_type => 'authorization_code',
@@ -73,11 +71,9 @@ describe MxitApi do
73
71
  :redirect_uri => '/')
74
72
  connection.access_token.should be_nil
75
73
  end
76
-
77
74
  end
78
75
 
79
- context 'connect' do
80
-
76
+ describe 'connect' do
81
77
  it 'must return connection if has access_token' do
82
78
  connection = mock('MxitApi', access_token: '123')
83
79
  MxitApi.should_receive(:new).with(:grant_type => 'authorization_code',
@@ -97,11 +93,9 @@ describe MxitApi do
97
93
  :code => '456',
98
94
  :redirect_uri => '/').should be_nil
99
95
  end
100
-
101
96
  end
102
97
 
103
- context 'profile' do
104
-
98
+ describe 'profile' do
105
99
  before :each do
106
100
  body = %&{ "DisplayName":"String content",
107
101
  "AvatarId":"String content",
@@ -163,11 +157,9 @@ describe MxitApi do
163
157
  profile = @connection.profile
164
158
  profile.should be_empty
165
159
  end
166
-
167
160
  end
168
161
 
169
- context 'send_message' do
170
-
162
+ describe 'send_message' do
171
163
  before :each do
172
164
  stub_request(:post, 'https://api.mxit.com/message/send/').to_return(:status => 200, :body => '', :headers => {})
173
165
  @connection = MxitApi.new('1', '1')
@@ -184,11 +176,9 @@ describe MxitApi do
184
176
  'User-Agent'=>'Ruby',
185
177
  'Content-Type' =>'application/json'})
186
178
  end
187
-
188
179
  end
189
180
 
190
- context 'send_invite' do
191
-
181
+ describe 'send_invite' do
192
182
  before :each do
193
183
  stub_request(:put, 'https://api.mxit.com/user/socialgraph/contact/contactname').
194
184
  to_return(:status => 200, :body => '', :headers => {})
@@ -204,7 +194,5 @@ describe MxitApi do
204
194
  'Authorization'=>'bearer c71219af53f5409e9d1db61db8a08248',
205
195
  'User-Agent'=>'Ruby'})
206
196
  end
207
-
208
197
  end
209
-
210
198
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mxit_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3.pre
5
- prerelease: 6
4
+ version: 0.3.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Grant Speelman
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-24 00:00:00.000000000 Z
12
+ date: 2014-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -208,6 +208,7 @@ files:
208
208
  - lib/mxit_api/profile.rb
209
209
  - lib/mxit_api/send_invite.rb
210
210
  - lib/mxit_api/send_message.rb
211
+ - lib/mxit_api/user_id.rb
211
212
  - lib/mxit_api/version.rb
212
213
  - lib/mxit_money_api/initialize.rb
213
214
  - lib/mxit_money_api/issue_money.rb
@@ -231,13 +232,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
231
232
  version: '0'
232
233
  segments:
233
234
  - 0
234
- hash: -437369432245690590
235
+ hash: -1289430584820972498
235
236
  required_rubygems_version: !ruby/object:Gem::Requirement
236
237
  none: false
237
238
  requirements:
238
- - - ! '>'
239
+ - - ! '>='
239
240
  - !ruby/object:Gem::Version
240
- version: 1.3.1
241
+ version: '0'
241
242
  requirements: []
242
243
  rubyforge_project:
243
244
  rubygems_version: 1.8.25