tropo-provisioning 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,21 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tropo-provisioning (0.0.21)
4
+ tropo-provisioning (0.0.22)
5
5
  activesupport
6
6
  hashie (>= 0.2.1)
7
7
  i18n
8
+ json
8
9
 
9
10
  GEM
10
11
  remote: http://rubygems.org/
11
12
  specs:
12
- activesupport (3.1.0)
13
+ activesupport (3.1.3)
13
14
  multi_json (~> 1.0)
14
15
  diff-lcs (1.1.2)
15
16
  fakeweb (1.3.0)
16
- hashie (1.1.0)
17
+ hashie (1.2.0)
17
18
  i18n (0.6.0)
18
- multi_json (1.0.3)
19
+ json (1.6.5)
20
+ json (1.6.5-java)
21
+ multi_json (1.0.4)
19
22
  rdoc (3.9.4)
20
23
  rspec (2.3.0)
21
24
  rspec-core (~> 2.3.0)
@@ -28,6 +31,7 @@ GEM
28
31
  yard (0.7.2)
29
32
 
30
33
  PLATFORMS
34
+ java
31
35
  ruby
32
36
 
33
37
  DEPENDENCIES
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2010 Voxeo, Corporation
3
+ Copyright (c) 2012 Voxeo, Corporation
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.rdoc CHANGED
@@ -18,7 +18,7 @@ The Tropo Provisioning gem provides a library for convenient access to the Tropo
18
18
 
19
19
  == Requirements
20
20
 
21
- * Unit tests passed on: Ruby MRI v1.8.6/1.8.7, Ruby 1.9.2, JRuby 1.5.0 and MacRuby 0.6
21
+ * Unit tests passed on: Ruby MRI v1.8.6/1.8.7, Ruby 1.9.2 and JRuby 1.6.3
22
22
 
23
23
  * RubyGems: Check tropo-provisioning.gemspec
24
24
 
data/Rakefile CHANGED
@@ -9,7 +9,6 @@ require 'tropo-provisioning/version'
9
9
 
10
10
 
11
11
  RSpec::Core::RakeTask.new(:test) do |spec|
12
- spec.skip_bundler = true
13
12
  spec.pattern = ['spec/*_spec.rb']
14
13
  spec.rspec_opts = '--color --format doc'
15
14
  end
@@ -27,14 +27,22 @@ class TropoClient
27
27
  # * [required, String] *password* valid password
28
28
  # * [optional, String] *base_uri* Tropo provisioning API endpoint
29
29
  # * [optional, String] *headers* required HTTP headers
30
+ # * [optional, Hash] * proxy => {"host" : <host>, "port" : <port>}
30
31
  #
31
32
  # ==== Return
32
33
  # * new TropoClient instance
33
- def initialize(username, password, base_uri = "http://api.tropo.com/v1", headers)
34
+ def initialize(username, password, base_uri = "http://api.tropo.com/v1/", headers = nil, proxy = nil)
34
35
  @base_uri = base_uri
36
+ if RUBY_VERSION =~ /1.8/
37
+ @base_uri << "/" if !@base_uri[-1].eql?(47)
38
+ elsif RUBY_VERSION =~ /1.9/
39
+ @base_uri << "/" if !@base_uri[-1].eql?("/")
40
+ end
41
+
35
42
  @username = username
36
43
  @password = password
37
44
  @headers = headers.nil? ? {} : headers
45
+ @proxy = proxy
38
46
  end
39
47
 
40
48
  ##
@@ -142,7 +150,22 @@ class TropoClient
142
150
  def http
143
151
  @http ||= (
144
152
  uri = URI.parse(base_uri)
145
- http = Net::HTTP.new(uri.host, uri.port)
153
+ if @proxy.nil?
154
+ base = Net::HTTP
155
+ else
156
+ [:host, :port].each{|item|
157
+ if @proxy.has_key(item)
158
+ proxy[item.to_s] = proxy[item]
159
+ end
160
+ }
161
+ if @proxy.has_key?("host") && @proxy.has_key?("port")
162
+ base = Net::HTTP::Proxy(@proxy["host"], @proxy["port"])
163
+ else
164
+ base = Net::HTTP
165
+ end
166
+ end
167
+
168
+ http = base.new(uri.host, uri.port)
146
169
  http.use_ssl = true if uri.scheme == 'https'
147
170
  http
148
171
  )
@@ -153,18 +176,13 @@ class TropoClient
153
176
  #
154
177
  # ==== Parameters
155
178
  # * [required, Symbol] http_request Net::HTTPRequest child
156
- # * [required, Hash] params used to create the request
157
- # * [String] :resource the resource to call on the base URL
158
- # * [Hash] :body the details to use when posting, putting or deleting an object, converts into the appropriate JSON
179
+ # * [required, Hash] body details parameters to use when posting or putting an object, converts into the appropriate JSON
159
180
  #
160
181
  # ==== Return
161
182
  # * [Hash] the result of the request
162
183
  # * [TropoError]
163
184
  # if it can not connect to the API server or if the response.code is not 200
164
- def request(http_request, params = {})
165
- params[:body] and params[:body] = camelize_params(params[:body])
166
-
167
- uri = params[:resource].nil? ? "" : params[:resource]
185
+ def request(http_request, body = {})
168
186
 
169
187
  unless http_request.is_a?(Net::HTTPRequest)
170
188
  raise TropoError.new("Invalid request type #{http_request}")
@@ -172,8 +190,10 @@ class TropoClient
172
190
 
