tropo-provisioning 0.0.23 → 0.0.24

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.
@@ -5,39 +5,39 @@ require 'active_support/inflector'
5
5
  # This class is a wrapper that allows an easy way to access Tropo HTTP Provisioning API
6
6
  # It defines a set of methods to create, update, retrieve or delete different kind of resources.
7
7
  class TropoProvisioning
8
-
8
+
9
9
  autoload :TropoClient, 'tropo-provisioning/tropo_client'
10
10
  autoload :TropoError, 'tropo-provisioning/tropo_error'
11
-
11
+
12
12
  # Defaults for the creation of applications
13
13
  DEFAULT_OPTIONS = { :partition => 'staging', :platform => 'scripting' }
14
-
14
+
15
15
  # Array of supported platforms in Tropo
16
16
  VALID_PLATFORMS = %w(scripting webapi)
17
17
  # Array of supported partitions in Tropo
18
18
  VALID_PARTITIONS = %w(staging production)
19
-
20
- attr_reader :user_data
21
-
19
+
20
+ attr_reader :user_data, :base_uri
21
+
22
22
  ##
23
23
  # Creates a new TropoProvisioning object
24
24
  #
25
25
  # ==== Parameters
26
26
  # * [required, String] username for your Tropo user
27
27
  # * [required, String] password for your Tropo user
28
- # * [optional, Hash] params
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
30
  #
31
31
  # ==== Return
32
32
  #
33
33
  # TropoProvisioning object
34
- def initialize(username, password, params={})
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)
34
+ def initialize(username, password, params={})
35
+ @base_uri = (params[:base_uri] || "https://api.tropo.com/v1/").sub(/(\/)+$/,'/')
36
+ proxy = params[:proxy] || nil
37
+ @tropo_client = TropoClient.new(username, password, @base_uri, { 'Content-Type' => 'application/json' }, proxy)
38
38
  user(username)
39
39
  end
40
-
40
+
41
41
  ##
42
42
  # Retrieves specific user information
43
43
  # ==== Parameters
@@ -50,15 +50,15 @@ class TropoProvisioning
50
50
  end
51
51
  temp_request("/#{action}.jsp?username=#{username}&password=#{password}")
52
52
  end
53
-
53
+
54
54
  ##
55
55
  # Username used for HTTP authentication (valid Tropo user)
56
56
  def username
57
57
  @tropo_client.username
58
58
  end
59
-
59
+
60
60
  alias :authenticate_account :account
61
-
61
+
62
62
  ##
63
63
  # Obtain information about a user
64
64
  #
@@ -76,7 +76,7 @@ class TropoProvisioning
76
76
  end
77
77
  result
78
78
  end
79
-
79
+
80
80
  ##
81
81
  # Confirms a user after they have been created. For example, you may want to email your user to make
82
82
  # sure they are real before activating the user.
@@ -93,7 +93,7 @@ class TropoProvisioning
93
93
  params = { :key => confirmation_key, :endUserHost => ip_address }
94
94
  @tropo_client.post("users/#{user_id}/confirmations", params)
95
95
  end
96
-
96
+
97
97
  ##
98
98
  # Creates a new user in a pending state. Once you receive the href/user_id/confirmation_key
99
99
  # you may then invoke the confirm_user method once you have taken appropriate steps to confirm the
@@ -104,8 +104,8 @@ class TropoProvisioning
104
104
  # * [required, String] :username the name of the user to create the user for
105
105
  # * [required, String] :password the password to use for the user
106
106
  # * [required, String] :email the email address to use
107
- # * [optional, String] :first_name of the user
108
- # * [optional, String] :last_name of the user
107
+ # * [required, String] :first_name of the user
108
+ # * [required, String] :last_name of the user
109
109
  # * [optional, String] :website the URL of the user's website
110
110
  # * [optional, String] :organization of the user, such as a company name
111
111
  # * [optional, String] :job_title of the user
