twilio-ruby 5.3.1 → 5.4.0

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +17 -0
  3. data/README.md +2 -2
  4. data/lib/rack/twilio_webhook_authentication.rb +46 -0
  5. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/local.rb +10 -1
  6. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb +10 -1
  7. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb +10 -1
  8. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb +22 -3
  9. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +3 -1
  10. data/lib/twilio-ruby/rest/client.rb +7 -0
  11. data/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document.rb +417 -0
  12. data/lib/twilio-ruby/rest/preview/hosted_numbers/hosted_number_order.rb +8 -7
  13. data/lib/twilio-ruby/rest/preview/hosted_numbers.rb +16 -0
  14. data/lib/twilio-ruby/rest/preview.rb +9 -0
  15. data/lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb +384 -0
  16. data/lib/twilio-ruby/rest/proxy/v1/service/session/interaction.rb +456 -0
  17. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant/message_interaction.rb +465 -0
  18. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +541 -0
  19. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +578 -0
  20. data/lib/twilio-ruby/rest/proxy/v1/service/short_code.rb +377 -0
  21. data/lib/twilio-ruby/rest/proxy/v1/service.rb +509 -0
  22. data/lib/twilio-ruby/rest/proxy/v1.rb +41 -0
  23. data/lib/twilio-ruby/rest/proxy.rb +44 -0
  24. data/lib/twilio-ruby/rest/wireless/v1/sim.rb +7 -0
  25. data/lib/twilio-ruby/security/request_validator.rb +1 -1
  26. data/lib/twilio-ruby/twiml/messaging_response.rb +5 -5
  27. data/lib/twilio-ruby/twiml/voice_response.rb +9 -7
  28. data/lib/twilio-ruby/util/configuration.rb +0 -3
  29. data/lib/twilio-ruby/version.rb +1 -1
  30. data/lib/twilio-ruby.rb +1 -0
  31. data/spec/integration/api/v2010/account/incoming_phone_number/local_spec.rb +2 -0
  32. data/spec/integration/api/v2010/account/incoming_phone_number/mobile_spec.rb +2 -0
  33. data/spec/integration/api/v2010/account/incoming_phone_number/toll_free_spec.rb +2 -0
  34. data/spec/integration/api/v2010/account/incoming_phone_number_spec.rb +4 -0
  35. data/spec/integration/preview/hosted_numbers/authorization_document_spec.rb +211 -0
  36. data/spec/integration/preview/hosted_numbers/hosted_number_order_spec.rb +35 -4
  37. data/spec/integration/proxy/v1/service/phone_number_spec.rb +176 -0
  38. data/spec/integration/proxy/v1/service/session/interaction_spec.rb +104 -0
  39. data/spec/integration/proxy/v1/service/session/participant/message_interaction_spec.rb +164 -0
  40. data/spec/integration/proxy/v1/service/session/participant_spec.rb +232 -0
  41. data/spec/integration/proxy/v1/service/session_spec.rb +225 -0
  42. data/spec/integration/proxy/v1/service/short_code_spec.rb +173 -0
  43. data/spec/integration/proxy/v1/service_spec.rb +200 -0
  44. data/spec/integration/wireless/v1/sim_spec.rb +6 -3
  45. data/spec/rack/twilio_webhook_authentication_spec.rb +106 -0
  46. data/spec/security/request_validator_spec.rb +28 -0
  47. data/spec/twiml/messaging_response_spec.rb +6 -6
  48. metadata +31 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28600f3f5e0d481da956dbb2220933c52aa949dd
4
- data.tar.gz: 83b9e42f778ae67c4d9d3c7a6690cbabba9de09d
3
+ metadata.gz: 56f7c1583df9eb3ebbfdb20f743dc5e98d500c1c
4
+ data.tar.gz: c7b36ff967128b82901b6a71dc229e79bf548d18
5
5
  SHA512:
6
- metadata.gz: 88883d2d4ba13c23d42d602e8e244d1606b717197cb854a9803a8c6f0da6338c179e6ac55a7f24b9c3965eda91936ccd50e2611acc3653c594c7277134e16ca3
7
- data.tar.gz: 95c16494c7f80f1ce8d22891a81e5fd1fc64e0bb0af5b38f0457a30d21b01be950030fe5b5e7709f80f6cd29d2477ca1e9346c6a440c2f19c0fea932d91c7a3b
6
+ metadata.gz: 7402344a5aad78ed4c7b1b35be18938fd845a8e4bcad2223f83bb2046faa9184d438131a097ab8978bb01e1fafeaaa38aef80cde0fdaffc7301de1469047574d
7
+ data.tar.gz: e29836c18de0a83521123f0f3a4090874575720e792f1332c69c96b36360fb1ab979f9da7f1a7c3261ab79324cdd53926b1505521373c044b583aa24f52d4128
data/CHANGES.md CHANGED
@@ -1,6 +1,23 @@
1
1
  twilio-ruby changelog
2
2
  =====================
3
3
 