173
191
  http_request.initialize_http_header(headers)
174
192
  http_request.basic_auth username, password
175
- http_request.body = ActiveSupport::JSON.encode params[:body] if params[:body]
176
-
193
+
194
+ # Include body if received
195
+ body.empty? or http_request.body = ActiveSupport::JSON.encode(camelize_params(body))
196
+
177
197
  begin
178
198
  response = http.request(http_request)
179
199
  rescue => e
@@ -32,8 +32,9 @@ class TropoProvisioning
32
32
  #
33
33
  # TropoProvisioning object
34
34
  def initialize(username, password, params={})
35
- base_uri = params[:base_uri] || "http://api.tropo.com/v1/"
36
- @tropo_client = TropoClient.new(username, password, base_uri, { 'Content-Type' => 'application/json' })
35
+ base_uri = params[:base_uri] || "https://api.tropo.com/v1/"
36
+ proxy = params[:proxy] || nil
37
+ @tropo_client = TropoClient.new(username, password, base_uri, { 'Content-Type' => 'application/json' }, proxy)
37
38
  user(username)
38
39
  end
39
40
 
@@ -161,7 +162,7 @@ class TropoProvisioning
161
162
  # ==== Parameters
162
163
  # * [required] search_term
163
164
  # * [String] a key/value of the search term you would like to use, such as 'username=foobar', or 'city=Orlando'
164
- # * [Hash] a Hash instance, such as {:username => "foobar"}, or {:city => "Orlando"}
165
+ # * [Hash] a Hash instance, such as {"username" => "foobar"}, or {"city" => "Orlando"}
165
166
  #
166
167
  # ==== Return
167
168
  # * [Array]
@@ -300,9 +301,9 @@ class TropoProvisioning
300
301
  # Add/modify payment info for a user
301
302
  #
302
303
  # ==== Parameters
303
- # * [required, String] user_id to add the payment details for
304
+ # * [user_id - required, String] to add the payment details for
304
305
  # * [require, Hash] params the params to add the payment info
305
- # * [required, String] :account_number the credit card number
306
+ # * [:account_number] [required, String] the credit card number
306
307
  # * [required, String] :payment_type the type, such as visa, mastercard, etc
307
308
  # * [required, String] :address
308
309
  # * [optional, String] :address2
@@ -411,7 +412,13 @@ class TropoProvisioning
411
412
  # * [String] :partition defines whether the application is in staging/development or production
412
413
  def application(application_id)
413
414
  app = @tropo_client.get("applications/#{application_id.to_s}")
414
- app.merge!({ :application_id => get_element(app.href) })
415
+ if app.instance_of? Array
416
+ href = app[0].href
417
+ app[0].merge!({ :application_id => get_element(href) })
418
+ else
419
+ href = app.href
420
+ app.merge!({ :application_id => get_element(href) })
421
+ end
415
422
  end
416
423
 
417
424
  ##
@@ -1,5 +1,5 @@
1
1
 
2
2
  class TropoProvisioning
3
3
  # Current gem version
4
- VERSION = "0.0.22"
4
+ VERSION = "0.0.23"
5
5
  end
@@ -1,2 +1,2 @@
1
-
1
+ require 'json' if RUBY_VERSION =~ /1.8/
2
2
  require 'tropo-provisioning/tropo_provisioning'
@@ -97,14 +97,14 @@ describe "TropoProvisioning" do
97
97
  it "should create an application" do
98
98
  # Get a specific user by username
99
99
  FakeWeb.register_uri(:get,
100
- "http://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/users/jsgoecke",
100
+ "https://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/users/jsgoecke",
101
101
  :body => ActiveSupport::JSON.encode(existing_user),
102
102
  :content_type => "application/json",
103
103
  :status => ["200", "OK"])
104
104
 
105
105
  # Create an application
106
106
  FakeWeb.register_uri(:post,
107
- %r|http://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/applications|,
107
+ %r|https://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/applications|,
108
108
  :body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/provisioning/applications/#{APPLICATION_ID}" }),
109
109
  :status => ["200", "OK"])
110
110
 
@@ -118,7 +118,7 @@ describe "TropoProvisioning" do
118
118
  it "should get a list of exchanges" do
119
119
  # Exchanges
120
120
  FakeWeb.register_uri(:get,
121
- "http://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/exchanges",
121
+ "https://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/exchanges",
122
122
  :body => exchanges,
123
123
  :status => ["200", "OK"],
124
124
  :content_type => "application/json")
@@ -130,21 +130,21 @@ describe "TropoProvisioning" do
130
130
  it "should add a phone, IM and token address to the application" do
131
131
  # Get a specific user by username
132
132
  FakeWeb.register_uri(:get,
133
- "http://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/users/jsgoecke",
133
+ "https://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/users/jsgoecke",
134
134
  :body => ActiveSupport::JSON.encode(existing_user),
135
135
  :content_type => "application/json",
136
136
  :status => ["200", "OK"])
137
137
 
138
138
  # Exchanges
139
139
  FakeWeb.register_uri(:get,
140
- "http://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/exchanges",
140
+ "https://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/exchanges",
141
141
  :body => exchanges,
142
142
  :status => ["200", "OK"],
143
143
  :content_type => "application/json")
144
144
 
145
145
  # Get a address that is a number
146
146
  FakeWeb.register_uri(:post,
147
- "http://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/applications/108016/addresses",
147
+ "https://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/applications/108016/addresses",
148
148
  :body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/108000/addresses/number/7202551912" }),
149
149
  :content_type => "application/json")
