tropo-provisioning 0.0.24 → 0.0.25
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/Gemfile.lock +4 -4
- data/changelog.md +4 -0
- data/lib/tropo-provisioning/tropo_client.rb +9 -2
- data/lib/tropo-provisioning/tropo_provisioning.rb +6 -4
- data/lib/tropo-provisioning/version.rb +1 -1
- data/spec/tropo-provisioning_spec.rb +259 -247
- metadata +5 -4
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
tropo-provisioning (0.0.
|
|
4
|
+
tropo-provisioning (0.0.25)
|
|
5
5
|
activesupport
|
|
6
6
|
hashie (>= 0.2.1)
|
|
7
7
|
i18n
|
|
@@ -9,15 +9,15 @@ PATH
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: http://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
activesupport (3.2.
|
|
12
|
+
activesupport (3.2.9)
|
|
13
13
|
i18n (~> 0.6)
|
|
14
14
|
multi_json (~> 1.0)
|
|
15
15
|
diff-lcs (1.1.3)
|
|
16
16
|
fakeweb (1.3.0)
|
|
17
17
|
hashie (1.2.0)
|
|
18
|
-
i18n (0.6.
|
|
18
|
+
i18n (0.6.1)
|
|
19
19
|
json (1.7.3)
|
|
20
|
-
multi_json (1.
|
|
20
|
+
multi_json (1.5.0)
|
|
21
21
|
rake (0.9.2.2)
|
|
22
22
|
rdoc (3.12)
|
|
23
23
|
json (~> 1.4)
|
data/changelog.md
ADDED
|
@@ -17,6 +17,8 @@ class TropoClient
|
|
|
17
17
|
attr_reader :username
|
|
18
18
|
# password associated to :username
|
|
19
19
|
attr_reader :password
|
|
20
|
+
# whether to require a valid certificate if using SSL
|
|
21
|
+
attr_reader :verify_certificate
|
|
20
22
|
|
|
21
23
|
##
|
|
22
24
|
# Creates a new TropoClient instance
|
|
@@ -27,10 +29,11 @@ class TropoClient
|
|
|
27
29
|
# * [optional, String] *base_uri* Tropo provisioning API endpoint
|
|
28
30
|
# * [optional, String] *headers* required HTTP headers
|
|
29
31
|
# * [optional, Hash] * proxy => {"host" : <host>, "port" : <port>}
|
|
32
|
+
# * [optional, Boolean] :verify_certificate whether to require a valid certificate if using SSL, defaults to true
|
|
30
33
|
#
|
|
31
34
|
# ==== Return
|
|
32
35
|
# * new TropoClient instance
|
|
33
|
-
def initialize(username, password, base_uri = "https://api.tropo.com/v1/", headers = nil, proxy = nil)
|
|
36
|
+
def initialize(username, password, base_uri = "https://api.tropo.com/v1/", headers = nil, proxy = nil, verify_certificate = true)
|
|
34
37
|
@base_uri = base_uri
|
|
35
38
|
if RUBY_VERSION =~ /1.8/
|
|
36
39
|
@base_uri << "/" if !@base_uri[-1].eql?(47)
|
|
@@ -42,6 +45,7 @@ class TropoClient
|
|
|
42
45
|
@password = password
|
|
43
46
|
@headers = headers.nil? ? {} : headers
|
|
44
47
|
@proxy = proxy
|
|
48
|
+
@verify_certificate = verify_certificate
|
|
45
49
|
end
|
|
46
50
|
|
|
47
51
|
##
|
|
@@ -165,7 +169,10 @@ class TropoClient
|
|
|
165
169
|
end
|
|
166
170
|
|
|
167
171
|
http = base.new(uri.host, uri.port)
|
|
168
|
-
|
|
172
|
+
if uri.scheme == 'https'
|
|
173
|
+
http.use_ssl = true
|
|
174
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @verify_certificate
|
|
175
|
+
end
|
|
169
176
|
http
|
|
170
177
|
)
|
|
171
178
|
end
|
|
@@ -17,7 +17,7 @@ class TropoProvisioning
|
|
|
17
17
|
# Array of supported partitions in Tropo
|
|
18
18
|
VALID_PARTITIONS = %w(staging production)
|
|
19
19
|
|
|
20
|
-
attr_reader :user_data, :base_uri
|
|
20
|
+
attr_reader :user_data, :base_uri, :verify_certificate
|
|
21
21
|
|
|
22
22
|
##
|
|
23
23
|
# Creates a new TropoProvisioning object
|
|
@@ -27,14 +27,16 @@ class TropoProvisioning
|
|
|
27
27
|
# * [required, String] password for your Tropo user
|
|
28
28
|
# * [optional, Hash] params
|
|
29
29
|
# * [optional, String] :base_uri to use for accessing the provisioning API if you would like a custom one
|
|
30
|
+
# * [optional, Boolean] :verify_certificate whether to require a valid certificate if using SSL, defaults to true
|
|
30
31
|
#
|
|
31
32
|
# ==== Return
|
|
32
33
|
#
|
|
33
34
|
# TropoProvisioning object
|
|
34
35
|
def initialize(username, password, params={})
|
|
35
|
-
@base_uri
|
|
36
|
-
proxy
|
|
37
|
-
@
|
|
36
|
+
@base_uri = (params[:base_uri] || "https://api.tropo.com/v1/").sub(/(\/)+$/,'/')
|
|
37
|
+
proxy = params[:proxy] || nil
|
|
38
|
+
@verify_certificate = params[:verify_certificate] || true
|
|
39
|
+
@tropo_client = TropoClient.new(username, password, @base_uri, { 'Content-Type' => 'application/json' }, proxy, @verify_certificate)
|
|
38
40
|
user(username)
|
|
39
41
|
end
|
|
40
42
|
|
|
@@ -6,26 +6,26 @@ FakeWeb.allow_net_connect = false
|
|
|
6
6
|
describe "TropoProvisioning" do
|
|
7
7
|
let(:applications) do
|
|
8
8
|
[ { "region" => "I-US",
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
"city" => "iNum US",
|
|
10
|
+
"number" => "883510001812716",
|
|
11
|
+
"href" => "http://api.tropo.com/v1/applications/108000/addresses/number/883510001812716",
|
|
12
|
+
"prefix" => "008",
|
|
13
|
+
"type" => "number" },
|
|
14
|
+
{ "number" => "9991436301",
|
|
15
|
+
"href" => "http://api.tropo.com/v1/applications/108000/addresses/pin/9991436300",
|
|
16
|
+
"type" => "pin" },
|
|
17
|
+
{ "href" => "http://api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
|
|
18
|
+
"nickname" => "",
|
|
19
|
+
"username" => "xyz123",
|
|
20
|
+
"type" => "jabber" },
|
|
21
|
+
{ "href" => "http://api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
|
|
22
|
+
"nickname" => "",
|
|
23
|
+
"username" => "9991436300",
|
|
24
|
+
"type" => "pin" },
|
|
25
|
+
{ "href" => "http://api.tropo.com/v1/applications/108000/addresses/token/a1b2c3d4",
|
|
26
|
+
"nickname" => "",
|
|
27
|
+
"username" => "a1b2c3d4",
|
|
28
|
+
"type" => "token" } ]
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
before(:all) do
|
|
@@ -167,10 +167,10 @@ describe "TropoProvisioning" do
|
|
|
167
167
|
|
|
168
168
|
# Alternate Base URI
|
|
169
169
|
FakeWeb.register_uri(:get,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
"http://foo:bar@testserver.com/rest/v1/users/foo",
|
|
171
|
+
:body => '{}',
|
|
172
|
+
:content_type => "application/json",
|
|
173
|
+
:status => ["200", "OK"])
|
|
174
174
|
|
|
175
175
|
|
|
176
176
|
# A specific application
|
|
@@ -245,11 +245,11 @@ describe "TropoProvisioning" do
|
|
|
245
245
|
:body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/108001/addresses/jabber/xyz123@bot.im" }),
|
|
246
246
|
:content_type => "application/json")
|
|
247
247
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
248
|
+
# Create a address that is a Token
|
|
249
|
+
FakeWeb.register_uri(:post,
|
|
250
|
+
"https://foo:bar@api.tropo.com/v1/applications/108002/addresses",
|
|
251
|
+
:body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/108002/addresses/token/12345679f90bac47a05b178c37d3c68aaf38d5bdbc5aba0c7abb12345d8a9fd13f1234c1234567dbe2c6f63b" }),
|
|
252
|
+
:content_type => "application/json")
|
|
253
253
|
|
|
254
254
|
# Delete an application
|
|
255
255
|
FakeWeb.register_uri(:delete,
|
|
@@ -279,138 +279,138 @@ describe "TropoProvisioning" do
|
|
|
279
279
|
:content_type => "application/json",
|
|
280
280
|
:status => ["200", "OK"])
|
|
281
281
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
282
|
+
# Create a new user
|
|
283
|
+
FakeWeb.register_uri(:post,
|
|
284
|
+
"https://foo:bar@api.tropo.com/v1/users",
|
|
285
|
+
:body => @new_user_json,
|
|
286
|
+
:content_type => "application/json",
|
|
287
|
+
:status => ["200", "OK"])
|
|
288
|
+
|
|
289
|
+
# Get a specific user by user_id
|
|
290
|
+
FakeWeb.register_uri(:get,
|
|
291
|
+
"https://foo:bar@api.tropo.com/v1/users/12345",
|
|
292
|
+
:body => ActiveSupport::JSON.encode(@existing_user),
|
|
293
|
+
:content_type => "application/json",
|
|
294
|
+
:status => ["200", "OK"])
|
|
295
|
+
|
|
296
|
+
# Get a specific user by user_id
|
|
297
|
+
FakeWeb.register_uri(:get,
|
|
298
|
+
"https://foo:bar@api.tropo.com/v1/users/98765",
|
|
299
|
+
:body => nil,
|
|
300
|
+
:content_type => "application/json",
|
|
301
|
+
:status => ["404", "Got an error here!"])
|
|
302
|
+
|
|
303
|
+
# Get a specific user by username
|
|
304
|
+
FakeWeb.register_uri(:get,
|
|
305
|
+
"https://foo:bar@api.tropo.com/v1/users/foo",
|
|
306
|
+
:body => ActiveSupport::JSON.encode(@existing_user),
|
|
307
|
+
:content_type => "application/json",
|
|
308
|
+
:status => ["200", "OK"])
|
|
309
|
+
|
|
310
|
+
# Get a specific user by username with HTTPS/SSL
|
|
311
|
+
FakeWeb.register_uri(:get,
|
|
312
|
+
"https://foo:bar@api.tropo.com/v1/users/foo",
|
|
313
|
+
:body => ActiveSupport::JSON.encode(@existing_user),
|
|
314
|
+
:content_type => "application/json",
|
|
315
|
+
:status => ["200", "OK"])
|
|
316
|
+
|
|
317
|
+
# Invalid credentials
|
|
318
|
+
FakeWeb.register_uri(:get,
|
|
319
|
+
"https://bad:password@api.tropo.com/v1/users/bad",
|
|
320
|
+
:content_type => "application/json",
|
|
321
|
+
:status => ["401", "Unauthorized"])
|
|
322
|
+
|
|
323
|
+
# Confirm an account account
|
|
324
|
+
FakeWeb.register_uri(:post,
|
|
325
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/confirmations",
|
|
326
|
+
:body => ActiveSupport::JSON.encode({"message" => "successfully confirmed user 12345" }),
|
|
327
|
+
:content_type => "application/json",
|
|
328
|
+
:status => ["200", "OK"])
|
|
329
|
+
|
|
330
|
+
# Return the payment method configured for a user
|
|
331
|
+
FakeWeb.register_uri(:get,
|
|
332
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/payment/method",
|
|
333
|
+
:body => ActiveSupport::JSON.encode(@payment_method),
|
|
334
|
+
:content_type => "application/json",
|
|
335
|
+
:status => ["200", "OK"])
|
|
336
|
+
|
|
337
|
+
# Return payment types
|
|
338
|
+
FakeWeb.register_uri(:get,
|
|
339
|
+
"https://foo:bar@api.tropo.com/v1/types/payment",
|
|
340
|
+
:body => ActiveSupport::JSON.encode(@payment_methods),
|
|
341
|
+
:content_type => "application/json",
|
|
342
|
+
:status => ["200", "OK"])
|
|
343
|
+
|
|
344
|
+
# Return features
|
|
345
|
+
FakeWeb.register_uri(:get,
|
|
346
|
+
"https://foo:bar@api.tropo.com/v1/features",
|
|
347
|
+
:body => ActiveSupport::JSON.encode(@features),
|
|
348
|
+
:content_type => "application/json",
|
|
349
|
+
:status => ["200", "OK"])
|
|
350
|
+
|
|
351
|
+
# Return features for a user
|
|
352
|
+
FakeWeb.register_uri(:get,
|
|
353
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/features",
|
|
354
|
+
:body => ActiveSupport::JSON.encode(@user_features),
|
|
355
|
+
:content_type => "application/json",
|
|
356
|
+
:status => ["200", "OK"])
|
|
357
|
+
|
|
358
|
+
# Add a feature to a user
|
|
359
|
+
FakeWeb.register_uri(:post,
|
|
360
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/features",
|
|
361
|
+
:body => ActiveSupport::JSON.encode(@feature),
|
|
362
|
+
:content_type => "application/json",
|
|
363
|
+
:status => ["200", "OK"])
|
|
364
|
+
|
|
365
|
+
# Add a feature to a user
|
|
366
|
+
FakeWeb.register_uri(:delete,
|
|
367
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/features/8",
|
|
368
|
+
:body => ActiveSupport::JSON.encode(@feature_delete_message),
|
|
369
|
+
:content_type => "application/json",
|
|
370
|
+
:status => ["200", "OK"])
|
|
371
|
+
|
|
372
|
+
# Add payment info to a user
|
|
373
|
+
FakeWeb.register_uri(:put,
|
|
374
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/payment/method",
|
|
375
|
+
:body => ActiveSupport::JSON.encode(@payment_info_message),
|
|
376
|
+
:content_type => "application/json",
|
|
377
|
+
:status => ["200", "OK"])
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
# List an account, with bad credentials
|
|
381
|
+
FakeWeb.register_uri(:get,
|
|
382
|
+
"https://evolution.voxeo.com/api/account/accesstoken/get.jsp?username=foobar7474&password=fooeyfooey",
|
|
383
|
+
:body => ActiveSupport::JSON.encode(@bad_account_creds),
|
|
384
|
+
:content_type => "application/json",
|
|
385
|
+
:status => ["403", "Invalid Login."])
|
|
386
|
+
|
|
387
|
+
# Get our search terms
|
|
388
|
+
FakeWeb.register_uri(:get,
|
|
389
|
+
"https://foo:bar@api.tropo.com/v1/users/?username=foobar",
|
|
390
|
+
:body => ActiveSupport::JSON.encode(@search_accounts),
|
|
391
|
+
:content_type => "application/json",
|
|
392
|
+
:status => ["200", "OK"])
|
|
393
|
+
|
|
394
|
+
# Payment resource
|
|
395
|
+
FakeWeb.register_uri(:post,
|
|
396
|
+
"https://foo:bar@api.tropo.com/v1/users/1234/payments",
|
|
397
|
+
:body => ActiveSupport::JSON.encode({ :message => "successfully posted payment for the amount 1.000000" }),
|
|
398
|
+
:content_type => "application/json",
|
|
399
|
+
:status => ["200", "OK"])
|
|
400
|
+
|
|
401
|
+
# Modify a user
|
|
402
|
+
FakeWeb.register_uri(:put,
|
|
403
|
+
"https://foo:bar@api.tropo.com/v1/users/12345",
|
|
404
|
+
:body => ActiveSupport::JSON.encode({ :href => "http://api-smsified-eng.voxeo.net/v1/users/12345" }),
|
|
405
|
+
:content_type => "application/json",
|
|
406
|
+
:status => ["200", "OK"])
|
|
407
|
+
|
|
408
|
+
# List available partitions
|
|
409
|
+
FakeWeb.register_uri(:get,
|
|
410
|
+
"https://foo:bar@api.tropo.com/v1/partitions",
|
|
411
|
+
:body => ActiveSupport::JSON.encode(@partitions),
|
|
412
|
+
:content_type => "application/json",
|
|
413
|
+
:status => ["200", "OK"])
|
|
414
414
|
|
|
415
415
|
# List available platforms
|
|
416
416
|
FakeWeb.register_uri(:get,
|
|
@@ -426,18 +426,18 @@ describe "TropoProvisioning" do
|
|
|
426
426
|
:content_type => "application/json",
|
|
427
427
|
:status => ["200", "OK"])
|
|
428
428
|
|
|
429
|
-
# Whitelist
|
|
430
|
-
FakeWeb.register_uri(:get,
|
|
431
|
-
"https://foo:bar@api.tropo.com/v1/users/12345/partitions/production/platforms/sms/whitelist",
|
|
432
|
-
:body => ActiveSupport::JSON.encode(@whitelist),
|
|
433
|
-
:content_type => "application/json",
|
|
434
|
-
:status => ["200", "OK"])
|
|
435
429
|
# Whitelist
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
430
|
+
FakeWeb.register_uri(:get,
|
|
431
|
+
"https://foo:bar@api.tropo.com/v1/users/12345/partitions/production/platforms/sms/whitelist",
|
|
432
|
+
:body => ActiveSupport::JSON.encode(@whitelist),
|
|
433
|
+
:content_type => "application/json",
|
|
434
|
+
:status => ["200", "OK"])
|
|
435
|
+
# Whitelist
|
|
436
|
+
FakeWeb.register_uri(:get,
|
|
437
|
+
"https://foo:bar@api.tropo.com/v1/users/partitions/production/platforms/sms/whitelist",
|
|
438
|
+
:body => ActiveSupport::JSON.encode(@whitelist),
|
|
439
|
+
:content_type => "application/json",
|
|
440
|
+
:status => ["200", "OK"])
|
|
441
441
|
|
|
442
442
|
# Whitelist create
|
|
443
443
|
FakeWeb.register_uri(:post,
|
|
@@ -632,6 +632,18 @@ describe "TropoProvisioning" do
|
|
|
632
632
|
tropo_provisioning.instance_of?(TropoProvisioning).should == true
|
|
633
633
|
end
|
|
634
634
|
|
|
635
|
+
it "should validate SSL by default" do
|
|
636
|
+
tropo_provisioning.verify_certificate.should == true
|
|
637
|
+
end
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
it "should not validate SSL when told to" do
|
|
641
|
+
tp = TropoProvisioning.new('foo', 'bar', {:verify_certificate => false })
|
|
642
|
+
tp.verify_certificate.should == true
|
|
643
|
+
end
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
635
647
|
describe 'authentication' do
|
|
636
648
|
it "should get an unathorized back if there is an invalid username or password" do
|
|
637
649
|
begin
|
|
@@ -696,18 +708,18 @@ describe "TropoProvisioning" do
|
|
|
696
708
|
it "should raise ArgumentErrors if appropriate values are not passed" do
|
|
697
709
|
begin
|
|
698
710
|
tropo_provisioning.create_application({ :name => 'foobar',
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
711
|
+
:partition => 'foobar',
|
|
712
|
+
:platform => 'foobar',
|
|
713
|
+
:messagingUrl => 'http://foobar' })
|
|
702
714
|
rescue => e
|
|
703
715
|
e.to_s.should == ":platform must be 'scripting' or 'webapi'"
|
|
704
716
|
end
|
|
705
717
|
|
|
706
718
|
begin
|
|
707
719
|
tropo_provisioning.create_application({ :name => 'foobar',
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
720
|
+
:partition => 'foobar',
|
|
721
|
+
:platform => 'scripting',
|
|
722
|
+
:messagingUrl => 'http://foobar' })
|
|
711
723
|
rescue => e
|
|
712
724
|
e.to_s.should == ":partition must be 'staging' or 'production'"
|
|
713
725
|
end
|
|
@@ -716,17 +728,17 @@ describe "TropoProvisioning" do
|
|
|
716
728
|
it "should receive an href back when we create a new application receiving an href back" do
|
|
717
729
|
# With camelCase
|
|
718
730
|
result = tropo_provisioning.create_application({ :name => 'foobar',
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
731
|
+
:partition => 'production',
|
|
732
|
+
:platform => 'scripting',
|
|
733
|
+
:messagingUrl => 'http://foobar' })
|
|
722
734
|
result.href.should == "http://api.tropo.com/v1/applications/108016"
|
|
723
735
|
result.application_id.should == '108016'
|
|
724
736
|
|
|
725
737
|
# With underscores
|
|
726
738
|
result = tropo_provisioning.create_application({ :name => 'foobar',
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
739
|
+
:partition => 'production',
|
|
740
|
+
:platform => 'scripting',
|
|
741
|
+
:messaging_url => 'http://foobar' })
|
|
730
742
|
result.href.should == "http://api.tropo.com/v1/applications/108016"
|
|
731
743
|
result.application_id.should == '108016'
|
|
732
744
|
end
|
|
@@ -734,16 +746,16 @@ describe "TropoProvisioning" do
|
|
|
734
746
|
it "should receive an href back when we update an application receiving an href back" do
|
|
735
747
|
# With camelCase
|
|
736
748
|
result = tropo_provisioning.update_application('108000', { :name => 'foobar',
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
749
|
+
:partition => 'production',
|
|
750
|
+
:platform => 'scripting',
|
|
751
|
+
:messagingUrl => 'http://foobar' })
|
|
740
752
|
result.href.should == "http://api.tropo.com/v1/applications/108016"
|
|
741
753
|
|
|
742
754
|
# With underscore
|
|
743
755
|
result = tropo_provisioning.update_application('108000', { :name => 'foobar',
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
756
|
+
:partition => 'production',
|
|
757
|
+
:platform => 'scripting',
|
|
758
|
+
:messaging_url => 'http://foobar' })
|
|
747
759
|
result.href.should == "http://api.tropo.com/v1/applications/108016"
|
|
748
760
|
end
|
|
749
761
|
|
|
@@ -988,56 +1000,56 @@ describe "TropoProvisioning" do
|
|
|
988
1000
|
describe 'payments' do
|
|
989
1001
|
it "should add a payment method to a user" do
|
|
990
1002
|
result = tropo_provisioning.add_payment_info('12345', { :account_number => '1234567890',
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1003
|
+
:payment_type => 'https://api-smsified-eng.voxeo.net/v1/types/payment/1',
|
|
1004
|
+
:address => '123 Smith Avenue',
|
|
1005
|
+
:city => 'San Carlos',
|
|
1006
|
+
:state => 'CA',
|
|
1007
|
+
:postal_code => '94070',
|
|
1008
|
+
:country => 'USA',
|
|
1009
|
+
:name_on_account => 'Tropo User',
|
|
1010
|
+
:expiration_date => '2011-12-10',
|
|
1011
|
+
:security_code => '123',
|
|
1012
|
+
:recharge_amount => 10.50,
|
|
1013
|
+
:recharge_threshold => 5.00,
|
|
1014
|
+
:email => 'j@doe.com',
|
|
1015
|
+
:phone_number => '4155551212' })
|
|
1004
1016
|
result.should == @payment_info_message
|
|
1005
1017
|
end
|
|
1006
1018
|
|
|
1007
1019
|
it "should add a payment method to a user in camelCase" do
|
|
1008
1020
|
result = tropo_provisioning.add_payment_info('12345', { :accountNumber => '1234567890',
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1021
|
+
:paymentType => 'https://api-smsified-eng.voxeo.net/v1/types/payment/1',
|
|
1022
|
+
:address => '123 Smith Avenue',
|
|
1023
|
+
:city => 'San Carlos',
|
|
1024
|
+
:state => 'CA',
|
|
1025
|
+
:postalCode => '94070',
|
|
1026
|
+
:country => 'USA',
|
|
1027
|
+
:nameOnAccount => 'Tropo User',
|
|
1028
|
+
:expirationDate => '2011-12-10',
|
|
1029
|
+
:securityCode => '123',
|
|
1030
|
+
:rechargeAmount => 10.50,
|
|
1031
|
+
:rechargeThreshold => 5.00,
|
|
1032
|
+
:email => 'j@doe.com',
|
|
1033
|
+
:phoneNumber => '4155551212' })
|
|
1022
1034
|
|
|
1023
1035
|
result.should == @payment_info_message
|
|
1024
1036
|
end
|
|
1025
1037
|
|
|
1026
1038
|
it 'should add a payment method to a user keys as strings' do
|
|
1027
1039
|
result = tropo_provisioning.add_payment_info('12345', { 'account_number' => '1234567890',
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1040
|
+
'payment_type' => 'https://api-smsified-eng.voxeo.net/v1/types/payment/1',
|
|
1041
|
+
'address' => '123 Smith Avenue',
|
|
1042
|
+
'city' => 'San Carlos',
|
|
1043
|
+
'state' => 'CA',
|
|
1044
|
+
'postal_code' => '94070',
|
|
1045
|
+
'country' => 'USA',
|
|
1046
|
+
'name_on_account' => 'Tropo User',
|
|
1047
|
+
'expiration_date' => '2011-12-10',
|
|
1048
|
+
'security_code' => '123',
|
|
1049
|
+
'recharge_amount' => 10.50,
|
|
1050
|
+
'recharge_threshold' => 5.00,
|
|
1051
|
+
'email' => 'j@doe.com',
|
|
1052
|
+
'phone_number' => '4155551212' })
|
|
1041
1053
|
|
|
1042
1054
|
|
|
1043
1055
|
result.should == @payment_info_message
|
|
@@ -1045,19 +1057,19 @@ describe "TropoProvisioning" do
|
|
|
1045
1057
|
|
|
1046
1058
|
it 'should add a payment method to a user in camelCase and keys as strings' do
|
|
1047
1059
|
result = tropo_provisioning.add_payment_info('12345', { 'accountNumber' => '1234567890',
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1060
|
+
'paymentType' => 'https://api-smsified-eng.voxeo.net/v1/types/payment/1',
|
|
1061
|
+
'address' => '123 Smith Avenue',
|
|
1062
|
+
'city' => 'San Carlos',
|
|
1063
|
+
'state' => 'CA',
|
|
1064
|
+
'postalCode' => '94070',
|
|
1065
|
+
'country' => 'USA',
|
|
1066
|
+
'nameOnAccount' => 'Tropo User',
|
|
1067
|
+
'expirationDate' => '2011-12-10',
|
|
1068
|
+
'securityCode' => '123',
|
|
1069
|
+
'rechargeAmount' => 10.50,
|
|
1070
|
+
'rechargeThreshold' => 5.00,
|
|
1071
|
+
'email' => 'j@doe.com',
|
|
1072
|
+
'phone_number' => '4155551212' })
|
|
1061
1073
|
|
|
1062
1074
|
result.should == @payment_info_message
|
|
1063
1075
|
end
|
|
@@ -1160,15 +1172,15 @@ describe "TropoProvisioning" do
|
|
|
1160
1172
|
|
|
1161
1173
|
it 'should create an invitation' do
|
|
1162
1174
|
tropo_provisioning.create_invitation({ :code => 'ABC457',
|
|
1163
|
-
|
|
1164
|
-
|
|
1175
|
+
:count => 100,
|
|
1176
|
+
:credit => 10 }).should == @invitation_created
|
|
1165
1177
|
end
|
|
1166
1178
|
|
|
1167
1179
|
it 'should create an invitationfor a specific user' do
|
|
1168
1180
|
tropo_provisioning.create_invitation('15909',
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1181
|
+
{ :code => 'ABC457',
|
|
1182
|
+
:count => 100,
|
|
1183
|
+
:credit => 10 }).should == @invitation_created
|
|
1172
1184
|
end
|
|
1173
1185
|
|
|
1174
1186
|
it 'should update an invitation' do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tropo-provisioning
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.25
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -155,6 +155,7 @@ files:
|
|
|
155
155
|
- LICENSE
|
|
156
156
|
- README.rdoc
|
|
157
157
|
- Rakefile
|
|
158
|
+
- changelog.md
|
|
158
159
|
- examples/app_details.yml
|
|
159
160
|
- examples/authenticate_account.rb
|
|
160
161
|
- examples/config.yml
|
|
@@ -203,7 +204,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
203
204
|
version: '0'
|
|
204
205
|
segments:
|
|
205
206
|
- 0
|
|
206
|
-
hash:
|
|
207
|
+
hash: 4140171583782304435
|
|
207
208
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
209
|
none: false
|
|
209
210
|
requirements:
|
|
@@ -212,10 +213,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
212
213
|
version: '0'
|
|
213
214
|
segments:
|
|
214
215
|
- 0
|
|
215
|
-
hash:
|
|
216
|
+
hash: 4140171583782304435
|
|
216
217
|
requirements: []
|
|
217
218
|
rubyforge_project: tropo-provisioning
|
|
218
|
-
rubygems_version: 1.8.
|
|
219
|
+
rubygems_version: 1.8.23
|
|
219
220
|
signing_key:
|
|
220
221
|
specification_version: 3
|
|
221
222
|
summary: Library for interacting with the Tropo Provisioning API
|