4
+ [2017-10-13] Version 5.4.0
5
+ ---------------------------
6
+ **Api**
7
+ - Add `smart_encoded` param for Messages
8
+ - Add `identity_sid` param to IncomingPhoneNumbers create and update
9
+
10
+ **Preview**
11
+ - Make 'address_sid' and 'email' optional fields when creating a HostedNumberOrder
12
+ - Add AuthorizationDocuments preview API.
13
+
14
+ **Proxy**
15
+ - Initial Release
16
+
17
+ **Wireless**
18
+ - Added `ip_address` to sim resource
19
+
20
+
4
21
  [2017-10-06] Version 5.3.1
5
22
  ---------------------------
6
23
  **Preview**
data/README.md CHANGED
@@ -27,13 +27,13 @@ in-line code documentation here in the library.
27
27
  To install using [Bundler][bundler] grab the latest stable version:
28
28
 
29
29
  ```ruby
30
- gem 'twilio-ruby', '~> 5.3.1'
30
+ gem 'twilio-ruby', '~> 5.4.0'
31
31
  ```
32
32
 
33
33
  To manually install `twilio-ruby` via [Rubygems][rubygems] simply gem install:
34
34
 
35
35
  ```bash
36
- gem install twilio-ruby -v 5.3.1
36
+ gem install twilio-ruby -v 5.4.0
37
37
  ```
38
38
 
39
39
  To build and install the development branch yourself from the latest source:
@@ -0,0 +1,46 @@
1
+ module Rack
2
+ # Middleware that authenticates webhooks from Twilio using the request
3
+ # validator.
4
+ #
5
+ # The middleware takes an auth token with which to set up the request
6
+ # validator and any number of paths. When a path matches the incoming request
7
+ # path, the request will be checked for authentication.
8
+ #
9
+ # Example:
10
+ #
11
+ # require 'rack'
12
+ # use Rack::TwilioWebhookAuthentication, ENV['AUTH_TOKEN'], /\/messages/
13
+ #
14
+ # The above appends this middleware to the stack, using an auth token saved in
15
+ # the ENV and only against paths that match /\/messages/. If the request
16
+ # validates then it gets passed on to the action as normal. If the request
17
+ # doesn't validate then the middleware responds immediately with a 403 status.
18
+
19
+ class TwilioWebhookAuthentication
20
+ def initialize(app, auth_token, *paths, &auth_token_lookup)
21
+ @app = app
22
+ @auth_token = auth_token
23
+ define_singleton_method(:get_auth_token, auth_token_lookup) if block_given?
24
+ @path_regex = Regexp.union(paths)
25
+ end
26
+
27
+ def call(env)
28
+ return @app.call(env) unless env['PATH_INFO'].match(@path_regex)
29
+ request = Rack::Request.new(env)
30
+ original_url = request.url
31
+ params = request.post? ? request.POST : {}
32
+ auth_token = @auth_token || get_auth_token(params['AccountSid'])
33
+ validator = Twilio::Security::RequestValidator.new(auth_token)
34
+ signature = env['HTTP_X_TWILIO_SIGNATURE'] || ''
35
+ if validator.validate(original_url, params, signature)
36
+ @app.call(env)
37
+ else
38
+ [
39
+ 403,
40
+ { 'Content-Type' => 'text/plain' },
41
+ ['Twilio Request Validation Failed.']
42
+ ]
43
+ end
44
+ end
45
+ end
46
+ end
@@ -159,8 +159,9 @@ module Twilio
159
159
  # @param [String] voice_fallback_url The voice_fallback_url
160
160
  # @param [String] voice_method The voice_method
161
161
  # @param [String] voice_url The voice_url
162
+ # @param [String] identity_sid The identity_sid
162
163
  # @return [LocalInstance] Newly created LocalInstance
163
- def create(phone_number: nil, api_version: :unset, friendly_name: :unset, sms_application_sid: :unset, sms_fallback_method: :unset, sms_fallback_url: :unset, sms_method: :unset, sms_url: :unset, status_callback: :unset, status_callback_method: :unset, voice_application_sid: :unset, voice_caller_id_lookup: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_url: :unset)
164
+ def create(phone_number: nil, api_version: :unset, friendly_name: :unset, sms_application_sid: :unset, sms_fallback_method: :unset, sms_fallback_url: :unset, sms_method: :unset, sms_url: :unset, status_callback: :unset, status_callback_method: :unset, voice_application_sid: :unset, voice_caller_id_lookup: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_url: :unset, identity_sid: :unset)
164
165
  data = Twilio::Values.of({
165
166
  'PhoneNumber' => phone_number,
166
167
  'ApiVersion' => api_version,
@@ -178,6 +179,7 @@ module Twilio
178
179
  'VoiceFallbackUrl' => voice_fallback_url,
179
180
  'VoiceMethod' => voice_method,
180
181
  'VoiceUrl' => voice_url,
182
+ 'IdentitySid' => identity_sid,
181
183
  })
182
184
 