150
150
 
@@ -156,21 +156,21 @@ describe "TropoProvisioning" do
156
156
  it "should add an IM token address to the application" do
157
157
  # Get a specific user by username
158
158
  FakeWeb.register_uri(:get,
159
- "http://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/users/jsgoecke",
159
+ "https://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/users/jsgoecke",
160
160
  :body => ActiveSupport::JSON.encode(existing_user),
161
161
  :content_type => "application/json",
162
162
  :status => ["200", "OK"])
163
163
 
164
164
  # Exchanges
165
165
  FakeWeb.register_uri(:get,
166
- "http://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/exchanges",
166
+ "https://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/exchanges",
167
167
  :body => exchanges,
168
168
  :status => ["200", "OK"],
169
169
  :content_type => "application/json")
170
170
 
171
171
  # Get a address that is a number
172
172
  FakeWeb.register_uri(:post,
173
- "http://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/applications/#{APPLICATION_ID}/addresses",
173
+ "https://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/applications/#{APPLICATION_ID}/addresses",
174
174
  :body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/#{APPLICATION_ID}/addresses/jabber/appsdsdsdasd@bot.im" }),
175
175
  :content_type => "application/json")
176
176
 
@@ -182,21 +182,21 @@ describe "TropoProvisioning" do
182
182
  it "should add a token to the application" do
183
183
  # Get a specific user by username
184
184
  FakeWeb.register_uri(:get,
185
- "http://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/users/jsgoecke",
185
+ "https://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/users/jsgoecke",
186
186
  :body => ActiveSupport::JSON.encode(existing_user),
187
187
  :content_type => "application/json",
188
188
  :status => ["200", "OK"])
189
189
 
190
190
  # Exchanges
191
191
  FakeWeb.register_uri(:get,
192
- "http://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/exchanges",
192
+ "https://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/exchanges",
193
193
  :body => exchanges,
194
194
  :status => ["200", "OK"],
195
195
  :content_type => "application/json")
196
196
 
197
197
  # Get a address that is a number
198
198
  FakeWeb.register_uri(:post,
199
- "http://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/applications/#{APPLICATION_ID}/addresses",
199
+ "https://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/applications/#{APPLICATION_ID}/addresses",
200
200
  :body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/#{APPLICATION_ID}/addresses/token/"+("w"*88) }),
201
201
  :content_type => "application/json")
202
202
  result = tropo_provisioning.create_address(APPLICATION_ID, { :type => 'token', :channel => 'voice' } )
@@ -208,7 +208,7 @@ describe "TropoProvisioning" do
208
208
 
209
209
  # A specific application
210
210
  FakeWeb.register_uri(:get,
211
- "http://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/applications/#{APPLICATION_ID}",
211
+ "https://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/applications/#{APPLICATION_ID}",
212
212
  :body => ActiveSupport::JSON.encode(application),
213
213
  :content_type => "application/json")
214
214
 
@@ -217,7 +217,7 @@ describe "TropoProvisioning" do
217
217
 
218
218
  # Update a specific application
219
219
  FakeWeb.register_uri(:put,
220
- %r|http://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/applications/#{APPLICATION_ID}|,
220
+ %r|https://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/applications/#{APPLICATION_ID}|,
221
221
  :body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/#{APPLICATION_ID}" }),
222
222
  :status => ["200", "OK"])
223
223
 
@@ -229,7 +229,7 @@ describe "TropoProvisioning" do
229
229
  pending
230
230
  # Create an application
231
231
  FakeWeb.register_uri(:post,
232
- %r|http://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/applications|,
232
+ %r|https://#{USERNAME}:#{PASSWORD}@api.tropo.com/v1/applications|,
233
233
  :body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/provisioning/applications/#{APPLICATION_ID}" }),
234
234
  :status => ["200", "OK"])
235
235
 
@@ -269,4 +269,4 @@ describe "TropoProvisioning" do
269
269
  # result = @tp.delete_application(APPLICATION_ID)
270
270
  # result.message.should == 'delete successful'
271
271
  # end
272
- end
272
+ end
@@ -173,19 +173,19 @@ describe "TropoProvisioning" do
173
173
 
174
174
  # Applications
175
175
  FakeWeb.register_uri(:get,
176
- %r|http://foo:bar@api.tropo.com/v1/applications|,
176
+ %r|https://foo:bar@api.tropo.com/v1/applications|,
177
177
  :body => ActiveSupport::JSON.encode(applications),
178
178
  :content_type => "application/json")
179
179
 
180
180
  # Create an application
181
181
  FakeWeb.register_uri(:post,
182
- %r|http://foo:bar@api.tropo.com/v1/applications|,
182
+ %r|https://foo:bar@api.tropo.com/v1/applications|,
183
183
  :body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/108016" }),
184
184
  :status => ["200", "OK"])
185
185
 
186
186
  # Update a specific application
187
187
  FakeWeb.register_uri(:put,
188
- %r|http://foo:bar@api.tropo.com/v1/applications/108000|,
188
+ %r|https://foo:bar@api.tropo.com/v1/applications/108000|,
189
189
  :body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/108016" }),
190
190
  :status => ["200", "OK"])
191
191
 
@@ -197,19 +197,19 @@ describe "TropoProvisioning" do
197
197
 
198
198
  # Get a specific address