@@ -125,11 +125,11 @@ class TropoProvisioning
125
125
  # * [ArgumentError]
126
126
  # if missing the :username, :password or :email parameters
127
127
  def create_user(params={})
128
- validate_params(params, %w(username password email))
129
-
128
+ validate_params(params, %w(username password first_name last_name email))
129
+
130
130
  # Set the Company Branding ID, or use default
131
- params[:website] = 'tropo' unless params[:website]
132
-
131
+ params[:website] = 'tropo' unless params[:website]
132
+
133
133
  result = @tropo_client.post("users", params)
134
134
  result[:user_id] = get_element(result.href)
135
135
  result[:confirmation_key] = result['confirmationKey']
@@ -155,7 +155,7 @@ class TropoProvisioning
155
155
  end
156
156
  result
157
157
  end
158
-
158
+
159
159
  ##
160
160
  # Allows you to search users to find a list of users
161
161
  #
@@ -184,11 +184,11 @@ class TropoProvisioning
184
184
  # * [required, String] a username to check
185
185
  # ==== Return
186
186
  # * [Array]
187
- # a hash containing an array of hashes with the qualifying account details
187
+ # a hash containing an array of hashes with the qualifying account details
188
188
  def username_exists?(username)
189
189
  @tropo_client.get("usernames/#{username}")
190
190
  end
191
-
191
+
192
192
  ##
193
193
  # Fetches the payment information for a user
194
194
  #
@@ -203,7 +203,7 @@ class TropoProvisioning
203
203
  result.merge!({ :id => get_element(result.paymentType) })
204
204
  result
205
205
  end
206
-
206
+
207
207
  ##
208
208
  # Lists the available payment types
209
209
  #
@@ -213,7 +213,7 @@ class TropoProvisioning
213
213
  def available_payment_types
214
214
  @tropo_client.get("types/payment")
215
215
  end
216
-
216
+
217
217
  ##
218
218
  # Obtain the current balance of a user
219
219
  #
@@ -226,7 +226,7 @@ class TropoProvisioning
226
226
  def balance(user_id)
227
227
  @tropo_client.get("users/#{user_id}/usage")
228
228
  end
229
-
229
+
230
230
  ##
231
231
  # Return the list of available countries
232
232
  #
@@ -237,7 +237,7 @@ class TropoProvisioning
237
237
  result = @tropo_client.get("countries")
238
238
  add_ids(result)
239
239
  end
240
-
240
+
241
241
  ##
242
242
  # Return the list of available states for a country
243
243
  #
@@ -248,7 +248,7 @@ class TropoProvisioning
248
248
  result = @tropo_client.get("countries/#{id}/states")
249
249
  add_ids(result)
250
250
  end
251
-
251
+
252
252
  ##
253
253
  # Lists the available features
254
254
  #
@@ -268,7 +268,7 @@ class TropoProvisioning
268
268
  def user_features(user_id)
269
269
  @tropo_client.get("users/#{user_id}/features")
270
270
  end
271
-
271
+
272
272
  ##
273
273
  # Enable a particular feature for a user
274
274
  #
@@ -282,7 +282,7 @@ class TropoProvisioning
282
282
  def user_enable_feature(user_id, feature)
283
283
  @tropo_client.post("users/#{user_id}/features", { :feature => feature })
284
284
  end
285
-
285
+
286
286
  ##
287
287
  # Disable a particular feature for a user
288
288
  #
@@ -296,7 +296,7 @@ class TropoProvisioning
296
296
  def user_disable_feature(user_id, feature_number)
297
297
  @tropo_client.delete("users/#{user_id}/features/#{feature_number}")
298
298
  end
299
-
299
+
300
300
  ##
301
301
  # Add/modify payment info for a user
302
302
  #
@@ -305,7 +305,7 @@ class TropoProvisioning
305
305
  # * [require, Hash] params the params to add the payment info
306
306
  # * [:account_number] [required, String] the credit card number