183
185
  payload = @version.create(
@@ -254,6 +256,7 @@ module Twilio
254
256
  'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
255
257
  'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
256
258
  'friendly_name' => payload['friendly_name'],
259
+ 'identity_sid' => payload['identity_sid'],
257
260
  'phone_number' => payload['phone_number'],
258
261
  'origin' => payload['origin'],
259
262
  'sid' => payload['sid'],
@@ -323,6 +326,12 @@ module Twilio
323
326
  @properties['friendly_name']
324
327
  end
325
328
 
329
+ ##
330
+ # @return [String] The identity_sid
331
+ def identity_sid
332
+ @properties['identity_sid']
333
+ end
334
+
326
335
  ##
327
336
  # @return [String] The phone_number
328
337
  def phone_number
@@ -159,8 +159,9 @@ module Twilio
159
159
  # @param [String] voice_fallback_url The voice_fallback_url
160
160
  # @param [String] voice_method The voice_method
161
161
  # @param [String] voice_url The voice_url
162
+ # @param [String] identity_sid The identity_sid
162
163
  # @return [MobileInstance] Newly created MobileInstance
163
- def create(phone_number: nil, api_version: :unset, friendly_name: :unset, sms_application_sid: :unset, sms_fallback_method: :unset, sms_fallback_url: :unset, sms_method: :unset, sms_url: :unset, status_callback: :unset, status_callback_method: :unset, voice_application_sid: :unset, voice_caller_id_lookup: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_url: :unset)
164
+ def create(phone_number: nil, api_version: :unset, friendly_name: :unset, sms_application_sid: :unset, sms_fallback_method: :unset, sms_fallback_url: :unset, sms_method: :unset, sms_url: :unset, status_callback: :unset, status_callback_method: :unset, voice_application_sid: :unset, voice_caller_id_lookup: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_url: :unset, identity_sid: :unset)
164
165
  data = Twilio::Values.of({
165
166
  'PhoneNumber' => phone_number,
166
167
  'ApiVersion' => api_version,
@@ -178,6 +179,7 @@ module Twilio
178
179
  'VoiceFallbackUrl' => voice_fallback_url,
179
180
  'VoiceMethod' => voice_method,
180
181
  'VoiceUrl' => voice_url,
182
+ 'IdentitySid' => identity_sid,
181
183
  })
182
184
 
183
185
  payload = @version.create(
@@ -254,6 +256,7 @@ module Twilio
254
256
  'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
255
257
  'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
256
258
  'friendly_name' => payload['friendly_name'],
259
+ 'identity_sid' => payload['identity_sid'],
257
260
  'phone_number' => payload['phone_number'],
258
261
  'origin' => payload['origin'],
259
262
  'sid' => payload['sid'],
@@ -323,6 +326,12 @@ module Twilio
323
326
  @properties['friendly_name']
324
327
  end
325
328
 
329
+ ##
330
+ # @return [String] The identity_sid
331
+ def identity_sid
332
+ @properties['identity_sid']
333
+ end
334
+
326
335
  ##
327
336
  # @return [String] The phone_number
328
337
  def phone_number
@@ -159,8 +159,9 @@ module Twilio
159
159
  # @param [String] voice_fallback_url The voice_fallback_url
160
160
  # @param [String] voice_method The voice_method
161
161
  # @param [String] voice_url The voice_url
162
+ # @param [String] identity_sid The identity_sid
162
163
  # @return [TollFreeInstance] Newly created TollFreeInstance
163
- def create(phone_number: nil, api_version: :unset, friendly_name: :unset, sms_application_sid: :unset, sms_fallback_method: :unset, sms_fallback_url: :unset, sms_method: :unset, sms_url: :unset, status_callback: :unset, status_callback_method: :unset, voice_application_sid: :unset, voice_caller_id_lookup: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_url: :unset)
164
+ def create(phone_number: nil, api_version: :unset, friendly_name: :unset, sms_application_sid: :unset, sms_fallback_method: :unset, sms_fallback_url: :unset, sms_method: :unset, sms_url: :unset, status_callback: :unset, status_callback_method: :unset, voice_application_sid: :unset, voice_caller_id_lookup: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_url: :unset, identity_sid: :unset)
164
165
  data = Twilio::Values.of({
165
166
  'PhoneNumber' => phone_number,
166
167
  'ApiVersion' => api_version,
@@ -178,6 +179,7 @@ module Twilio
178
179
  'VoiceFallbackUrl' => voice_fallback_url,
179
180
  'VoiceMethod' => voice_method,
180
181
  'VoiceUrl' => voice_url,
182
+ 'IdentitySid' => identity_sid,
181
183
  })
182
184
 
183
185
  payload = @version.create(
@@ -254,6 +256,7 @@ module Twilio
254
256
  'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
255
257
  'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
256
258
  'friendly_name' => payload['friendly_name'],
259
+ 'identity_sid' => payload['identity_sid'],
257
260
  'phone_number' => payload['phone_number'],
258
261
  'origin' => payload['origin'],
259
262
  'sid' => payload['sid'],
@@ -323,6 +326,12 @@ module Twilio
323
326
  @properties['friendly_name']
324
327
  end
325
328
 
329
+ ##
330
+ # @return [String] The identity_sid
331
+ def identity_sid
332
+ @properties['identity_sid']
333
+ end
334
+
326
335
  ##
327
336
  # @return [String] The phone_number
328
337
  def phone_number
@@ -198,12 +198,15 @@ module Twilio
198
198
  # ignore all of the voice urls and voice applications above and use those set on
199
199
  # the Trunk. Setting a `TrunkSid` will automatically delete your
200
200
  # `VoiceApplicationSid` and vice versa.
201
+ # @param [String] identity_sid The 34 character sid of the identity Twilio should
202
+ # use to associate with the number. Identities are required in some regions to
203
+ # meet local regulations
201
204
  # @param [String] phone_number The phone number to purchase. e.g., +16175551212
202
205
  # (E.164 format)
203
206
  # @param [String] area_code The desired area code for the new phone number. Any
204
207
  # three digit US or Canada rea code is valid
205
208
  # @return [IncomingPhoneNumberInstance] Newly created IncomingPhoneNumberInstance
206
- def create(api_version: :unset, friendly_name: :unset, sms_application_sid: :unset, sms_fallback_method: :unset, sms_fallback_url: :unset, sms_method: :unset, sms_url: :unset, status_callback: :unset, status_callback_method: :unset, voice_application_sid: :unset, voice_caller_id_lookup: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_url: :unset, emergency_status: :unset, emergency_address_sid: :unset, trunk_sid: :unset, phone_number: :unset, area_code: :unset)
209
+ def create(api_version: :unset, friendly_name: :unset, sms_application_sid: :unset, sms_fallback_method: :unset, sms_fallback_url: :unset, sms_method: :unset, sms_url: :unset, status_callback: :unset, status_callback_method: :unset, voice_application_sid: :unset, voice_caller_id_lookup: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_url: :unset, emergency_status: :unset, emergency_address_sid: :unset, trunk_sid: :unset, identity_sid: :unset, phone_number: :unset, area_code: :unset)
207
210
  data = Twilio::Values.of({
208
211
  'PhoneNumber' => phone_number,
209
212
  'AreaCode' => area_code,
@@ -225,6 +228,7 @@ module Twilio
225
228
  'EmergencyStatus' => emergency_status,
226
229
  'EmergencyAddressSid' => emergency_address_sid,
227
230
  'TrunkSid' => trunk_sid,
231
+ 'IdentitySid' => identity_sid,
228
232
  })
229
233
 
230
234
  payload = @version.create(
@@ -386,8 +390,11 @@ module Twilio
386
390
  # `VoiceApplicationSid` and vice versa.
387
391
  # @param [incoming_phone_number.VoiceReceiveMode] voice_receive_mode The
388
392
  # voice_receive_mode
393
+ # @param [String] identity_sid The 34 character sid of the identity Twilio should
394
+ # use to associate with the number. Identities are required in some regions to
395
+ # meet local regulations
389
396
  # @return [IncomingPhoneNumberInstance] Updated IncomingPhoneNumberInstance
390
- def update(account_sid: :unset, api_version: :unset, friendly_name: :unset, sms_application_sid: :unset, sms_fallback_method: :unset, sms_fallback_url: :unset, sms_method: :unset, sms_url: :unset, status_callback: :unset, status_callback_method: :unset, voice_application_sid: :unset, voice_caller_id_lookup: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_url: :unset, emergency_status: :unset, emergency_address_sid: :unset, trunk_sid: :unset, voice_receive_mode: :unset)
397
+ def update(account_sid: :unset, api_version: :unset, friendly_name: :unset, sms_application_sid: :unset, sms_fallback_method: :unset, sms_fallback_url: :unset, sms_method: :unset, sms_url: :unset, status_callback: :unset, status_callback_method: :unset, voice_application_sid: :unset, voice_caller_id_lookup: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_url: :unset, emergency_status: :unset, emergency_address_sid: :unset, trunk_sid: :unset, voice_receive_mode: :unset, identity_sid: :unset)
391
398
  data = Twilio::Values.of({
392
399
  'AccountSid' => account_sid,
393
400
  'ApiVersion' => api_version,
@@ -409,6 +416,7 @@ module Twilio
409
416
  'EmergencyAddressSid' => emergency_address_sid,
410
417
  'TrunkSid' => trunk_sid,
411
418
  'VoiceReceiveMode' => voice_receive_mode,
419
+ 'IdentitySid' => identity_sid,
412
420
  })
413
421
 
414
422
  payload = @version.update(
@@ -510,6 +518,7 @@ module Twilio
510
518
  'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
511
519
  'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
512
520
  'friendly_name' => payload['friendly_name'],
521
+ 'identity_sid' => payload['identity_sid'],
513
522
  'phone_number' => payload['phone_number'],
514
523
  'origin' => payload['origin'],
515
524
  'sid' => payload['sid'],
@@ -603,6 +612,12 @@ module Twilio
603
612
  @properties['friendly_name']
604
613
  end
605
614
 
615
+ ##
616
+ # @return [String] Unique string that identifies the identity associated with number
617
+ def identity_sid
618
+ @properties['identity_sid']
619
+ end
620
+
606
621
  ##
607
622
  # @return [String] The incoming phone number
608
623
  def phone_number
@@ -774,8 +789,11 @@ module Twilio
774
789
  # `VoiceApplicationSid` and vice versa.
775
790
  # @param [incoming_phone_number.VoiceReceiveMode] voice_receive_mode The
776
791
  # voice_receive_mode
792
+ # @param [String] identity_sid The 34 character sid of the identity Twilio should
793
+ # use to associate with the number. Identities are required in some regions to
794
+ # meet local regulations
777
795
  # @return [IncomingPhoneNumberInstance] Updated IncomingPhoneNumberInstance
778
- def update(account_sid: :unset, api_version: :unset, friendly_name: :unset, sms_application_sid: :unset, sms_fallback_method: :unset, sms_fallback_url: :unset, sms_method: :unset, sms_url: :unset, status_callback: :unset, status_callback_method: :unset, voice_application_sid: :unset, voice_caller_id_lookup: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_url: :unset, emergency_status: :unset, emergency_address_sid: :unset, trunk_sid: :unset, voice_receive_mode: :unset)
796
+ def update(account_sid: :unset, api_version: :unset, friendly_name: :unset, sms_application_sid: :unset, sms_fallback_method: :unset, sms_fallback_url: :unset, sms_method: :unset, sms_url: :unset, status_callback: :unset, status_callback_method: :unset, voice_application_sid: :unset, voice_caller_id_lookup: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_url: :unset, emergency_status: :unset, emergency_address_sid: :unset, trunk_sid: :unset, voice_receive_mode: :unset, identity_sid: :unset)
779
797
  context.update(
780
798
  account_sid: account_sid,
781
799
  api_version: api_version,
@@ -797,6 +815,7 @@ module Twilio
797
815
  emergency_address_sid: emergency_address_sid,
798
816
  trunk_sid: trunk_sid,
799
817
  voice_receive_mode: voice_receive_mode,
818
+ identity_sid: identity_sid,
800
819
  )
801
820
  end
802
821
 
@@ -43,13 +43,14 @@ module Twilio
43
43
  # @param [String] provider_sid The provider_sid
44
44
  # @param [message.ContentRetention] content_retention The content_retention
45
45
  # @param [message.AddressRetention] address_retention The address_retention
46
+ # @param [Boolean] smart_encoded The smart_encoded
46
47
  # @param [String] from A Twilio phone number or alphanumeric sender ID enabled for
47
48
  # the type of message you wish to send.
48
49
  # @param [String] messaging_service_sid The messaging_service_sid
49
50
  # @param [String] body The body
50
51
  # @param [String] media_url The media_url
51
52
  # @return [MessageInstance] Newly created MessageInstance
52
- def create(to: nil, status_callback: :unset, application_sid: :unset, max_price: :unset, provide_feedback: :unset, validity_period: :unset, max_rate: :unset, force_delivery: :unset, provider_sid: :unset, content_retention: :unset, address_retention: :unset, from: :unset, messaging_service_sid: :unset, body: :unset, media_url: :unset)
53
+ def create(to: nil, status_callback: :unset, application_sid: :unset, max_price: :unset, provide_feedback: :unset, validity_period: :unset, max_rate: :unset, force_delivery: :unset, provider_sid: :unset, content_retention: :unset, address_retention: :unset, smart_encoded: :unset, from: :unset, messaging_service_sid: :unset, body: :unset, media_url: :unset)
53
54
  data = Twilio::Values.of({
54
55
  'To' => to,
55
56
  'From' => from,
@@ -66,6 +67,7 @@ module Twilio
66
67
  'ProviderSid' => provider_sid,
67
68
  'ContentRetention' => content_retention,
68
69
  'AddressRetention' => address_retention,
70
+ 'SmartEncoded' => smart_encoded,
69
71
  })
70
72
 
71
73
  payload = @version.create(
@@ -33,6 +33,7 @@ module Twilio
33
33
  @notify = nil
34
34
  @preview = nil
35
35
  @pricing = nil
36
+ @proxy = nil
36
37
  @taskrouter = nil
37
38
  @trunking = nil
38
39
  @video = nil
@@ -140,6 +141,12 @@ module Twilio
140
141
  @pricing ||= Pricing.new self
141
142
  end
142
143
 
144
+ ##
145
+ # Access the Proxy Twilio Domain
146
+ def proxy
147
+ @proxy ||= Proxy.new self
148
+ end
149
+
143
150
  ##
144
151
  # Access the Taskrouter Twilio Domain
145
152
  def taskrouter
@@ -0,0 +1,417 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Preview < Domain
10
+ class HostedNumbers < Version
11
+ ##
12
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
13
+ class AuthorizationDocumentList < ListResource
14
+ ##
15
+ # Initialize the AuthorizationDocumentList
16
+ # @param [Version] version Version that contains the resource
17
+ # @return [AuthorizationDocumentList] AuthorizationDocumentList
18
+ def initialize(version)
19
+ super(version)
20
+
21
+ # Path Solution
22
+ @solution = {}
23
+ @uri = "/AuthorizationDocuments"
24
+ end
25
+
26
+ ##
27
+ # Lists AuthorizationDocumentInstance records from the API as a list.
28
+ # Unlike stream(), this operation is eager and will load `limit` records into
29
+ # memory before returning.
30
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
31
+ # guarantees to never return more than limit. Default is no limit
32
+ # @param [Integer] page_size Number of records to fetch per request, when
33
+ # not set will use the default value of 50 records. If no page_size is defined
34
+ # but a limit is defined, stream() will attempt to read the limit with the most
35
+ # efficient page size, i.e. min(limit, 1000)
36
+ # @return [Array] Array of up to limit results
37
+ def list(limit: nil, page_size: nil)
38
+ self.stream(
39
+ limit: limit,
40
+ page_size: page_size
41
+ ).entries
42
+ end
43
+
44
+ ##
45
+ # Streams AuthorizationDocumentInstance records from the API as an Enumerable.
46
+ # This operation lazily loads records as efficiently as possible until the limit
47
+ # is reached.
48
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
49
+ # guarantees to never return more than limit. Default is no limit.
50
+ # @param [Integer] page_size Number of records to fetch per request, when
51
+ # not set will use the default value of 50 records. If no page_size is defined
52
+ # but a limit is defined, stream() will attempt to read the limit with the most
53
+ # efficient page size, i.e. min(limit, 1000)
54
+ # @return [Enumerable] Enumerable that will yield up to limit results
55
+ def stream(limit: nil, page_size: nil)
56
+ limits = @version.read_limits(limit, page_size)
57
+
58
+ page = self.page(
59
+ page_size: limits[:page_size],
60
+ )
61
+
62
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
63
+ end
64
+
65
+ ##
66
+ # When passed a block, yields AuthorizationDocumentInstance records from the API.
67
+ # This operation lazily loads records as efficiently as possible until the limit
68
+ # is reached.
69
+ def each
70
+ limits = @version.read_limits
71
+
72
+ page = self.page(
73
+ page_size: limits[:page_size],
74
+ )
75
+
76
+ @version.stream(page,
77
+ limit: limits[:limit],
78
+ page_limit: limits[:page_limit]).each {|x| yield x}
79
+ end
80
+
81
+ ##
82
+ # Retrieve a single page of AuthorizationDocumentInstance records from the API.
83
+ # Request is executed immediately.
84
+ # @param [String] page_token PageToken provided by the API
85
+ # @param [Integer] page_number Page Number, this value is simply for client state
86
+ # @param [Integer] page_size Number of records to return, defaults to 50
87
+ # @return [Page] Page of AuthorizationDocumentInstance
88
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
89
+ params = Twilio::Values.of({
90
+ 'PageToken' => page_token,
91
+ 'Page' => page_number,
92
+ 'PageSize' => page_size,
93
+ })
94
+ response = @version.page(
95
+ 'GET',
96
+ @uri,
97
+ params
98
+ )
99
+ AuthorizationDocumentPage.new(@version, response, @solution)
100
+ end
101
+
102
+ ##
103
+ # Retrieve a single page of AuthorizationDocumentInstance records from the API.
104
+ # Request is executed immediately.
105
+ # @param [String] target_url API-generated URL for the requested results page
106
+ # @return [Page] Page of AuthorizationDocumentInstance
107
+ def get_page(target_url)
108
+ response = @version.domain.request(
109
+ 'GET',
110
+ target_url
111
+ )
112
+ AuthorizationDocumentPage.new(@version, response, @solution)
113
+ end
114
+
115
+ ##
116
+ # Retrieve a single page of AuthorizationDocumentInstance records from the API.
117
+ # Request is executed immediately.
118
+ # @param [String] hosted_number_order_sids A list of HostedNumberOrder sids that
119
+ # this AuthorizationDocument will authorize for hosting phone number capabilities
120
+ # on Twilio's platform.
121
+ # @param [String] address_sid A 34 character string that uniquely identifies the
122
+ # Address resource that is associated with this AuthorizationDocument.
123
+ # @param [String] email Email that this AuthorizationDocument will be sent to for
124
+ # signing.
125
+ # @param [String] cc_emails A list of emails that this AuthorizationDocument will
126
+ # be carbon copied to.
127
+ # @return [AuthorizationDocumentInstance] Newly created AuthorizationDocumentInstance
128
+ def create(hosted_number_order_sids: nil, address_sid: nil, email: nil, cc_emails: :unset)
129
+ data = Twilio::Values.of({
130
+ 'HostedNumberOrderSids' => hosted_number_order_sids,
131
+ 'AddressSid' => address_sid,
132
+ 'Email' => email,
133
+ 'CcEmails' => cc_emails,
134
+ })
135
+
136
+ payload = @version.create(
137
+ 'POST',
138
+ @uri,
139
+ data: data
140
+ )
141
+
142
+ AuthorizationDocumentInstance.new(
143
+ @version,
144
+ payload,
145
+ )
146
+ end
147
+
148
+ ##
149
+ # Provide a user friendly representation
150
+ def to_s
151
+ '#<Twilio.Preview.HostedNumbers.AuthorizationDocumentList>'
152
+ end
153
+ end
154
+
155
+ ##
156
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
157
+ class AuthorizationDocumentPage < Page
158
+ ##
159
+ # Initialize the AuthorizationDocumentPage
160
+ # @param [Version] version Version that contains the resource
161
+ # @param [Response] response Response from the API
162
+ # @param [Hash] solution Path solution for the resource
163
+ # @return [AuthorizationDocumentPage] AuthorizationDocumentPage
164
+ def initialize(version, response, solution)
165
+ super(version, response)
166
+
167
+ # Path Solution
168
+ @solution = solution
169
+ end
170
+
171
+ ##
172
+ # Build an instance of AuthorizationDocumentInstance
173
+ # @param [Hash] payload Payload response from the API
174
+ # @return [AuthorizationDocumentInstance] AuthorizationDocumentInstance
175
+ def get_instance(payload)
176
+ AuthorizationDocumentInstance.new(
177
+ @version,
178
+ payload,
179
+ )
180
+ end
181
+
182
+ ##
183
+ # Provide a user friendly representation
184
+ def to_s
185
+ '<Twilio.Preview.HostedNumbers.AuthorizationDocumentPage>'
186
+ end
187
+ end
188
+
189
+ ##
190
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
191
+ class AuthorizationDocumentContext < InstanceContext
192
+ ##
193
+ # Initialize the AuthorizationDocumentContext
194
+ # @param [Version] version Version that contains the resource
195
+ # @param [String] sid A 34 character string that uniquely identifies this
196
+ # AuthorizationDocument.
197
+ # @return [AuthorizationDocumentContext] AuthorizationDocumentContext
198
+ def initialize(version, sid)
199
+ super(version)
200
+
201
+ # Path Solution
202
+ @solution = {
203
+ sid: sid,
204
+ }
205
+ @uri = "/AuthorizationDocuments/#{@solution[:sid]}"
206
+ end
207
+
208
+ ##
209
+ # Fetch a AuthorizationDocumentInstance
210
+ # @return [AuthorizationDocumentInstance] Fetched AuthorizationDocumentInstance
211
+ def fetch
212
+ params = Twilio::Values.of({})
213
+
214
+ payload = @version.fetch(
215
+ 'GET',
216
+ @uri,
217
+ params,
218
+ )
219
+
220
+ AuthorizationDocumentInstance.new(
221
+ @version,
222
+ payload,
223
+ sid: @solution[:sid],
224
+ )
225
+ end
226
+
227
+ ##
228
+ # Update the AuthorizationDocumentInstance
229
+ # @param [String] hosted_number_order_sids A list of HostedNumberOrder sids that
230
+ # this AuthorizationDocument will authorize for hosting phone number capabilities
231
+ # on Twilio's platform.
232
+ # @param [String] address_sid A 34 character string that uniquely identifies the
233
+ # Address resource that is associated with this AuthorizationDocument.
234
+ # @param [String] email Email that this AuthorizationDocument will be sent to for
235
+ # signing.
236
+ # @param [String] cc_emails A list of emails that this AuthorizationDocument will
237
+ # be carbon copied to.
238
+ # @param [authorization_document.Status] status The Status of this
239
+ # AuthorizationDocument. User can only update this to `opened` when
240
+ # AuthorizationDocument is in `signing`, or `signing` when AuthorizationDocument
241
+ # is in `opened`.
242
+ # @return [AuthorizationDocumentInstance] Updated AuthorizationDocumentInstance
243
+ def update(hosted_number_order_sids: :unset, address_sid: :unset, email: :unset, cc_emails: :unset, status: :unset)
244
+ data = Twilio::Values.of({
245
+ 'HostedNumberOrderSids' => hosted_number_order_sids,
246
+ 'AddressSid' => address_sid,
247
+ 'Email' => email,
248
+ 'CcEmails' => cc_emails,
249
+ 'Status' => status,
250
+ })
251
+
252
+ payload = @version.update(
253
+ 'POST',
254
+ @uri,
255
+ data: data,
256
+ )
257
+
258
+ AuthorizationDocumentInstance.new(
259
+ @version,
260
+ payload,
261
+ sid: @solution[:sid],
262
+ )
263
+ end
264
+
265
+ ##
266
+ # Provide a user friendly representation
267
+ def to_s
268
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
269
+ "#<Twilio.Preview.HostedNumbers.AuthorizationDocumentContext #{context}>"
270
+ end
271
+ end
272
+
273
+ ##
274
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
275
+ class AuthorizationDocumentInstance < InstanceResource
276
+ ##
277
+ # Initialize the AuthorizationDocumentInstance
278
+ # @param [Version] version Version that contains the resource
279
+ # @param [Hash] payload payload that contains response from Twilio
280
+ # @param [String] sid A 34 character string that uniquely identifies this
281
+ # AuthorizationDocument.
282
+ # @return [AuthorizationDocumentInstance] AuthorizationDocumentInstance
283
+ def initialize(version, payload, sid: nil)
284
+ super(version)
285
+
286
+ # Marshaled Properties
287
+ @properties = {
288
+ 'sid' => payload['sid'],
289
+ 'address_sid' => payload['address_sid'],
290
+ 'status' => payload['status'],
291
+ 'email' => payload['email'],
292
+ 'cc_emails' => payload['cc_emails'],
293
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
294
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
295
+ 'url' => payload['url'],
296
+ }
297
+
298
+ # Context
299
+ @instance_context = nil
300
+ @params = {
301
+ 'sid' => sid || @properties['sid'],
302
+ }
303
+ end
304
+
305
+ ##
306
+ # Generate an instance context for the instance, the context is capable of
307
+ # performing various actions. All instance actions are proxied to the context
308
+ # @return [AuthorizationDocumentContext] AuthorizationDocumentContext for this AuthorizationDocumentInstance
309
+ def context
310
+ unless @instance_context
311
+ @instance_context = AuthorizationDocumentContext.new(
312
+ @version,
313
+ @params['sid'],
314
+ )
315
+ end
316
+ @instance_context
317
+ end
318
+
319
+ ##
320
+ # @return [String] AuthorizationDocument sid.
321
+ def sid
322
+ @properties['sid']
323
+ end
324
+
325
+ ##
326
+ # @return [String] Address sid.
327
+ def address_sid
328
+ @properties['address_sid']
329
+ end
330
+
331
+ ##
332
+ # @return [authorization_document.Status] The Status of this AuthorizationDocument.
333
+ def status
334
+ @properties['status']
335
+ end
336
+
337
+ ##
338
+ # @return [String] Email.
339
+ def email
340
+ @properties['email']
341
+ end
342
+
343
+ ##
344
+ # @return [String] A list of emails.
345
+ def cc_emails
346
+ @properties['cc_emails']
347
+ end
348
+
349
+ ##
350
+ # @return [Time] The date this AuthorizationDocument was created.
351
+ def date_created
352
+ @properties['date_created']
353
+ end
354
+
355
+ ##
356
+ # @return [Time] The date this AuthorizationDocument was updated.
357
+ def date_updated
358
+ @properties['date_updated']
359
+ end
360
+
361
+ ##
362
+ # @return [String] The url
363
+ def url
364
+ @properties['url']
365
+ end
366
+
367
+ ##
368
+ # Fetch a AuthorizationDocumentInstance
369
+ # @return [AuthorizationDocumentInstance] Fetched AuthorizationDocumentInstance
370
+ def fetch
371
+ context.fetch
372
+ end
373
+
374
+ ##
375
+ # Update the AuthorizationDocumentInstance
376
+ # @param [String] hosted_number_order_sids A list of HostedNumberOrder sids that
377
+ # this AuthorizationDocument will authorize for hosting phone number capabilities
378
+ # on Twilio's platform.
379
+ # @param [String] address_sid A 34 character string that uniquely identifies the
380
+ # Address resource that is associated with this AuthorizationDocument.
381
+ # @param [String] email Email that this AuthorizationDocument will be sent to for
382
+ # signing.
383
+ # @param [String] cc_emails A list of emails that this AuthorizationDocument will
384
+ # be carbon copied to.
385
+ # @param [authorization_document.Status] status The Status of this
386
+ # AuthorizationDocument. User can only update this to `opened` when
387
+ # AuthorizationDocument is in `signing`, or `signing` when AuthorizationDocument
388
+ # is in `opened`.
389
+ # @return [AuthorizationDocumentInstance] Updated AuthorizationDocumentInstance
390
+ def update(hosted_number_order_sids: :unset, address_sid: :unset, email: :unset, cc_emails: :unset, status: :unset)
391
+ context.update(
392
+ hosted_number_order_sids: hosted_number_order_sids,
393
+ address_sid: address_sid,
394
+ email: email,
395
+ cc_emails: cc_emails,
396
+ status: status,
397
+ )
398
+ end
399
+
400
+ ##
401
+ # Provide a user friendly representation
402
+ def to_s
403
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
404
+ "<Twilio.Preview.HostedNumbers.AuthorizationDocumentInstance #{values}>"
405
+ end
406
+
407
+ ##
408
+ # Provide a detailed, user friendly representation
409
+ def inspect
410
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
411
+ "<Twilio.Preview.HostedNumbers.AuthorizationDocumentInstance #{values}>"
412
+ end
413
+ end
414
+ end
415
+ end
416
+ end
417
+ end