199
199
  FakeWeb.register_uri(:get,
200
- "http://foo:bar@api.tropo.com/v1/applications/108000/addresses/number/883510001812716",
200
+ "https://foo:bar@api.tropo.com/v1/applications/108000/addresses/number/883510001812716",
201
201
  :body => ActiveSupport::JSON.encode(@addresses[0]),
202
202
  :content_type => "application/json")
203
203
 
204
204
  # Get a address that is an IM/username
205
205
  FakeWeb.register_uri(:get,
206
- "http://foo:bar@api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
206
+ "https://foo:bar@api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
207
207
  :body => ActiveSupport::JSON.encode(@addresses[2]),
208
208
  :content_type => "application/json")
209
209
 
210
210
  # Get a address that is a token
211
211
  FakeWeb.register_uri(:get,
212
- "http://foo:bar@api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
212
+ "https://foo:bar@api.tropo.com/v1/applications/108000/addresses/jabber/xyz123",
213
213
  :body => ActiveSupport::JSON.encode(@addresses[2]),
214
214
  :content_type => "application/json")
215
215
 
@@ -221,80 +221,80 @@ describe "TropoProvisioning" do
221
221
 
222
222
  # Get a address that is a token
223
223
  FakeWeb.register_uri(:get,
224
- "http://foo:bar@api.tropo.com/v1/applications/108000/addresses/token/a1b2c3d4",
224
+ "https://foo:bar@api.tropo.com/v1/applications/108000/addresses/token/a1b2c3d4",
225
225
  :body => ActiveSupport::JSON.encode(@addresses[4]),
226
226
  :content_type => "application/json")
227
227
 
228
228
  # Get a address that is a number
229
229
  FakeWeb.register_uri(:post,
230
- "http://foo:bar@api.tropo.com/v1/applications/108000/addresses",
230
+ "https://foo:bar@api.tropo.com/v1/applications/108000/addresses",
231
231
  :body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/108000/addresses/number/7202551912" }),
232
232
  :content_type => "application/json")
233
233
 
234
234
  # Create a address that is an IM account
235
235
  FakeWeb.register_uri(:post,
236
- "http://foo:bar@api.tropo.com/v1/applications/108001/addresses",
236
+ "https://foo:bar@api.tropo.com/v1/applications/108001/addresses",
237
237
  :body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/108001/addresses/jabber/xyz123@bot.im" }),
238
238
  :content_type => "application/json")
239
239
 
240
240
  # Create a address that is a Token
241
241
  FakeWeb.register_uri(:post,
242
- "http://foo:bar@api.tropo.com/v1/applications/108002/addresses",
242
+ "https://foo:bar@api.tropo.com/v1/applications/108002/addresses",
243
243
  :body => ActiveSupport::JSON.encode({ "href" => "http://api.tropo.com/v1/applications/108002/addresses/token/12345679f90bac47a05b178c37d3c68aaf38d5bdbc5aba0c7abb12345d8a9fd13f1234c1234567dbe2c6f63b" }),
244
244
  :content_type => "application/json")
245
245
 
246
246
  # Delete an application
247
247
  FakeWeb.register_uri(:delete,
248
- "http://foo:bar@api.tropo.com/v1/applications/108000",
248
+ "https://foo:bar@api.tropo.com/v1/applications/108000",
249
249
  :body => ActiveSupport::JSON.encode({ 'message' => 'delete successful' }),
250
250
  :content_type => "application/json",
251
251
  :status => ["200", "OK"])
252
252
 
253
253
  # Exchanges
254
254
  FakeWeb.register_uri(:get,
255
- "http://foo:bar@api.tropo.com/v1/exchanges",
255
+ "https://foo:bar@api.tropo.com/v1/exchanges",
256
256
  :body => exchanges,
257
257
  :status => ["200", "OK"],
258
258
  :content_type => "application/json")
259
259
 
260
260
  # Delete a address
261
261
  FakeWeb.register_uri(:delete,
262
- "http://foo:bar@api.tropo.com/v1/applications/108000/addresses/number/883510001812716",
262
+ "https://foo:bar@api.tropo.com/v1/applications/108000/addresses/number/883510001812716",
263
263
  :body => ActiveSupport::JSON.encode({ 'message' => 'delete successful' }),
264
264
  :content_type => "application/json",
265
265
  :status => ["200", "OK"])
266
266
 
267
267
  # Add a specific address
268
268
  FakeWeb.register_uri(:post,
269
- "http://foo:bar@api.tropo.com/v1/applications/108002/addresses/number/883510001812716",
269
+ "https://foo:bar@api.tropo.com/v1/applications/108002/addresses/number/883510001812716",
270
270
  :body => ActiveSupport::JSON.encode({ 'message' => 'delete successful' }),
271
271
  :content_type => "application/json",
272
272
  :status => ["200", "OK"])
273
273
 
274
274
  # Create a new user
275
275
  FakeWeb.register_uri(:post,
276
- "http://foo:bar@api.tropo.com/v1/users",
276
+ "https://foo:bar@api.tropo.com/v1/users",
277
277
  :body => @new_user_json,
278
278
  :content_type => "application/json",
279
279
  :status => ["200", "OK"])
280
280
 
281
281
  # Get a specific user by user_id
282
282
  FakeWeb.register_uri(:get,
283
- "http://foo:bar@api.tropo.com/v1/users/12345",
283
+ "https://foo:bar@api.tropo.com/v1/users/12345",
284
284
  :body => ActiveSupport::JSON.encode(@existing_user),
285
285
  :content_type => "application/json",
286
286
  :status => ["200", "OK"])