307
307
  # * [required, String] :payment_type the type, such as visa, mastercard, etc
308
- # * [required, String] :address
308
+ # * [required, String] :address
309
309
  # * [optional, String] :address2
310
310
  # * [required, String] :city
311
311
  # * [required, String] :state
@@ -327,10 +327,10 @@ class TropoProvisioning
327
327
  @tropo_client.put("users/#{user_id}/payment/method", params)
328
328
  end
329
329
  alias :modify_payment_info :add_payment_info
330
-
330
+
331
331
  ##
332
332
  # Add/modify recurring fund amount and threshold
333
- #
333
+ #
334
334
  # ==== Parameters
335
335
  # * [required, String] user_id to add the payment details for
336
336
  # * [require, Hash] params the params to add the recurrence
@@ -341,13 +341,13 @@ class TropoProvisioning
341
341
  # * [Hash]
342
342
  def update_recurrence(user_id, params={})
343
343
  validate_params(params, %w(recharge_amount threshold_percentage))
344
-
344
+
345
345
  @tropo_client.put("users/#{user_id}/payment/recurrence", params)
346
346
  end
347
-
347
+
348
348
  ##
349
349
  # Add/modify recurring fund amount and threshold
350
- #
350
+ #
351
351
  # ==== Parameters
352
352
  # * [required, String] user_id to get the recurrence info for
353
353
  #
@@ -356,7 +356,7 @@ class TropoProvisioning
356
356
  def get_recurrence(user_id)
357
357
  result = @tropo_client.get("users/#{user_id}/payment/recurrence")
358
358
  end
359
-
359
+
360
360
  ##
361
361
  # Makes a payment on behalf of a user
362
362
  #
@@ -369,10 +369,10 @@ class TropoProvisioning
369
369
  # a message with the success or failure of the payment
370
370
  def make_payment(user_id, amount)
371
371
  amount.instance_of?(Float) or raise ArgumentError, 'amount must be of type Float'
372
-
372
+
373
373
  @tropo_client.post("users/#{user_id}/payments", { :amount => amount })
374
374
  end
375
-
375
+
376
376
  ##
377
377
  # Creates an address to an existing application
378
378
  #
@@ -384,18 +384,18 @@ class TropoProvisioning
384
384
  # * [String] :username the messaging/IM account's username
385
385
  # * [String] :password the messaging/IM account's password
386
386
  #
387
- # ==== Return
387
+ # ==== *Return*
388
388
  # * [Hash] params the key/values that make up the application
389
389
  # * [String] :href identifies the address that was added, refer to address method for details
390
390
  # * [String] :address the address that was created
391
391
  def create_address(application_id, params={})
392
392
  validate_address_parameters(params)
393
-
393
+
394
394
  result = @tropo_client.post("applications/#{application_id.to_s}/addresses", params)
395
395
  result[:address] = get_element(result.href)
396
396
  result
397
397
  end
398
-
398
+
399
399
  ##
400
400
  # Get a specific application
401
401
  #
@@ -420,7 +420,7 @@ class TropoProvisioning
420
420
  app.merge!({ :application_id => get_element(href) })
421
421
  end
422
422
  end
423
-
423
+
424
424
  ##
425
425
  # Fetches all of the applications configured for a user
426
426
  #
@@ -434,7 +434,7 @@ class TropoProvisioning
434
434
  end
435
435
  result_with_ids
436
436
  end
437
-
437
+
438
438
  ##
439
439
  # Fetches the application(s) with the associated addresses in the hash
440
440
  #
@@ -455,7 +455,7 @@ class TropoProvisioning
455
455
  end
456
456
  end
457
457
  alias :application_with_address :applications_with_addresses
458
-
458
+
459
459
  ##
460
460
  # Create a new application
461
461
  #
@@ -476,7 +476,7 @@ class TropoProvisioning
476
476
  result[:application_id] = get_element(result.href)
477
477
  result
478
478
  end
