telesocial 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/README.markdown +41 -0
- data/Rakefile +1 -0
- data/lib/telesocial/client.rb +346 -0
- data/lib/telesocial/errors.rb +23 -0
- data/lib/telesocial/version.rb +3 -0
- data/lib/telesocial.rb +5 -0
- data/telesocial.gemspec +31 -0
- data/test/telesocial_client_functional_test.rb +38 -0
- data/test/telesocial_client_test.rb +83 -0
- data/test/test_helper.rb +14 -0
- metadata +164 -0
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
Telesocial API Ruby gem
|
2
|
+
=======================
|
3
|
+
|
4
|
+
Telesocial's free calling API enables mobile calling in social networks.
|
5
|
+
This is a Ruby interface to [Telesocial API](http://sites.telesocial.com/docs/home).
|
6
|
+
|
7
|
+
Installation
|
8
|
+
------------
|
9
|
+
|
10
|
+
gem install telesocial
|
11
|
+
|
12
|
+
Usage - Examples
|
13
|
+
----------------
|
14
|
+
```ruby
|
15
|
+
require 'telesocial'
|
16
|
+
client = Telesocial::Client.new('your_api_key') # Now, all telesocial methods are available to your client
|
17
|
+
|
18
|
+
# Method calls on the client returns a simple object that matches
|
19
|
+
# Telesocial's API response object.
|
20
|
+
|
21
|
+
# Register a user with username "eric" and phone number: 4054441212
|
22
|
+
response = client.register("eric", "4054441212")
|
23
|
+
puts response.status # => 201
|
24
|
+
puts response.uri # => "/api/rest/registrant/eric"
|
25
|
+
|
26
|
+
# Check a user's registration status
|
27
|
+
response = begin
|
28
|
+
client.get_registration_status('eric')
|
29
|
+
rescue Telesocial::NotFound
|
30
|
+
# Registration not found;
|
31
|
+
else
|
32
|
+
# Other errors
|
33
|
+
end
|
34
|
+
|
35
|
+
# Upload a file to be played to a registered user
|
36
|
+
media_id = client.create_media.mediaId
|
37
|
+
upload_request_grant_id = client.request_upload_grant(media_id)
|
38
|
+
|
39
|
+
uploaded_file_url = client.upload_file(upload_request_grant_id, "my_file_path.mp3")
|
40
|
+
|
41
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,346 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'hashie'
|
3
|
+
require 'net/http/post/multipart'
|
4
|
+
require 'mime/types'
|
5
|
+
|
6
|
+
module Telesocial
|
7
|
+
class Client
|
8
|
+
include HTTParty
|
9
|
+
base_uri 'https://api4.bitmouth.com'
|
10
|
+
disable_rails_query_string_format
|
11
|
+
|
12
|
+
class ResponseParser < HTTParty::Parser
|
13
|
+
def parse
|
14
|
+
begin
|
15
|
+
Hashie::Mash.new(Crack::JSON.parse(body).values.first)
|
16
|
+
rescue
|
17
|
+
body
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
parser ResponseParser
|
22
|
+
|
23
|
+
attr_reader :api_key
|
24
|
+
|
25
|
+
def initialize(api_key)
|
26
|
+
@api_key = api_key
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_registration_status(network_id, query = "exists")
|
30
|
+
|
31
|
+
response = post("/api/rest/registrant/#{network_id}", :body => {:query => query, :appkey => @api_key})
|
32
|
+
|
33
|
+
case response.status
|
34
|
+
when 200
|
35
|
+
response.registered = true
|
36
|
+
when 401
|
37
|
+
raise Telesocial::Unauthorized.new("The network ID exists but it is not associated with the specified application", response)
|
38
|
+
when 404
|
39
|
+
raise Telesocial::NotFound.new("The device is not registered.", response)
|
40
|
+
else
|
41
|
+
raise Telesocial::Error.new(response.message, response)
|
42
|
+
end
|
43
|
+
|
44
|
+
return response
|
45
|
+
end
|
46
|
+
|
47
|
+
def register(network_id, phone, greeting_id = nil)
|
48
|
+
response = post("/api/rest/registrant/", :body => {:networkid => network_id, :phone => phone, :appkey => @api_key, :greetingid => greeting_id})
|
49
|
+
|
50
|
+
case response.status
|
51
|
+
when 201
|
52
|
+
when 400
|
53
|
+
raise Telesocial::BadRequest.new("One or more parameters were invalid or this (phone, networkid) pair is already registered.", response)
|
54
|
+
when 502
|
55
|
+
raise Telesocial::BadGateway.new("Unable to start the phone authorization process.", response)
|
56
|
+
else
|
57
|
+
raise Telesocial::Error.new(response.message, response)
|
58
|
+
end
|
59
|
+
|
60
|
+
response
|
61
|
+
end
|
62
|
+
|
63
|
+
def create_media()
|
64
|
+
response = post("/api/rest/media/", :body => {:appkey => @api_key})
|
65
|
+
|
66
|
+
case response.status
|
67
|
+
when 201
|
68
|
+
when 400
|
69
|
+
raise Telesocial::BadRequest.new("Missing parameter(s)", response)
|
70
|
+
when 404
|
71
|
+
raise Telesocial::NotFound.new("The application key is invalid.", response)
|
72
|
+
end
|
73
|
+
|
74
|
+
response
|
75
|
+
end
|
76
|
+
|
77
|
+
def record(network_id, media_id)
|
78
|
+
response = post("/api/rest/media/#{media_id}",:body => {:networkid => network_id, :appkey => @api_key, :action => "record"})
|
79
|
+
|
80
|
+
case response.status
|
81
|
+
when 201
|
82
|
+
when 400
|
83
|
+
raise Telesocial::BadRequest.new("Missing parameter(s).", response)
|
84
|
+
when 404
|
85
|
+
raise Telesocial::NotFound.new("The application key is invalid or the application is not associated with the networkid.", response)
|
86
|
+
when 502
|
87
|
+
raise Telesocial::BadGateway.new("Unable to initiate phone call at this time.", response)
|
88
|
+
end
|
89
|
+
|
90
|
+
response
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
def blast(network_id, media_id)
|
95
|
+
response = post("/api/rest/media/#{media_id}",:body => {:networkid => network_id, :appkey => @api_key, :action => "blast"})
|
96
|
+
|
97
|
+
case response.status
|
98
|
+
when 200,201,202
|
99
|
+
when 400
|
100
|
+
raise Telesocial::BadRequest.new("Missing parameter(s).", response)
|
101
|
+
when 404
|
102
|
+
raise Telesocial::NotFound.new("The application key is invalid or the application is not associated with the networkid.", response)
|
103
|
+
when 502
|
104
|
+
raise Telesocial::BadGateway.new("Unable to initiate phone call at this time.", response)
|
105
|
+
end
|
106
|
+
|
107
|
+
response
|
108
|
+
end
|
109
|
+
|
110
|
+
def request_upload_grant(media_id)
|
111
|
+
response = post("/api/rest/media/#{media_id}",:body => {:appkey => @api_key, :action => "upload_grant"})
|
112
|
+
|
113
|
+
case response.status
|
114
|
+
when 201,202
|
115
|
+
when 400
|
116
|
+
raise Telesocial::BadRequest.new("Missing or invalid parameter(s).", response)
|
117
|
+
when 401
|
118
|
+
raise Telesocial::Unauthorized.new("The media ID is invalid or is not associated with the application identified by the appkey parameter.", response)
|
119
|
+
end
|
120
|
+
|
121
|
+
response
|
122
|
+
end
|
123
|
+
|
124
|
+
def media_status(media_id)
|
125
|
+
response = get("/api/rest/media/status/#{media_id}", :query => {:appkey => @api_key})
|
126
|
+
|
127
|
+
case response.status
|
128
|
+
when 200,201,202
|
129
|
+
when 204
|
130
|
+
raise Telesocial::NoContent.new("No media content exists for this Media ID.", response)
|
131
|
+
when 404
|
132
|
+
raise Telesocial::NotFound.new("The application key or networkid are invalid.", response)
|
133
|
+
end
|
134
|
+
|
135
|
+
response
|
136
|
+
end
|
137
|
+
|
138
|
+
def remove_media(media_id)
|
139
|
+
response = delete("/api/rest/media/#{media_id}",:body => {:appkey => @api_key, :action => "remove"})
|
140
|
+
|
141
|
+
case response.status
|
142
|
+
when 200
|
143
|
+
when 400
|
144
|
+
raise Telesocial::BadRequest.new("Missing or invalid parameter(s).", response)
|
145
|
+
when 401
|
146
|
+
raise Telesocial::Unauthorized.new("The content associated with the media ID cannot be removed.", response)
|
147
|
+
when 404
|
148
|
+
raise Telesocial::NotFound.new("The media ID is invalid.", response)
|
149
|
+
end
|
150
|
+
|
151
|
+
response
|
152
|
+
end
|
153
|
+
|
154
|
+
def create_conference(network_id, recording_id = nil, greeting_id = nil)
|
155
|
+
|
156
|
+
options = {}
|
157
|
+
options[:recordingid] = recording_id if recording_id
|
158
|
+
options[:greetingid] = greeting_id if greeting_id
|
159
|
+
|
160
|
+
response = post("/api/rest/conference/", :body => {:networkid => args, :appkey => @api_key}.merge(options))
|
161
|
+
|
162
|
+
case response.status
|
163
|
+
when 201
|
164
|
+
when 502
|
165
|
+
raise Telesocial::BadGateway.new("The request cannot be fulfilled at this time.", response)
|
166
|
+
else
|
167
|
+
raise Telesocial::Error.new("The request cannot be fulfilled at this time.", response)
|
168
|
+
end
|
169
|
+
|
170
|
+
response
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
def add_to_conference(conference_id, network_id)
|
175
|
+
response = post("/api/rest/conference/#{conference_id}", :body => {:networkid => network_id, :appkey => @api_key, :action => 'add'})
|
176
|
+
|
177
|
+
case response.status
|
178
|
+
when 200
|
179
|
+
when 400
|
180
|
+
raise Telesocial::BadRequest.new("Missing or invalid parameter(s).", response)
|
181
|
+
when 502
|
182
|
+
raise Telesocial::BadGateway.new("Unable to initiate phone(s) call at this time.", response)
|
183
|
+
end
|
184
|
+
|
185
|
+
response
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
def close_conference(conference_id)
|
190
|
+
response = post("/api/rest/conference//#{conference_id}", :body => {:appkey => @api_key, :action => 'close'})
|
191
|
+
|
192
|
+
case response.status
|
193
|
+
when 200
|
194
|
+
when 400
|
195
|
+
raise Telesocial::BadRequest.new("Missing or invalid parameter(s).", response)
|
196
|
+
when 404
|
197
|
+
raise Telesocial::NotFound.new("The conference ID is invalid.", response)
|
198
|
+
when 502
|
199
|
+
raise Telesocial::BadGateway.new("Unable to terminate conference calls.", response)
|
200
|
+
end
|
201
|
+
|
202
|
+
response
|
203
|
+
end
|
204
|
+
|
205
|
+
def hangup_call(conference_id, network_id)
|
206
|
+
response = post("/api/rest/conference/#{conference_id}/#{network_id}", :body => {:appkey => @api_key, :action => 'hangup'})
|
207
|
+
|
208
|
+
case response.status
|
209
|
+
when 200
|
210
|
+
when 400
|
211
|
+
raise Telesocial::BadRequest.new("Missing or invalid parameter(s).", response)
|
212
|
+
when 401
|
213
|
+
raise Telesocial::Unauthorized.new("The specified network ID is not associated with the application identified by the application key.", response)
|
214
|
+
when 404
|
215
|
+
raise Telesocial::NotFound.new("The conference ID is invalid.", response)
|
216
|
+
when 502
|
217
|
+
raise Telesocial::BadGateway.new("Unable to terminate call at this time.", response)
|
218
|
+
end
|
219
|
+
|
220
|
+
response
|
221
|
+
end
|
222
|
+
|
223
|
+
def move_call(from_conference_id, to_conference_id, network_id)
|
224
|
+
response = post("/api/rest/conference/#{from_conference_id}/#{network_id}", :body => {:appkey => @api_key, :toconferenceid => to_conference_id, :action => 'move'})
|
225
|
+
|
226
|
+
case response.status
|
227
|
+
when 200
|
228
|
+
when 400
|
229
|
+
raise Telesocial::BadRequest.new("Missing or invalid parameter(s).", response)
|
230
|
+
when 401
|
231
|
+
raise Telesocial::Unauthorized.new("The specified network ID is not associated with the application identified by the application key.", response)
|
232
|
+
when 502
|
233
|
+
raise Telesocial::BadGateway.new("Unable to move call.", response)
|
234
|
+
end
|
235
|
+
|
236
|
+
response
|
237
|
+
end
|
238
|
+
|
239
|
+
def mute(conference_id, network_id)
|
240
|
+
response = post("/api/rest/conference/#{conference_id}/#{network_id}", :body => {:app_key => @api_key, :action => "mute"})
|
241
|
+
|
242
|
+
case response.status
|
243
|
+
when 200
|
244
|
+
when 400
|
245
|
+
raise Telesocial::BadRequest.new("Missing or invalid parameter(s).", response)
|
246
|
+
when 401
|
247
|
+
raise Telesocial::Unauthorized.new("One or more of the specified network IDs is not associated with the application identified by the application key.", response)
|
248
|
+
when 502
|
249
|
+
raise Telesocial::BadGateway.new("Unable to mute call(s).", response)
|
250
|
+
end
|
251
|
+
|
252
|
+
response
|
253
|
+
end
|
254
|
+
|
255
|
+
def unmute(conference_id, network_id)
|
256
|
+
response = self.class.post("/api/rest/conference/#{conference_id}/#{network_id}", :body => {:app_key => @api_key, :action => "unmute"})
|
257
|
+
|
258
|
+
case response.status
|
259
|
+
when 200
|
260
|
+
when 400
|
261
|
+
raise Telesocial::BadRequest.new("Missing or invalid parameter(s).", response)
|
262
|
+
when 401
|
263
|
+
raise Telesocial::Unauthorized.new("One or more of the specified network IDs is not associated with the application identified by the application key.", response)
|
264
|
+
when 502
|
265
|
+
raise Telesocial::BadGateway.new("Unable to unmute call(s).", response)
|
266
|
+
end
|
267
|
+
|
268
|
+
response
|
269
|
+
end
|
270
|
+
|
271
|
+
def get_version
|
272
|
+
response = self.class.get("/api/rest/version").parsed_response
|
273
|
+
end
|
274
|
+
|
275
|
+
def upload_file(upload_grant_id, file_path)
|
276
|
+
uri = URI.parse(self.class.base_uri)
|
277
|
+
req = Net::HTTP::Post::Multipart.new "/forklift/", {"grant" => upload_grant_id, "mediafile" => UploadIO.new(file_path, mime_for(file_path))}
|
278
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
279
|
+
if (uri.scheme == "https")
|
280
|
+
http.use_ssl = true
|
281
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
282
|
+
end
|
283
|
+
res = http.request(req)
|
284
|
+
|
285
|
+
case res
|
286
|
+
when Net::HTTPSuccess
|
287
|
+
when Net::HTTPBadRequest
|
288
|
+
raise Telesocial::BadRequest.new("Missing or invalid parameter(s).", res)
|
289
|
+
when Net::HTTPNotFound
|
290
|
+
raise Telesocial::NotFound.new("The grant code is invalid.", res)
|
291
|
+
when Net::HTTPRequestEntityTooLarge
|
292
|
+
raise Telesocial::RequestEntityTooLarge.new("The file is larger than the allowed limit.", res)
|
293
|
+
when Net::HTTPUnsupportedMediaType
|
294
|
+
raise Telesocial::UnsupportedMediaTpe.new("The file is not an MP3 file. Only MP3 files may be uploaded at this time.", res)
|
295
|
+
end
|
296
|
+
|
297
|
+
res.body
|
298
|
+
|
299
|
+
end
|
300
|
+
|
301
|
+
# Handling for general errors
|
302
|
+
private
|
303
|
+
def post(url, options = {})
|
304
|
+
response = self.class.post(url, :query => options[:query], :body => options[:body])
|
305
|
+
parsed_response = response.parsed_response
|
306
|
+
|
307
|
+
case response.code
|
308
|
+
when 500
|
309
|
+
raise Telesocial::Error.new("Internal Server Error", response)
|
310
|
+
end
|
311
|
+
|
312
|
+
parsed_response
|
313
|
+
end
|
314
|
+
|
315
|
+
def get(url, options = {})
|
316
|
+
response = self.class.get(url, :query => options[:query])
|
317
|
+
parsed_response = response.parsed_response
|
318
|
+
|
319
|
+
case response.code
|
320
|
+
when 500
|
321
|
+
raise Telesocial::Error.new("Internal Server Error", response)
|
322
|
+
end
|
323
|
+
|
324
|
+
parsed_response
|
325
|
+
end
|
326
|
+
|
327
|
+
def delete(url, options = {})
|
328
|
+
response = self.class.delete(url, :query => options[:query], :body => options[:body])
|
329
|
+
parsed_response = response.parsed_response
|
330
|
+
|
331
|
+
case response.code
|
332
|
+
when 500
|
333
|
+
raise Telesocial::Error.new("Internal Server Error", response)
|
334
|
+
end
|
335
|
+
|
336
|
+
parsed_response
|
337
|
+
end
|
338
|
+
|
339
|
+
def mime_for(path)
|
340
|
+
mime = MIME::Types.type_for path
|
341
|
+
mime.empty? ? 'text/plain' : mime[0].content_type
|
342
|
+
end
|
343
|
+
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Telesocial
|
2
|
+
class Error < StandardError
|
3
|
+
attr_reader :response
|
4
|
+
|
5
|
+
def initialize(message, response)
|
6
|
+
@response = response
|
7
|
+
super(info(message, response))
|
8
|
+
end
|
9
|
+
|
10
|
+
def info(text = '', env = Hashie::Mash.new)
|
11
|
+
"#{text} - (server message: #{env.message})"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class NotFound < Error; end;
|
16
|
+
class Unauthorized < Error; end;
|
17
|
+
class BadRequest < Error; end;
|
18
|
+
class BadGateway < Error; end;
|
19
|
+
class RequestEntityTooLarge < Error; end;
|
20
|
+
class UnsupportedMediaTpe < Error; end;
|
21
|
+
|
22
|
+
end
|
23
|
+
|
data/lib/telesocial.rb
ADDED
data/telesocial.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "telesocial/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "telesocial"
|
7
|
+
s.version = Telesocial::VERSION
|
8
|
+
s.authors = ["Selem Delul"]
|
9
|
+
s.email = ["selem@selem.im"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Ruby wrapper for Telesocial API}
|
12
|
+
s.description = %q{Ruby wrapper for Telesocial API}
|
13
|
+
|
14
|
+
s.rubyforge_project = "telesocial"
|
15
|
+
|
16
|
+
s.add_development_dependency "fakeweb"
|
17
|
+
s.add_development_dependency "rake"
|
18
|
+
s.add_development_dependency "redgreen"
|
19
|
+
s.add_development_dependency "rocco"
|
20
|
+
s.add_development_dependency "rr"
|
21
|
+
|
22
|
+
s.add_dependency "httparty"
|
23
|
+
s.add_dependency "hashie"
|
24
|
+
s.add_dependency "multipart-post"
|
25
|
+
s.add_dependency "mime-types"
|
26
|
+
|
27
|
+
s.files = `git ls-files`.split("\n")
|
28
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
29
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
30
|
+
s.require_paths = ["lib"]
|
31
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/test_helper')
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/telesocial')
|
3
|
+
|
4
|
+
class TelesocialClientTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@client = Telesocial::Client.new("f180804f-5eda-4e6b-8f4e-ecea52362396")
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_check_existing_network_id
|
11
|
+
resp = @client.get_registration_status("necrodome")
|
12
|
+
assert 200 == resp.status
|
13
|
+
assert resp.registered?
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_check_non_existing_network_id
|
17
|
+
assert_raise(Telesocial::NotFound) { @client.get_registration_status("erica_and_some_other_chars")}
|
18
|
+
end
|
19
|
+
|
20
|
+
# This test needs to improved due to the fact that
|
21
|
+
# registration requires phone call.
|
22
|
+
# def test_succesful_registration
|
23
|
+
# resp = @client.register("xxx", 1234567)
|
24
|
+
# assert 201, resp.status
|
25
|
+
# end
|
26
|
+
|
27
|
+
def test_create_media
|
28
|
+
resp = @client.create_media()
|
29
|
+
assert 201 == resp.status
|
30
|
+
assert resp.uri?
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_request_upload_grant
|
34
|
+
resp = @client.request_upload_grant("123c5e5b40c54eb198d69d64e37ed182")
|
35
|
+
assert 201 == resp.status
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/test_helper')
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/telesocial')
|
3
|
+
|
4
|
+
class TelesocialClientTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_check_existing_network_id
|
7
|
+
resp = @client.get_registration_status("eric")
|
8
|
+
assert 200 == resp.status
|
9
|
+
assert resp.registered?
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_check_non_existing_network_id
|
13
|
+
assert_raise(Telesocial::NotFound) { @client.get_registration_status("erica")}
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_succesful_registration
|
17
|
+
resp = @client.register("xxx", 1234567)
|
18
|
+
assert 201 == resp.status
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_create_media
|
22
|
+
resp = @client.create_media()
|
23
|
+
assert 201 == resp.status
|
24
|
+
assert resp.uri?
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_request_upload_grant
|
28
|
+
resp = @client.request_upload_grant("123c5e5b40c54eb198d69d64e37ed182")
|
29
|
+
assert 201 == resp.status
|
30
|
+
assert resp.grantId == 5062406589092978092
|
31
|
+
assert resp.uri == "/api/rest/media/123c5e5b40c54eb198d69d64e37ed182/5062406589092978092"
|
32
|
+
end
|
33
|
+
|
34
|
+
def setup
|
35
|
+
@client = Telesocial::Client.new("key")
|
36
|
+
|
37
|
+
FakeWeb.allow_net_connect = false
|
38
|
+
FakeWeb.register_uri(
|
39
|
+
:post, "https://api4.bitmouth.com/api/rest/registrant/eric",
|
40
|
+
:content_type => "application/json; charset=utf-8",
|
41
|
+
:body => <<-JSON
|
42
|
+
{"RegistrantResponse":{"message":"","status":200}}
|
43
|
+
JSON
|
44
|
+
)
|
45
|
+
|
46
|
+
FakeWeb.register_uri(
|
47
|
+
:post, "https://api4.bitmouth.com/api/rest/registrant/erica",
|
48
|
+
:content_type => "application/json; charset=utf-8",
|
49
|
+
:body => <<-JSON
|
50
|
+
{"RegistrantResponse":{"message":"","status":404}}
|
51
|
+
JSON
|
52
|
+
)
|
53
|
+
|
54
|
+
FakeWeb.register_uri(
|
55
|
+
:post, "https://api4.bitmouth.com/api/rest/registrant/",
|
56
|
+
:data => {:name => "sdsd"},
|
57
|
+
:content_type => "application/json; charset=utf-8",
|
58
|
+
:body => <<-JSON
|
59
|
+
{"RegistrationResponse":{"message":"","status":201,"uri":"\/api\/rest\/registrant\/1000022816599"}}
|
60
|
+
JSON
|
61
|
+
)
|
62
|
+
|
63
|
+
FakeWeb.register_uri(
|
64
|
+
:post, "https://api4.bitmouth.com/api/rest/media/",
|
65
|
+
:content_type => "application/json; charset=utf-8",
|
66
|
+
:body => <<-JSON
|
67
|
+
{"MediaResponse":{"message":"","status":201,"downloadUrl":"","fileSize":0,"mediaId":"6e6a151be31b467f87225b18b0f36f00","uri":"\/api\/rest\/media\/6e6a151be31b467f87225b18b0f36f00"}}
|
68
|
+
JSON
|
69
|
+
)
|
70
|
+
|
71
|
+
FakeWeb.register_uri(
|
72
|
+
:post, "https://api4.bitmouth.com/api/rest/media/123c5e5b40c54eb198d69d64e37ed182",
|
73
|
+
:content_type => "application/json; charset=utf-8",
|
74
|
+
:body => <<-JSON
|
75
|
+
{"UploadResponse":{"message":"","status":201,"grantId":5062406589092978092,"uri":"\/api\/rest\/media\/123c5e5b40c54eb198d69d64e37ed182\/5062406589092978092"}}
|
76
|
+
JSON
|
77
|
+
)
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: telesocial
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Selem Delul
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-09-06 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fakeweb
|
16
|
+
requirement: &2151808920 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2151808920
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &2151807760 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2151807760
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: redgreen
|
38
|
+
requirement: &2151806000 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2151806000
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rocco
|
49
|
+
requirement: &2151804620 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2151804620
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rr
|
60
|
+
requirement: &2151801600 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2151801600
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: httparty
|
71
|
+
requirement: &2151797000 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2151797000
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: hashie
|
82
|
+
requirement: &2151843080 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *2151843080
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: multipart-post
|
93
|
+
requirement: &2151846180 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *2151846180
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: mime-types
|
104
|
+
requirement: &2151853180 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *2151853180
|
113
|
+
description: Ruby wrapper for Telesocial API
|
114
|
+
email:
|
115
|
+
- selem@selem.im
|
116
|
+
executables: []
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- Gemfile
|
121
|
+
- README.markdown
|
122
|
+
- Rakefile
|
123
|
+
- lib/telesocial.rb
|
124
|
+
- lib/telesocial/client.rb
|
125
|
+
- lib/telesocial/errors.rb
|
126
|
+
- lib/telesocial/version.rb
|
127
|
+
- telesocial.gemspec
|
128
|
+
- test/telesocial_client_functional_test.rb
|
129
|
+
- test/telesocial_client_test.rb
|
130
|
+
- test/test_helper.rb
|
131
|
+
homepage: ''
|
132
|
+
licenses: []
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options: []
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
segments:
|
144
|
+
- 0
|
145
|
+
hash: 1926186920278007827
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ! '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
segments:
|
153
|
+
- 0
|
154
|
+
hash: 1926186920278007827
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project: telesocial
|
157
|
+
rubygems_version: 1.8.7
|
158
|
+
signing_key:
|
159
|
+
specification_version: 3
|
160
|
+
summary: Ruby wrapper for Telesocial API
|
161
|
+
test_files:
|
162
|
+
- test/telesocial_client_functional_test.rb
|
163
|
+
- test/telesocial_client_test.rb
|
164
|
+
- test/test_helper.rb
|