287
287
 
288
288
  # Get a specific user by user_id
289
289
  FakeWeb.register_uri(:get,
290
- "http://foo:bar@api.tropo.com/v1/users/98765",
290
+ "https://foo:bar@api.tropo.com/v1/users/98765",
291
291
  :body => nil,
292
292
  :content_type => "application/json",
293
293
  :status => ["404", "Got an error here!"])
294
294
 
295
295
  # Get a specific user by username
296
296
  FakeWeb.register_uri(:get,
297
- "http://foo:bar@api.tropo.com/v1/users/foo",
297
+ "https://foo:bar@api.tropo.com/v1/users/foo",
298
298
  :body => ActiveSupport::JSON.encode(@existing_user),
299
299
  :content_type => "application/json",
300
300
  :status => ["200", "OK"])
@@ -308,62 +308,62 @@ describe "TropoProvisioning" do
308
308
 
309
309
  # Invalid credentials
310
310
  FakeWeb.register_uri(:get,
311
- "http://bad:password@api.tropo.com/v1/users/bad",
311
+ "https://bad:password@api.tropo.com/v1/users/bad",
312
312
  :content_type => "application/json",
313
313
  :status => ["401", "Unauthorized"])
314
314
 
315
315
  # Confirm an account account
316
316
  FakeWeb.register_uri(:post,
317
- "http://foo:bar@api.tropo.com/v1/users/12345/confirmations",
317
+ "https://foo:bar@api.tropo.com/v1/users/12345/confirmations",
318
318
  :body => ActiveSupport::JSON.encode({"message" => "successfully confirmed user 12345" }),
319
319
  :content_type => "application/json",
320
320
  :status => ["200", "OK"])
321
321
 
322
322
  # Return the payment method configured for a user
323
323
  FakeWeb.register_uri(:get,
324
- "http://foo:bar@api.tropo.com/v1/users/12345/payment/method",
324
+ "https://foo:bar@api.tropo.com/v1/users/12345/payment/method",
325
325
  :body => ActiveSupport::JSON.encode(@payment_method),
326
326
  :content_type => "application/json",
327
327
  :status => ["200", "OK"])
328
328
 
329
329
  # Return payment types
330
330
  FakeWeb.register_uri(:get,
331
- "http://foo:bar@api.tropo.com/v1/types/payment",
331
+ "https://foo:bar@api.tropo.com/v1/types/payment",
332
332
  :body => ActiveSupport::JSON.encode(@payment_methods),
333
333
  :content_type => "application/json",
334
334
  :status => ["200", "OK"])
335
335
 
336
336
  # Return features
337
337
  FakeWeb.register_uri(:get,
338
- "http://foo:bar@api.tropo.com/v1/features",
338
+ "https://foo:bar@api.tropo.com/v1/features",
339
339
  :body => ActiveSupport::JSON.encode(@features),
340
340
  :content_type => "application/json",
341
341
  :status => ["200", "OK"])
342
342
 
343
343
  # Return features for a user
344
344
  FakeWeb.register_uri(:get,
345
- "http://foo:bar@api.tropo.com/v1/users/12345/features",
345
+ "https://foo:bar@api.tropo.com/v1/users/12345/features",
346
346
  :body => ActiveSupport::JSON.encode(@user_features),
347
347
  :content_type => "application/json",
348
348
  :status => ["200", "OK"])
349
349
 
350
350
  # Add a feature to a user
351
351
  FakeWeb.register_uri(:post,
352
- "http://foo:bar@api.tropo.com/v1/users/12345/features",
352
+ "https://foo:bar@api.tropo.com/v1/users/12345/features",
353
353
  :body => ActiveSupport::JSON.encode(@feature),
354
354
  :content_type => "application/json",
355
355
  :status => ["200", "OK"])
356
356
 
357
357
  # Add a feature to a user
358
358
  FakeWeb.register_uri(:delete,
359
- "http://foo:bar@api.tropo.com/v1/users/12345/features/8",
359
+ "https://foo:bar@api.tropo.com/v1/users/12345/features/8",
360
360
  :body => ActiveSupport::JSON.encode(@feature_delete_message),
361
361
  :content_type => "application/json",
362
362
  :status => ["200", "OK"])
363
363
 
364
364
  # Add payment info to a user
365
365
  FakeWeb.register_uri(:put,
366
- "http://foo:bar@api.tropo.com/v1/users/12345/payment/method",
366
+ "https://foo:bar@api.tropo.com/v1/users/12345/payment/method",
367
367
  :body => ActiveSupport::JSON.encode(@payment_info_message),
368
368
  :content_type => "application/json",
369
369
  :status => ["200", "OK"])
@@ -371,103 +371,103 @@ describe "TropoProvisioning" do
371
371
 
372
372
  # List an account, with bad credentials
373
373
  FakeWeb.register_uri(:get,
374
- "http://evolution.voxeo.com/api/account/accesstoken/get.jsp?username=foobar7474&password=fooeyfooey",
374
+ "https://evolution.voxeo.com/api/account/accesstoken/get.jsp?username=foobar7474&password=fooeyfooey",
375
375
  :body => ActiveSupport::JSON.encode(@bad_account_creds),
376
376
  :content_type => "application/json",
377
377
  :status => ["403", "Invalid Login."])
378
378
 
379
379
  # Get our search terms