479
-
479
+
480
480
  ##
481
481
  # Deletes an application
482
482
  #
@@ -488,7 +488,7 @@ class TropoProvisioning
488
488
  def delete_application(application_id)
489
489
  @tropo_client.delete("applications/#{application_id.to_s}")
490
490
  end
491
-
491
+
492
492
  ##
493
493
  # Deletes a address from a specific application
494
494
  #
@@ -497,10 +497,10 @@ class TropoProvisioning
497
497
  # * [String] address_id for the address
498
498
  def delete_address(application_id, address_id)
499
499
  address_to_delete = address(application_id, address_id)
500
-
500
+
501
501
  @tropo_client.delete("applications/#{application_id.to_s}/addresses/#{address_to_delete['type']}/#{address_id.to_s}")
502
502
  end
503
-
503
+
504
504
  ##
505
505
  # Provides a list of available exchanges to obtain Numbers from
506
506
  #
@@ -509,7 +509,7 @@ class TropoProvisioning
509
509
  def exchanges
510
510
  @tropo_client.get("exchanges")
511
511
  end
512
-
512
+
513
513
  ##
514
514
  # Used to move a address between one application and another
515
515
  #
@@ -520,7 +520,7 @@ class TropoProvisioning
520
520
  # * [required, String] :address
521
521
  def move_address(params={})
522
522
  validate_params(params, %w(from to address))
523
-
523
+
524
524
  begin
525
525
  address_to_move = address(params[:from], params[:address])
526
526
  delete_address(params[:from], params[:address])
@@ -529,7 +529,7 @@ class TropoProvisioning
529
529
  raise RuntimeError, 'Unable to move the address'
530
530
  end
531
531
  end
532
-
532
+
533
533
  ##
534
534
  # Get a specific address for an application
535
535
  #
@@ -554,13 +554,13 @@ class TropoProvisioning
554
554
  # * [String] :password the messaging/IM account's password
555
555
  # * [String] :token alphanumeric string that identifies your Tropo application, used with the Session API
556
556
  def address(application_id, address_id)
557
- addresses(application_id).each { |address| return address if address['number'] == address_id ||
558
- address['username'] == address_id ||
559
- address['pin'] == address_id ||
560
- address['token'] == address_id }
557
+ addresses(application_id).each { |address| return address if address['number'] == address_id ||
558
+ address['username'] == address_id ||
559
+ address['pin'] == address_id ||
560
+ address['token'] == address_id }
561
561
  raise RuntimeError, 'Address not found with that application.'
562
562
  end
563
-
563
+
564
564
  ##
565
565
  # Get all of the configured addresses for an application
566
566
  #
@@ -572,7 +572,7 @@ class TropoProvisioning
572
572
  def addresses(application_id)
573
573
  @tropo_client.get("applications/#{application_id.to_s}/addresses")
574
574
  end
575
-
575
+
576
576
  ##
577
577
  # Updated an existing application
578
578
  #
@@ -590,7 +590,7 @@ class TropoProvisioning
590
590
  def update_application(application_id, params={})
591
591
  @tropo_client.put("applications/#{application_id.to_s}", params )
592
592
  end
593
-
593
+
594
594
  ##
595
595
  # Fetch all invitations, or invitations by user
596
596
  #
@@ -609,7 +609,7 @@ class TropoProvisioning
609
609
  end
610
610
  end
611
611
  alias :user_invitations :invitations
612
-
612
+
613
613
  ##
614
614
  # Fetch an invitation
615
615
  #
@@ -625,12 +625,12 @@ class TropoProvisioning
625
625
  # * [Hash] return an invitation
626
626
  def invitation(invitation_id, user_id = nil)
627
627
  path = user_id.nil? ? "invitations/#{invitation_id}" : "users/#{user_id}/invitations/#{invitation_id}"
628
-
628
+
629
629
  @tropo_client.get(path)
630
630
  end
631
631
 
632
632
  alias :user_invitation :invitation
