mxit_api 0.1.0.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ gem "activesupport", ">= 3.0.0"
5
+ gem "i18n", ">= 0.5.0"
6
+
7
+ # Add dependencies to develop your gem here.
8
+ # Include everything needed to run rake, tests, features, etc.
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"
17
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.2.8)
5
+ i18n (~> 0.6)
6
+ multi_json (~> 1.0)
7
+ addressable (2.3.2)
8
+ crack (0.3.1)
9
+ diff-lcs (1.1.3)
10
+ git (1.2.5)
11
+ i18n (0.6.1)
12
+ jeweler (1.8.4)
13
+ bundler (~> 1.0)
14
+ git (>= 1.2.5)
15
+ rake
16
+ rdoc
17
+ json (1.7.5)
18
+ multi_json (1.3.7)
19
+ rake (0.9.2.2)
20
+ rdoc (3.12)
21
+ json (~> 1.4)
22
+ rspec (2.11.0)
23
+ rspec-core (~> 2.11.0)
24
+ rspec-expectations (~> 2.11.0)
25
+ rspec-mocks (~> 2.11.0)
26
+ rspec-core (2.11.1)
27
+ rspec-expectations (2.11.3)
28
+ diff-lcs (~> 1.1.3)
29
+ rspec-mocks (2.11.3)
30
+ simplecov (0.7.1)
31
+ multi_json (~> 1.0)
32
+ simplecov-html (~> 0.7.1)
33
+ simplecov-html (0.7.1)
34
+ timecop (0.5.3)
35
+ webmock (1.9.0)
36
+ addressable (>= 2.2.7)
37
+ crack (>= 0.1.7)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ activesupport (>= 3.0.0)
44
+ bundler
45
+ i18n (>= 0.5.0)
46
+ jeweler
47
+ rdoc
48
+ rspec
49
+ simplecov
50
+ timecop
51
+ webmock
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Grant Speelman
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ MxitApi gem for API connections to mxit
2
+ =================================
3
+
4
+ This gem allows you to easily interact (http://dev.mxit.com/docs/):
5
+ * Authorization API (OAuth 2.0)
6
+ * Messaging API
7
+ * User API
8
+
9
+ Installation
10
+ ============
11
+
12
+ Place this in your Gemfile:
13
+ ```ruby
14
+ gem 'mxit_api'
15
+ ```
16
+ and run the bundle command or type this in the command line:
17
+
18
+ ```
19
+ gem install mxit_api
20
+ ```
21
+
22
+ Then try one of the examples below.
23
+
24
+ Examples
25
+ ========
26
+
27
+ Prerequisites (usually found on the mxit dashboard http://code.mxit.com/MobiDashboard/Default.aspx):
28
+ * MXIT_CLIENT_ID
29
+ * MXIT_CLIENT_SECRET
30
+
31
+
32
+ Authorization API
33
+ ----------------------------------------
34
+
35
+
36
+ Messaging API
37
+ ----------------
38
+
39
+
40
+ User API
41
+ ----------------
data/Rakefile ADDED
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ require './lib/mxit_api/version.rb'
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"]
24
+ gem.version = MxitApi::Version::STRING
25
+ # dependencies defined in Gemfile
26
+ gem.add_dependency 'activesupport', '>= 3.0.0'
27
+ gem.add_dependency 'i18n', '>= 0.5.0'
28
+ end
29
+ Jeweler::RubygemsDotOrgTasks.new
30
+
31
+ require 'rspec/core'
32
+ require 'rspec/core/rake_task'
33
+ RSpec::Core::RakeTask.new(:spec) do |spec|
34
+ spec.pattern = FileList['spec/**/*_spec.rb']
35
+ end
36
+
37
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
38
+ spec.pattern = 'spec/**/*_spec.rb'
39
+ spec.rcov = true
40
+ end
41
+
42
+ task :default => :spec
43
+
44
+ require 'rdoc/task'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "mxit_api #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
@@ -0,0 +1,30 @@
1
+ class MxitApi
2
+
3
+ attr_reader :access_token, :token_type, :refresh_token, :scope, :expire_at, :app_name
4
+
5
+ def initialize(client_id, client_secret, form_data = {grant_type: 'client_credentials', scope: 'message/send'})
6
+ if form_data.kind_of?(Hash)
7
+ url = URI.parse('https://auth.mxit.com/token')
8
+ req = Net::HTTP::Post.new(url.path, 'Accept'=>'application/json')
9
+ req.set_form_data(form_data)
10
+ req.basic_auth(client_id,client_secret)
11
+ http = Net::HTTP.new(url.host, url.port)
12
+ http.use_ssl = true
13
+ response = http.request(req)
14
+ if response.code == '200'
15
+ data = ActiveSupport::JSON.decode(response.body)
16
+ @access_token = data['access_token']
17
+ @token_type = data['token_type']
18
+ @refresh_token = data['refresh_token']
19
+ @scope = data['scope']
20
+ @expire_at = data['expires_in'].to_i.seconds.from_now
21
+ end
22
+ end
23
+ end
24
+
25
+ def self.connect(*args)
26
+ connection = new(*args)
27
+ connection.access_token ? connection : nil
28
+ end
29
+
30
+ end
@@ -0,0 +1,17 @@
1
+ class MxitApi
2
+
3
+ def profile
4
+ profile = {}
5
+ url = URI.parse('https://api.mxit.com/user/profile')
6
+ req = Net::HTTP::Get.new(url.path, 'Authorization' => "#{token_type} #{access_token}", 'Accept'=>'application/json')
7
+ http = Net::HTTP.new(url.host, url.port)
8
+ http.use_ssl = true
9
+ response = http.request(req)
10
+ if response.code == '200'
11
+ data = ActiveSupport::JSON.decode(response.body)
12
+ profile = Hash[data.map {|k, v| [k.underscore, v] }]
13
+ end
14
+ HashWithIndifferentAccess.new(profile)
15
+ end
16
+
17
+ end
@@ -0,0 +1,11 @@
1
+ class MxitApi
2
+
3
+ def send_invite(contact)
4
+ url = URI.parse("https://api.mxit.com/user/socialgraph/contact/#{contact}")
5
+ req = Net::HTTP::Put.new(url.path, 'Authorization' => "#{token_type} #{access_token}", 'Accept'=>'application/json')
6
+ http = Net::HTTP.new(url.host, url.port)
7
+ http.use_ssl = true
8
+ http.request(req)
9
+ end
10
+
11
+ end
@@ -0,0 +1,17 @@
1
+ class MxitApi
2
+
3
+ def send_message(params)
4
+ params = Hash[params.map {|k, v| [k.to_s.camelize, v] }]
5
+ params.reverse_merge!('ContainsMarkup' => 'true', 'From' => app_name)
6
+ url = URI.parse('https://api.mxit.com/message/send/')
7
+ req = Net::HTTP::Post.new(url.path,
8
+ 'Authorization' => "#{token_type} #{access_token}",
9
+ 'Accept'=>'application/json',
10
+ 'Content-Type' =>'application/json')
11
+ req.body = params.to_json
12
+ http = Net::HTTP.new(url.host, url.port)
13
+ http.use_ssl = true
14
+ http.request(req)
15
+ end
16
+
17
+ end
@@ -0,0 +1,10 @@
1
+ class MxitApi
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 1
5
+ PATCH = 0
6
+ BUILD = 'pre'
7
+
8
+ STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
9
+ end
10
+ end
data/lib/mxit_api.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'net/http'
2
+ require 'net/https'
3
+ require 'active_support/all'
4
+ require 'mxit_api/initialize'
5
+ require 'mxit_api/profile'
6
+ require 'mxit_api/send_invite'
7
+ require 'mxit_api/send_message'
8
+ require 'mxit_api/version'
data/mxit_api.gemspec ADDED
@@ -0,0 +1,86 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "mxit_api"
8
+ s.version = "0.1.0.pre"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Grant Speelman"]
12
+ s.date = "2012-11-08"
13
+ s.description = "gem to use the Mxit APIs at http://dev.mxit.com/docs/ "
14
+ s.email = "grant.speelman@unboxedconsulting.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ ".travis.yml",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.md",
27
+ "Rakefile",
28
+ "lib/mxit_api.rb",
29
+ "lib/mxit_api/initialize.rb",
30
+ "lib/mxit_api/profile.rb",
31
+ "lib/mxit_api/send_invite.rb",
32
+ "lib/mxit_api/send_message.rb",
33
+ "lib/mxit_api/version.rb",
34
+ "mxit_api.gemspec",
35
+ "spec/mxit_api_spec.rb",
36
+ "spec/spec_helper.rb"
37
+ ]
38
+ s.homepage = "http://github.com/unboxed/mxit_api"
39
+ s.licenses = ["MIT"]
40
+ s.require_paths = ["lib"]
41
+ s.rubygems_version = "1.8.24"
42
+ s.summary = "gem to use Mxit APIs"
43
+
44
+ if s.respond_to? :specification_version then
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
+ s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0"])
49
+ s.add_runtime_dependency(%q<i18n>, [">= 0.5.0"])
50
+ s.add_development_dependency(%q<rspec>, [">= 0"])
51
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
52
+ s.add_development_dependency(%q<bundler>, [">= 0"])
53
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
54
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
55
+ s.add_development_dependency(%q<webmock>, [">= 0"])
56
+ s.add_development_dependency(%q<timecop>, [">= 0"])
57
+ s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0"])
58
+ s.add_runtime_dependency(%q<i18n>, [">= 0.5.0"])
59
+ else
60
+ s.add_dependency(%q<activesupport>, [">= 3.0.0"])
61
+ s.add_dependency(%q<i18n>, [">= 0.5.0"])
62
+ s.add_dependency(%q<rspec>, [">= 0"])
63
+ s.add_dependency(%q<rdoc>, [">= 0"])
64
+ s.add_dependency(%q<bundler>, [">= 0"])
65
+ s.add_dependency(%q<jeweler>, [">= 0"])
66
+ s.add_dependency(%q<simplecov>, [">= 0"])
67
+ s.add_dependency(%q<webmock>, [">= 0"])
68
+ s.add_dependency(%q<timecop>, [">= 0"])
69
+ s.add_dependency(%q<activesupport>, [">= 3.0.0"])
70
+ s.add_dependency(%q<i18n>, [">= 0.5.0"])
71
+ end
72
+ else
73
+ s.add_dependency(%q<activesupport>, [">= 3.0.0"])
74
+ s.add_dependency(%q<i18n>, [">= 0.5.0"])
75
+ s.add_dependency(%q<rspec>, [">= 0"])
76
+ s.add_dependency(%q<rdoc>, [">= 0"])
77
+ s.add_dependency(%q<bundler>, [">= 0"])
78
+ s.add_dependency(%q<jeweler>, [">= 0"])
79
+ s.add_dependency(%q<simplecov>, [">= 0"])
80
+ s.add_dependency(%q<webmock>, [">= 0"])
81
+ s.add_dependency(%q<timecop>, [">= 0"])
82
+ s.add_dependency(%q<activesupport>, [">= 3.0.0"])
83
+ s.add_dependency(%q<i18n>, [">= 0.5.0"])
84
+ end
85
+ end
86
+
@@ -0,0 +1,210 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe MxitApi do
4
+
5
+ before :each do
6
+ token_body = %&{"access_token":"c71219af53f5409e9d1db61db8a08248",
7
+ "token_type":"bearer",
8
+ "expires_in":3600,
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 => {})
12
+ end
13
+
14
+ context "new" do
15
+
16
+ it "must post to mxit api requesting token" do
17
+ MxitApi.new("1","1",
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",
23
+ :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/x-www-form-urlencoded', 'User-Agent'=>'Ruby'})
24
+ end
25
+
26
+ it "must set the access_token" do
27
+ connection = MxitApi.new("1","1",
28
+ :grant_type => 'authorization_code',
29
+ :code => "456",
30
+ :redirect_uri => "/")
31
+ connection.access_token.should == "c71219af53f5409e9d1db61db8a08248"
32
+ end
33
+
34
+ it "must set the token_type" do
35
+ connection = MxitApi.new("1","1",
36
+ :grant_type => 'authorization_code',
37
+ :code => "456",
38
+ :redirect_uri => "/")
39
+ connection.token_type.should == "bearer"
40
+ end
41
+
42
+ it "must set expire_at" do
43
+ Timecop.freeze do
44
+ connection = MxitApi.new("1","1",
45
+ :grant_type => 'authorization_code',
46
+ :code => "456",
47
+ :redirect_uri => "/")
48
+ connection.expire_at.should == 1.hour.from_now
49
+ end
50
+ end
51
+
52
+ it "must set the refresh_token" do
53
+ connection = MxitApi.new("1","1",
54
+ :grant_type => 'authorization_code',
55
+ :code => "456",
56
+ :redirect_uri => "/")
57
+ connection.refresh_token.should == "7f4b56bda11e4f7ba84c9e35c76b7aea"
58
+ end
59
+
60
+ it "must set the scope" do
61
+ connection = MxitApi.new("1","1",
62
+ :grant_type => 'authorization_code',
63
+ :code => "456",
64
+ :redirect_uri => "/")
65
+ connection.scope.should == "message"
66
+ end
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",
71
+ :grant_type => 'authorization_code',
72
+ :code => "456",
73
+ :redirect_uri => "/")
74
+ connection.access_token.should be_nil
75
+ end
76
+
77
+ end
78
+
79
+ context "connect" do
80
+
81
+ it "must return connection if has access_token" do
82
+ connection = mock('MxitApi', access_token: "123")
83
+ MxitApi.should_receive(:new).with(:grant_type => 'authorization_code',
84
+ :code => "456",
85
+ :redirect_uri => "/").and_return(connection)
86
+ MxitApi.connect(:grant_type => 'authorization_code',
87
+ :code => "456",
88
+ :redirect_uri => "/").should == connection
89
+ end
90
+
91
+ it "wont return connection if not access_token" do
92
+ connection = mock('MxitApi', access_token: nil)
93
+ MxitApi.should_receive(:new).with(:grant_type => 'authorization_code',
94
+ :code => "456",
95
+ :redirect_uri => "/").and_return(connection)
96
+ MxitApi.connect(:grant_type => 'authorization_code',
97
+ :code => "456",
98
+ :redirect_uri => "/").should be_nil
99
+ end
100
+
101
+ end
102
+
103
+ context "profile" do
104
+
105
+ before :each do
106
+ body = %&{ "DisplayName":"String content",
107
+ "AvatarId":"String content",
108
+ "State":{
109
+ "Availability":0,
110
+ "IsOnline":true,
111
+ "LastModified":"\\/Date(928142400000+0200)\\/",
112
+ "LastOnline":"\\/Date(928142400000+0200)\\/",
113
+ "Mood":0,
114
+ "StatusMessage":"String content"
115
+ },
116
+ "UserId":"String content",
117
+ "AboutMe":"String content",
118
+ "Age":32767,
119
+ "FirstName":"Grant",
120
+ "Gender":0,
121
+ "LanguageCode":"String content",
122
+ "LastKnownCountryCode":"String content",
123
+ "LastName":"Speelman",
124
+ "NetworkOperatorCode":"String content",
125
+ "RegisteredCountryCode":"String content",
126
+ "RegistrationDate":"\\/Date(928142400000+0200)\\/",
127
+ "StatusMessage":"String content",
128
+ "Title":"String content",
129
+ "CurrentCultureName":"String content",
130
+ "DateOfBirth":"\\/Date(928142400000+0200)\\/",
131
+ "Email":"String content",
132
+ "MobileNumber":"0821234567",
133
+ "RelationshipStatus":0,
134
+ "WhereAmI":"String content"
135
+ }&
136
+ stub_request(:get, "https://api.mxit.com/user/profile").to_return(:status => 200, :body => body, :headers => {})
137
+ @connection = MxitApi.new("1","1",
138
+ :grant_type => 'authorization_code',
139
+ :code => "456",
140
+ :redirect_uri => "/")
141
+ end
142
+
143
+ it "must return a hash of the profile" do
144
+ profile = @connection.profile
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"
149
+ end
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")
154
+ @connection.profile
155
+ assert_requested(:get, "https://api.mxit.com/user/profile",
156
+ :headers => {'Accept'=>'application/json',
157
+ 'Authorization'=>'bearer c71219af53f5409e9d1db61db8a08248',
158
+ 'User-Agent'=>'Ruby'})
159
+ end
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 => {})
163
+ profile = @connection.profile
164
+ profile.should be_empty
165
+ end
166
+
167
+ end
168
+
169
+ context "send_message" do
170
+
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")
174
+ end
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/",
181
+ :body => '{"To":"m123","Body":"Hello from the Mxit Api","From":"tester","SpoolTimeout":82800,"ContainsMarkup":"true"}',
182
+ :headers => {'Accept'=>'application/json',
183
+ 'Authorization'=>'bearer c71219af53f5409e9d1db61db8a08248',
184
+ 'User-Agent'=>'Ruby',
185
+ 'Content-Type' =>'application/json'})
186
+ end
187
+
188
+ end
189
+
190
+ context "send_invite" do
191
+
192
+ before :each do
193
+ stub_request(:put, "https://api.mxit.com/user/socialgraph/contact/contactname").
194
+ to_return(:status => 200, :body => '', :headers => {})
195
+ @connection = MxitApi.new("1","1")
196
+ end
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",
203
+ :headers => {'Accept'=>'application/json',
204
+ 'Authorization'=>'bearer c71219af53f5409e9d1db61db8a08248',
205
+ 'User-Agent'=>'Ruby'})
206
+ end
207
+
208
+ end
209
+
210
+ end
@@ -0,0 +1,14 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'webmock/rspec'
5
+ require 'timecop'
6
+ require 'mxit_api'
7
+
8
+ # Requires supporting files with custom matchers and macros, etc,
9
+ # in ./support/ and its subdirectories.
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
+
12
+ RSpec.configure do |config|
13
+
14
+ end
metadata ADDED
@@ -0,0 +1,243 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mxit_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.pre
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Grant Speelman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: i18n
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.5.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.5.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rdoc
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: bundler
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: jeweler
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: simplecov
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: webmock
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: timecop
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: activesupport
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: 3.0.0
166
+ type: :runtime
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: 3.0.0
174
+ - !ruby/object:Gem::Dependency
175
+ name: i18n
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: 0.5.0
182
+ type: :runtime
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: 0.5.0
190
+ description: ! 'gem to use the Mxit APIs at http://dev.mxit.com/docs/ '
191
+ email: grant.speelman@unboxedconsulting.com
192
+ executables: []
193
+ extensions: []
194
+ extra_rdoc_files:
195
+ - LICENSE.txt
196
+ - README.md
197
+ files:
198
+ - .document
199
+ - .rspec
200
+ - .travis.yml
201
+ - Gemfile
202
+ - Gemfile.lock
203
+ - LICENSE.txt
204
+ - README.md
205
+ - Rakefile
206
+ - lib/mxit_api.rb
207
+ - lib/mxit_api/initialize.rb
208
+ - lib/mxit_api/profile.rb
209
+ - lib/mxit_api/send_invite.rb
210
+ - lib/mxit_api/send_message.rb
211
+ - lib/mxit_api/version.rb
212
+ - mxit_api.gemspec
213
+ - spec/mxit_api_spec.rb
214
+ - spec/spec_helper.rb
215
+ homepage: http://github.com/unboxed/mxit_api
216
+ licenses:
217
+ - MIT
218
+ post_install_message:
219
+ rdoc_options: []
220
+ require_paths:
221
+ - lib
222
+ required_ruby_version: !ruby/object:Gem::Requirement
223
+ none: false
224
+ requirements:
225
+ - - ! '>='
226
+ - !ruby/object:Gem::Version
227
+ version: '0'
228
+ segments:
229
+ - 0
230
+ hash: 3437017726523863957
231
+ required_rubygems_version: !ruby/object:Gem::Requirement
232
+ none: false
233
+ requirements:
234
+ - - ! '>'
235
+ - !ruby/object:Gem::Version
236
+ version: 1.3.1
237
+ requirements: []
238
+ rubyforge_project:
239
+ rubygems_version: 1.8.24
240
+ signing_key:
241
+ specification_version: 3
242
+ summary: gem to use Mxit APIs
243
+ test_files: []