380
380
  FakeWeb.register_uri(:get,
381
- "http://foo:bar@api.tropo.com/v1/users/?username=foobar",
381
+ "https://foo:bar@api.tropo.com/v1/users/?username=foobar",
382
382
  :body => ActiveSupport::JSON.encode(@search_accounts),
383
383
  :content_type => "application/json",
384
384
  :status => ["200", "OK"])
385
385
 
386
386
  # Payment resource
387
387
  FakeWeb.register_uri(:post,
388
- "http://foo:bar@api.tropo.com/v1/users/1234/payments",
388
+ "https://foo:bar@api.tropo.com/v1/users/1234/payments",
389
389
  :body => ActiveSupport::JSON.encode({ :message => "successfully posted payment for the amount 1.000000" }),
390
390
  :content_type => "application/json",
391
391
  :status => ["200", "OK"])
392
392
 
393
393
  # Modify a user
394
394
  FakeWeb.register_uri(:put,
395
- "http://foo:bar@api.tropo.com/v1/users/12345",
395
+ "https://foo:bar@api.tropo.com/v1/users/12345",
396
396
  :body => ActiveSupport::JSON.encode({ :href => "http://api-smsified-eng.voxeo.net/v1/users/12345" }),
397
397
  :content_type => "application/json",
398
398
  :status => ["200", "OK"])
399
399
 
400
400
  # List available partitions
401
401
  FakeWeb.register_uri(:get,
402
- "http://foo:bar@api.tropo.com/v1/partitions",
402
+ "https://foo:bar@api.tropo.com/v1/partitions",
403
403
  :body => ActiveSupport::JSON.encode(@partitions),
404
404
  :content_type => "application/json",
405
405
  :status => ["200", "OK"])
406
406
 
407
407
  # List available platforms
408
408
  FakeWeb.register_uri(:get,
409
- "http://foo:bar@api.tropo.com/v1/partitions/staging/platforms",
409
+ "https://foo:bar@api.tropo.com/v1/partitions/staging/platforms",
410
410
  :body => ActiveSupport::JSON.encode(@platforms),
411
411
  :content_type => "application/json",
412
412
  :status => ["200", "OK"])
413
413
 
414
414
  # List balance
415
415
  FakeWeb.register_uri(:get,
416
- "http://foo:bar@api.tropo.com/v1/users/12345/usage",
416
+ "https://foo:bar@api.tropo.com/v1/users/12345/usage",
417
417
  :body => ActiveSupport::JSON.encode(@balance),
418
418
  :content_type => "application/json",
419
419
  :status => ["200", "OK"])
420
420
 
421
421
  # Whitelist
422
422
  FakeWeb.register_uri(:get,
423
- "http://foo:bar@api.tropo.com/v1/users/12345/partitions/production/platforms/sms/whitelist",
423
+ "https://foo:bar@api.tropo.com/v1/users/12345/partitions/production/platforms/sms/whitelist",
424
424
  :body => ActiveSupport::JSON.encode(@whitelist),
425
425
  :content_type => "application/json",
426
426
  :status => ["200", "OK"])
427
427
  # Whitelist
428
428
  FakeWeb.register_uri(:get,
429
- "http://foo:bar@api.tropo.com/v1/users/partitions/production/platforms/sms/whitelist",
429
+ "https://foo:bar@api.tropo.com/v1/users/partitions/production/platforms/sms/whitelist",
430
430
  :body => ActiveSupport::JSON.encode(@whitelist),
431
431
  :content_type => "application/json",
432
432
  :status => ["200", "OK"])
433
433
 
434
434
  # Whitelist create
435
435
  FakeWeb.register_uri(:post,
436
- "http://foo:bar@api.tropo.com/v1/users/12345/partitions/production/platforms/sms/whitelist",
436
+ "https://foo:bar@api.tropo.com/v1/users/12345/partitions/production/platforms/sms/whitelist",
437
437
  :body => ActiveSupport::JSON.encode(@whitelist),
438
438
  :content_type => "application/json",
439
439
  :status => ["200", "OK"])
440
440
  # Whitelist delete
441
441
  FakeWeb.register_uri(:delete,
442
- "http://foo:bar@api.tropo.com/v1/users/12345/partitions/production/platforms/sms/whitelist/14155551212",
442
+ "https://foo:bar@api.tropo.com/v1/users/12345/partitions/production/platforms/sms/whitelist/14155551212",
443
443
  :body => ActiveSupport::JSON.encode(@whitelist),
444
444
  :content_type => "application/json",
445
445
  :status => ["200", "OK"])
446
446
 
447
447
  # Countries
448
448
  FakeWeb.register_uri(:get,
449
- "http://foo:bar@api.tropo.com/v1/countries",
449
+ "https://foo:bar@api.tropo.com/v1/countries",
450
450
  :body => ActiveSupport::JSON.encode(@countries),
451
451
  :content_type => "application/json",
452
452
  :status => ["200", "OK"])
453
453
 
454
454
  # States
455
455
  FakeWeb.register_uri(:get,
456
- "http://foo:bar@api.tropo.com/v1/countries/36/states",
456
+ "https://foo:bar@api.tropo.com/v1/countries/36/states",
457
457
  :body => ActiveSupport::JSON.encode(@states),
458
458
  :content_type => "application/json",
459
459
  :status => ["200", "OK"])
460
460
 
461
461
  # Recurrency get