633
-
633
+
634
634
  ##
635
635
  # Fetch an invitation
636
636
  #
@@ -646,30 +646,30 @@ class TropoProvisioning
646
646
  # * [Hash] return an invitation
647
647
  def delete_invitation(invitation_id, user_id = nil)
648
648
  path = user_id.nil? ? "invitations/#{invitation_id}" : "users/#{user_id}/invitations/#{invitation_id}"
649
-
649
+
650
650
  @tropo_client.delete(path)
651
651
  end
652
652
 
653
653
  alias :delete_user_invitation :delete_invitation
654
-
654
+
655
655
  ##
656
656
  # Create an invitation
657
657
  #
658
658
  # @overload def create_invitation(options)
659
659
  # ==== Parameters
660
660
  # * [required, Hash] params the parameters used to create the application
661
- # * [optional, String] :code the invitation code (defaults to a random alphanum string of length 6 if not specified on POST)
662
- # * [optional, String] :count the number of accounts that may signup with this code (decrements on each signup)
663
- # * [optional, String] :credit starting account balance for users who signup with this code (replaces the default for the brand)
661
+ # * [optional, String] :code the invitation code (defaults to a random alphanum string of length 6 if not specified on POST)
662
+ # * [optional, String] :count the number of accounts that may signup with this code (decrements on each signup)
663
+ # * [optional, String] :credit starting account balance for users who signup with this code (replaces the default for the brand)
664
664
  # * [optional, String] :partition whether to create in staging or production
665
- # * [optional, String] :owner URI identifying the user to which this invite code belongs (optional - null implies this is a "global" code)
665
+ # * [optional, String] :owner URI identifying the user to which this invite code belongs (optional - null implies this is a "global" code)
666
666
  # @overload def create_user_invitation(user_id, options)
667
667
  # ==== Parameters
668
668
  # * [requried, String] user_id to create the invitation for
669
669
  # * [required, Hash] params the parameters used to create the application
670
- # * [optional, String] :code the invitation code (defaults to a random alphanum string of length 6 if not specified on POST)
671
- # * [optional, String] :count the number of accounts that may signup with this code (decrements on each signup)
672
- # * [optional, String] :credit starting account balance for users who signup with this code (replaces the default for the brand)
670
+ # * [optional, String] :code the invitation code (defaults to a random alphanum string of length 6 if not specified on POST)
671
+ # * [optional, String] :count the number of accounts that may signup with this code (decrements on each signup)
672
+ # * [optional, String] :credit starting account balance for users who signup with this code (replaces the default for the brand)
673
673
  # * [optional, String] :partition whether to create in staging or production
674
674
  # * [optional, String] :owner URI identifying the user to which this invite code belongs (optional - null implies this is a "global" code)
675
675
  #
@@ -683,7 +683,7 @@ class TropoProvisioning
683
683
  end
684
684
  end
685
685
  alias :create_user_invitation :create_invitation
686
-
686
+
687
687
  ##
688
688
  # Update an invitation
689
689
  #
@@ -691,17 +691,17 @@ class TropoProvisioning
691
691
  # ==== Parameters
692
692
  # * [required, String] id of the invitation to udpate (code)
693
693
  # * [required, Hash] params the parameters used to update the application
694
- # * [optional, String] :count the number of accounts that may signup with this code (decrements on each signup)
695
- # * [optional, String] :credit starting account balance for users who signup with this code (replaces the default for the brand)
694
+ # * [optional, String] :count the number of accounts that may signup with this code (decrements on each signup)
695
+ # * [optional, String] :credit starting account balance for users who signup with this code (replaces the default for the brand)
696
696
  # * [optional, String] :partition whether to create in staging or production
697
- # * [optional, String] :owner URI identifying the user to which this invite code belongs (optional - null implies this is a "global" code)
697
+ # * [optional, String] :owner URI identifying the user to which this invite code belongs (optional - null implies this is a "global" code)
698
698
  # @overload def updated_user_invitation(invitation_id, user_id, options)