462
462
  FakeWeb.register_uri(:get,
463
- "http://foo:bar@api.tropo.com/v1/users/1234/payment/recurrence",
463
+ "https://foo:bar@api.tropo.com/v1/users/1234/payment/recurrence",
464
464
  :body => ActiveSupport::JSON.encode(@recurrence),
465
465
  :content_type => "application/json",
466
466
  :status => ["200", "OK"])
467
467
 
468
468
  # Recurrency update
469
469
  FakeWeb.register_uri(:put,
470
- "http://foo:bar@api.tropo.com/v1/users/1234/payment/recurrence",
470
+ "https://foo:bar@api.tropo.com/v1/users/1234/payment/recurrence",
471
471
  :body => ActiveSupport::JSON.encode(@recurrence_updated),
472
472
  :content_type => "application/json",
473
473
  :status => ["200", "OK"])
@@ -479,63 +479,63 @@ describe "TropoProvisioning" do
479
479
 
480
480
  # List invitations
481
481
  FakeWeb.register_uri(:get,
482
- "http://foo:bar@api.tropo.com/v1/invitations",
482
+ "https://foo:bar@api.tropo.com/v1/invitations",
483
483
  :body => ActiveSupport::JSON.encode(@invitations),
484
484
  :content_type => "application/json",
485
485
  :status => ["200", "OK"])
486
486
 
487
487
  # Get an invitation
488
488
  FakeWeb.register_uri(:get,
489
- "http://foo:bar@api.tropo.com/v1/invitations/ABC457",
489
+ "https://foo:bar@api.tropo.com/v1/invitations/ABC457",
490
490
  :body => ActiveSupport::JSON.encode(@invitations[1]),
491
491
  :content_type => "application/json",
492
492
  :status => ["200", "OK"])
493
493
 
494
494
  # Update an invitation
495
495
  FakeWeb.register_uri(:put,
496
- "http://foo:bar@api.tropo.com/v1/invitations/ABC457",
496
+ "https://foo:bar@api.tropo.com/v1/invitations/ABC457",
497
497
  :body => ActiveSupport::JSON.encode(@invitation_created),
498
498
  :content_type => "application/json",
499
499
  :status => ["200", "OK"])
500
500
 
501
501
  # Update an invitation
502
502
  FakeWeb.register_uri(:put,
503
- "http://foo:bar@api.tropo.com/v1/users/15909/invitations/ABC457",
503
+ "https://foo:bar@api.tropo.com/v1/users/15909/invitations/ABC457",
504
504
  :body => ActiveSupport::JSON.encode(@invitation_created),
505
505
  :content_type => "application/json",
506
506
  :status => ["200", "OK"])
507
507
 
508
508
  # Delete an invitation
509
509
  FakeWeb.register_uri(:delete,
510
- "http://foo:bar@api.tropo.com/v1/invitations/ABC457",
510
+ "https://foo:bar@api.tropo.com/v1/invitations/ABC457",
511
511
  :body => ActiveSupport::JSON.encode(@deleted_invitation),
512
512
  :content_type => "application/json",
513
513
  :status => ["200", "OK"])
514
514
 
515
515
  # Delete an invitation
516
516
  FakeWeb.register_uri(:delete,
517
- "http://foo:bar@api.tropo.com/v1/users/15909/invitations/ABC457",
517
+ "https://foo:bar@api.tropo.com/v1/users/15909/invitations/ABC457",
518
518
  :body => ActiveSupport::JSON.encode(@deleted_invitation),
519
519
  :content_type => "application/json",
520
520
  :status => ["200", "OK"])
521
521
 
522
522
  # Create invitation
523
523
  FakeWeb.register_uri(:post,
524
- "http://foo:bar@api.tropo.com/v1/invitations",
524
+ "https://foo:bar@api.tropo.com/v1/invitations",
525
525
  :body => ActiveSupport::JSON.encode(@invitation_created),
526
526
  :content_type => "application/json",
527
527
  :status => ["200", "OK"])
528
528
 
529
529
  # Create invitation
530
530
  FakeWeb.register_uri(:post,
531
- "http://foo:bar@api.tropo.com/v1/users/15909/invitations",
531
+ "https://foo:bar@api.tropo.com/v1/users/15909/invitations",
532
532
  :body => ActiveSupport::JSON.encode(@invitation_created),
533
533
  :content_type => "application/json",
534
534
  :status => ["200", "OK"])
535
535
 
536
536
  # List invitation for a user
537
537
  FakeWeb.register_uri(:get,
538
- "http://foo:bar@api.tropo.com/v1/users/15909/invitations",
538
+ "https://foo:bar@api.tropo.com/v1/users/15909/invitations",
539
539
  :body => ActiveSupport::JSON.encode([@invitation_created]),
540
540
  :content_type => "application/json",
541
541
  :status => ["200", "OK"])
@@ -549,7 +549,7 @@ describe "TropoProvisioning" do
549
549
 
550
550
  # List invitation for a user
551
551
  FakeWeb.register_uri(:get,
552
- "http://foo:bar@api.tropo.com/v1/users/15909/invitations/ABC457",
552
+ "https://foo:bar@api.tropo.com/v1/users/15909/invitations/ABC457",
553
553
  :body => ActiveSupport::JSON.encode(@invitations[1]),
554
554
  :content_type => "application/json",
555
555
  :status => ["200", "OK"])
@@ -557,7 +557,7 @@ describe "TropoProvisioning" do
557
557
  @username_check = { 'available' => false, 'href' => "http://api.smsified.com/v1/usernames/jsgoecke", 'valid' => true }
558
558
  # List invitation for a user