699
699
  # ==== Parameters
700
700
  # * [required, String] id of the invitation to udpate (code)
701
701
  # * [required, String] id of the user to update the invitation code for
702
702
  # * [required, Hash] params the parameters used to update the application
703
- # * [optional, String] :count the number of accounts that may signup with this code (decrements on each signup)
704
- # * [optional, String] :credit starting account balance for users who signup with this code (replaces the default for the brand)
703
+ # * [optional, String] :count the number of accounts that may signup with this code (decrements on each signup)
704
+ # * [optional, String] :credit starting account balance for users who signup with this code (replaces the default for the brand)
705
705
  # * [optional, String] :partition whether to create in staging or production
706
706
  # * [optional, String] :owner URI identifying the user to which this invite code belongs (optional - null implies this is a "global" code)
707
707
  #
@@ -715,7 +715,7 @@ class TropoProvisioning
715
715
  end
716
716
  end
717
717
  alias :update_user_invitation :update_invitation
718
-
718
+
719
719
  ##
720
720
  # Get the available partitions available
721
721
  #
@@ -725,7 +725,7 @@ class TropoProvisioning
725
725
  def partitions
726
726
  @tropo_client.get("partitions")
727
727
  end
728
-
728
+
729
729
  ##
730
730
  # Get the available platforms available under a certain partition
731
731
  #
@@ -737,7 +737,7 @@ class TropoProvisioning
737
737
  def platforms(partition)
738
738
  @tropo_client.get("partitions/#{partition}/platforms")
739
739
  end
740
-
740
+
741
741
  ##
742
742
  # Get the whitelist of the numbers on a particular users list
743
743
  #
@@ -749,10 +749,10 @@ class TropoProvisioning
749
749
  # the href and value containing the number on the whitelist
750
750
  def whitelist(user_id = nil)
751
751
  resource = user_id.nil? ? "users/partitions/production/platforms/sms/whitelist" : "users/#{user_id}/partitions/production/platforms/sms/whitelist"
752
-
752
+
753
753
  @tropo_client.get(resource)
754
754
  end
755
-
755
+
756
756
  ##
757
757
  # Add to a whitelist for a particular user
758
758
  #
@@ -763,11 +763,11 @@ class TropoProvisioning
763
763
  #
764
764
  # ==== Return
765
765
  # * [Hash]
766
- # the href
766
+ # the href
767
767
  def add_whitelist(params={})
768
- resource = params.has_key?(:user_id) ?
769
- "users/#{params[:user_id]}/partitions/production/platforms/sms/whitelist" :
770
- "users/partitions/production/platforms/sms/whitelist"
768
+ resource = params.has_key?(:user_id) ?
769
+ "users/#{params[:user_id]}/partitions/production/platforms/sms/whitelist" :
770
+ "users/partitions/production/platforms/sms/whitelist"
771
771
  @tropo_client.post(resource, {:value => params[:value]})
772
772
  end
773
773
 
@@ -780,15 +780,15 @@ class TropoProvisioning
780
780
  #
781
781
  # ==== Return
782
782
  # * [Hash]
783
- # the href
783
+ # the href
784
784
  def delete_whitelist(params={})
785
785
  resource = params.has_key?(:user_id) ? "users/#{params[:user_id]}/partitions/production/platforms/sms/whitelist/" : "users/partitions/production/platforms/sms/whitelist/"
786
786
 
787
787
  @tropo_client.delete("#{resource}#{params[:value]}")
788
788
  end
789
-
789
+
790
790
  private
791
-
791
+
792
792
  ##
793
793
  # Returns the current method name
794
794
  #
@@ -797,13 +797,13 @@ class TropoProvisioning
797
797
  def current_method_name
798
798
  caller[0] =~ /`([^']*)'/ and $1
799
799
  end
800
-
800
+
801
801
  ##
802
802
  # Adds the IDs to an Array of Hashes if no ID is present
803
803
  #
804
804
  # ==== Parameters
805
805
  # * [required, Array] array of hashes to add IDs to
806
- #
806
+ #
807
807
  # ==== Return
808
808
  # * [Array]
809
809
  # the array of hashes with ID added
@@ -813,7 +813,7 @@ class TropoProvisioning
813
813
  end
814
814
  array
815
815
  end
816
-
816
+
817
817
  ##
818
818
  # Parses the URL and returns the last element
819
819
  #
@@ -825,7 +825,7 @@ class TropoProvisioning
825
825
  def get_element(url)
826
826
  url.split('/').last
827
827
  end
828
-
828
+
829
829
  ##
830
830
  # Associates the addresses to an application
831
831
  #
@@ -838,7 +838,7 @@ class TropoProvisioning
838
838
  add = addresses(app.application_id)
839
839
  app.merge!({ :addresses => add })
840
840
  end
841
-
841
+
842
842
  ##
843
843
  # Creates the appropriate request for the temporary Evolution account API
844
844
  #
@@ -865,7 +865,7 @@ class TropoProvisioning
865
865
  Hashie::Mash.new(result)
866
866
  end
867
867
  end
868
-
868
+
869
869
 
870
870
  ##
871
871
  # Used to validate required params in either underscore or camelCase formats
@@ -885,7 +885,7 @@ class TropoProvisioning
885
885
  end
886
886
  end
887
887
  end
888
-
888
+
889
889
  ##
890
890
  # Validates that we have all of the appropriate params when creating an application
891
891
  #
@@ -902,25 +902,25 @@ class TropoProvisioning
902
902
  def validate_application_params(params={})
903
903
  # Make sure all of the arguments are present
904
904
  raise ArgumentError, ':name is a required parameter' unless params[:name] || params['name']
905
-
905
+
906
906
  # Make sure the arguments have valid values
907
907
  raise ArgumentError, ":platform must be #{VALID_PLATFORMS.map{|platform| "\'#{platform}\'"}.join(' or ')}" unless VALID_PLATFORMS.include?(params[:platform]) or VALID_PLATFORMS.include?(params["platform"])
908
908
  raise ArgumentError, ":partition must be #{VALID_PARTITIONS.map{|partition| "\'#{partition}\'"}.join(' or ')}" unless VALID_PARTITIONS.include?(params[:partition]) or VALID_PARTITIONS.include?(params["partition"])
909
909
  end
910
-
910
+
911
911
  ##
912
912
  # Validates a create address request parameters
913
913
  #
914
914
  # ==== Parameters
915
915
  # * [required, Hash] required parameters values
916
- #
916
+ #
917
917
  # ==== Return
918
- # * nil if successful validation
918
+ # * nil if successful validation
919
919
  # * ArgumentError is a required parameter is missing
920
920
  #
921
921
  def validate_address_parameters(params={})
922
922
  raise ArgumentError, ":type is a required parameter" unless params[:type] || params['type']
923
-
923
+
924
924
  case params[:type].downcase
925
925
  when 'number'
926
926
  raise ArgumentError, ':prefix required to add a number address' unless params[:prefix] || params[:number] || params['prefix'] || params['number']
@@ -934,4 +934,4 @@ class TropoProvisioning
934
934
  raise ArgumentError, ':channel must be voice or messaging' unless params[:channel] == 'voice' || params[:channel] == 'messaging' || params['channel'] == 'voice' || params['channel'] == 'messaging'
935
935
  end
936
936
  end
937
- end
937
+ end
@@ -1,5 +1,5 @@
1
1
 
2
2
  class TropoProvisioning
3
3
  # Current gem version
4
- VERSION = "0.0.23"
5
- end
4
+ VERSION = "0.0.24"
5
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../lib', __FILE__)
1
3
  require 'tropo-provisioning'
2
4
  require 'fakeweb'
3
5