559
559
  FakeWeb.register_uri(:get,
560
- "http://foo:bar@api.tropo.com/v1/usernames/12345",
560
+ "https://foo:bar@api.tropo.com/v1/usernames/12345",
561
561
  :body => ActiveSupport::JSON.encode(@username_check),
562
562
  :content_type => "application/json",
563
563
  :status => ["200", "OK"])
@@ -808,17 +808,21 @@ describe "TropoProvisioning" do
808
808
  end
809
809
  end
810
810
 
811
- it "should add appropriate addresses" do
811
+ it "should add appropriate number address" do
812
812
  # Add a address based on a prefix
813
813
  result = tropo_provisioning.create_address('108000', { :type => 'number', :prefix => '1303' })
814
814
  result[:href].should == "http://api.tropo.com/v1/applications/108000/addresses/number/7202551912"
815
815
  result[:address].should == '7202551912'
816
+ end
816
817
 
818
+ it "should add appropriate jabber address" do
817
819
  # Add a jabber account
818
820
  result = tropo_provisioning.create_address('108001', { :type => 'jabber', :username => 'xyz123@bot.im' })
819
821
  result[:href].should == "http://api.tropo.com/v1/applications/108001/addresses/jabber/xyz123@bot.im"
820
822
  result[:address].should == 'xyz123@bot.im'
821
-
823
+ end
824
+
825
+ it "should add appropriate token address" do
822
826
  # Add a token
823
827
  result = tropo_provisioning.create_address('108002', { :type => 'token', :channel => 'voice' })
824
828
  result[:href].should == "http://api.tropo.com/v1/applications/108002/addresses/token/12345679f90bac47a05b178c37d3c68aaf38d5bdbc5aba0c7abb12345d8a9fd13f1234c1234567dbe2c6f63b"
@@ -27,9 +27,11 @@ Gem::Specification.new do |s|
27
27
  s.add_development_dependency("fakeweb")
28
28
  s.add_development_dependency("yard")
29
29
  s.add_development_dependency("rdoc")
30
+ s.add_development_dependency("rake")
30
31
 
31
32
  s.add_runtime_dependency("hashie", ">= 0.2.1")
32
33
  s.add_runtime_dependency("activesupport")
33
34
  s.add_runtime_dependency("i18n")
35
+ s.add_runtime_dependency("json") if RUBY_VERSION =~ /1.8/
34
36
  end
35
37
 
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.22
4
+ version: 0.0.23
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-09-05 00:00:00.000000000Z
13
+ date: 2011-09-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &70361391690020 !ruby/object:Gem::Requirement
17
+ requirement: &70314617321460 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *70361391690020
25
+ version_requirements: *70314617321460
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: fakeweb
28
- requirement: &70361391688520 !ruby/object:Gem::Requirement
28
+ requirement: &70314617320080 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *70361391688520
36
+ version_requirements: *70314617320080
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: yard
39
- requirement: &70361391687380 !ruby/object:Gem::Requirement
39
+ requirement: &70314617319300 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70361391687380
47
+ version_requirements: *70314617319300
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rdoc
50
- requirement: &70361391686800 !ruby/object:Gem::Requirement
50
+ requirement: &70314617318680 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,21 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70361391686800
58
+ version_requirements: *70314617318680
59
+ - !ruby/object:Gem::Dependency
60
+ name: rake
61
+ requirement: &70314617330920 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *70314617330920
59
70
  - !ruby/object:Gem::Dependency
60
71
  name: hashie
61
- requirement: &70361391686000 !ruby/object:Gem::Requirement
72
+ requirement: &70314617329260 !ruby/object:Gem::Requirement
62
73
  none: false
63
74
  requirements:
64
75
  - - ! '>='
@@ -66,10 +77,10 @@ dependencies:
66
77
  version: 0.2.1
67
78
  type: :runtime
68
79
  prerelease: false
69
- version_requirements: *70361391686000
80
+ version_requirements: *70314617329260
70
81
  - !ruby/object:Gem::Dependency
71
82
  name: activesupport
72
- requirement: &70361391685240 !ruby/object:Gem::Requirement
83
+ requirement: &70314617327680 !ruby/object:Gem::Requirement
73
84
  none: false
74
85
  requirements:
75
86
  - - ! '>='
@@ -77,10 +88,10 @@ dependencies:
77
88
  version: '0'
78
89
  type: :runtime
79
90
  prerelease: false
80
- version_requirements: *70361391685240
91
+ version_requirements: *70314617327680
81
92
  - !ruby/object:Gem::Dependency
82
93
  name: i18n
83
- requirement: &70361391684580 !ruby/object:Gem::Requirement
94
+ requirement: &70314617326680 !ruby/object:Gem::Requirement
84
95
  none: false
85
96
  requirements:
86
97
  - - ! '>='
@@ -88,7 +99,7 @@ dependencies:
88
99
  version: '0'
89
100
  type: :runtime
90
101
  prerelease: false
91
- version_requirements: *70361391684580
102
+ version_requirements: *70314617326680
92
103
  description: Library for interacting with the Tropo Provisioning API
93
104
  email:
94
105
  - jsgoecke@voxeo.com
@@ -158,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
169
  version: '0'
159
170
  requirements: []
160
171
  rubyforge_project: tropo-provisioning
161
- rubygems_version: 1.8.6
172
+ rubygems_version: 1.8.10
162
173
  signing_key:
163
174
  specification_version: 3
164
175
  summary: Library for interacting with the Tropo Provisioning API