twilio-ruby 5.21.2 → 5.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +13 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +2 -6
  5. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +3 -1
  6. data/lib/twilio-ruby/rest/api/v2010/account/queue/member.rb +15 -9
  7. data/lib/twilio-ruby/rest/api/v2010/account/queue.rb +7 -0
  8. data/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list/credential.rb +5 -5
  9. data/lib/twilio-ruby/rest/lookups/v1/phone_number.rb +47 -43
  10. data/lib/twilio-ruby/rest/lookups/v1.rb +3 -1
  11. data/lib/twilio-ruby/rest/lookups.rb +3 -3
  12. data/lib/twilio-ruby/rest/messaging/v1/session/webhook.rb +448 -0
  13. data/lib/twilio-ruby/rest/messaging/v1/session.rb +26 -0
  14. data/lib/twilio-ruby/rest/messaging/v1/webhook.rb +15 -2
  15. data/lib/twilio-ruby/rest/pricing/v1/messaging/country.rb +11 -7
  16. data/lib/twilio-ruby/rest/pricing/v1/messaging.rb +3 -1
  17. data/lib/twilio-ruby/rest/pricing/v1/phone_number/country.rb +11 -7
  18. data/lib/twilio-ruby/rest/pricing/v1/phone_number.rb +3 -1
  19. data/lib/twilio-ruby/rest/pricing/v1/voice/country.rb +11 -7
  20. data/lib/twilio-ruby/rest/pricing/v1/voice/number.rb +8 -8
  21. data/lib/twilio-ruby/rest/pricing/v1/voice.rb +4 -2
  22. data/lib/twilio-ruby/rest/pricing/v2/voice/country.rb +11 -9
  23. data/lib/twilio-ruby/rest/pricing/v2/voice/number.rb +23 -13
  24. data/lib/twilio-ruby/rest/pricing/v2/voice.rb +10 -7
  25. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb +1 -1
  26. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +343 -0
  27. data/lib/twilio-ruby/rest/verify/v2/service/verification_check.rb +209 -0
  28. data/lib/twilio-ruby/rest/verify/v2/service.rb +507 -0
  29. data/lib/twilio-ruby/rest/verify/v2.rb +43 -0
  30. data/lib/twilio-ruby/rest/verify.rb +10 -3
  31. data/lib/twilio-ruby/rest/voice/v1/{voice_permission → dialing_permissions}/bulk_country_update.rb +1 -1
  32. data/lib/twilio-ruby/rest/voice/v1/{voice_permission → dialing_permissions}/country/highrisk_special_prefix.rb +1 -1
  33. data/lib/twilio-ruby/rest/voice/v1/{voice_permission → dialing_permissions}/country.rb +1 -1
  34. data/lib/twilio-ruby/rest/voice/v1/{voice_permission → dialing_permissions}/settings.rb +1 -1
  35. data/lib/twilio-ruby/rest/voice/v1/{voice_permission.rb → dialing_permissions.rb} +16 -16
  36. data/lib/twilio-ruby/rest/voice/v1.rb +4 -4
  37. data/lib/twilio-ruby/rest/voice.rb +3 -3
  38. data/lib/twilio-ruby/rest/wireless/v1/sim.rb +15 -2
  39. data/lib/twilio-ruby/version.rb +1 -1
  40. data/spec/integration/api/v2010/account/queue/member_spec.rb +50 -9
  41. data/spec/integration/api/v2010/account/queue_spec.rb +16 -10
  42. data/spec/integration/lookups/v1/phone_number_spec.rb +263 -2
  43. data/spec/integration/messaging/v1/session/webhook_spec.rb +300 -0
  44. data/spec/integration/messaging/v1/session_spec.rb +8 -4
  45. data/spec/integration/messaging/v1/webhook_spec.rb +2 -0
  46. data/spec/integration/verify/v2/service/verification_check_spec.rb +54 -0
  47. data/spec/integration/verify/v2/service/verification_spec.rb +169 -0
  48. data/spec/integration/verify/v2/service_spec.rb +231 -0
  49. data/spec/integration/voice/v1/{voice_permission → dialing_permissions}/bulk_country_update_spec.rb +2 -2
  50. data/spec/integration/voice/v1/{voice_permission → dialing_permissions}/country/highrisk_special_prefix_spec.rb +3 -3
  51. data/spec/integration/voice/v1/{voice_permission → dialing_permissions}/country_spec.rb +4 -4
  52. data/spec/integration/voice/v1/{voice_permission → dialing_permissions}/settings_spec.rb +4 -4
  53. data/spec/integration/voice/v1/{voice_permission_spec.rb → dialing_permissions_spec.rb} +1 -1
  54. data/spec/integration/wireless/v1/sim_spec.rb +3 -0
  55. metadata +31 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad3aa9bdc412dd96cc0b81e055d21cebb066bd4cd373e8d6e81073a5b190abc2
4
- data.tar.gz: 1e613a2b3905866dd111eab5f637b199f0ecac111870ff8b57abe9fcbc1568a2
3
+ metadata.gz: 2caa3e357ecf1b95218e2dd30cac8d6fec3e80bc9344f8cf6d0d33c5d3b3f0ca
4
+ data.tar.gz: d63ebd00ecbf0fd5216581baaf6ef70099bb0368a1e54e5303253530ef933925
5
5
  SHA512:
6
- metadata.gz: 141bc5a13272f67e640c5c70a46ab38d8e37f5bcca2d0c092a034841250e442c7ea0bca7cb159d6eada054f6a562eab34a1223f6944e022e30751daf24c72a63
7
- data.tar.gz: 4c5a19b25aea870391e9b7baddfd7088b0ae3acdbde5ac3b6217a6162ba2995d169bb97a585164bae3fae4bbadbe636ab9f7b7f27febb6542acdad113746f1ad
6
+ metadata.gz: 44a9c25927de36f595007341e16afb056f4b54e324409f156e8116a3639593aee57d515c0374f1381d82867097d6578082021f13212e86b61d6be65693976555
7
+ data.tar.gz: 1a9ed249a0acbf614d781f1daaddcad3d1c1457958c829046d4279bf884ac0c228ba8986e461c5105dbb77c972a53a074ade8bc89729eec7126302d7aa2545a0
data/CHANGES.md CHANGED
@@ -1,6 +1,19 @@
1
1
  twilio-ruby changelog
2
2
  =====================
3
3
 
4
+ [2019-03-28] Version 5.22.0
5
+ ----------------------------
6
+ **Api**
7
+ - Remove optional `if_machine` call create parameter from helper libraries **(breaking change)**
8
+ - Changed `call_sid` path parameter type on QueueMember fetch and update requests **(breaking change)**
9
+
10
+ **Voice**
11
+ - changed file names to dialing_permissions prefix **(breaking change)**
12
+
13
+ **Wireless**
14
+ - Added `ResetStatus` property to Sim resource to allow resetting connectivity via the API.
15
+
16
+
4
17
  [2019-03-15] Version 5.21.2
5
18
  ----------------------------
6
19
  **Library**
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.21.2'
30
+ gem 'twilio-ruby', '~> 5.22.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.21.2
36
+ gem install twilio-ruby -v 5.22.0
37
37
  ```
38
38
 
39
39
  To build and install the development branch yourself from the latest source:
@@ -71,9 +71,6 @@ module Twilio
71
71
  # '`#`' character has special meaning in a URL. If both `SendDigits` and
72
72
  # `MachineDetection` parameters are provided, then `MachineDetection` will be
73
73
  # ignored.
74
- # @param [String] if_machine Deprecated. Tell Twilio to try and determine if a
75
- # machine (like voicemail) or a human has answered the call. Possible value are
76
- # `Continue` and `Hangup`.
77
74
  # @param [String] timeout The integer number of seconds that we should allow the
78
75
  # phone to ring before assuming there is no answer. The default is `60` seconds
79
76
  # and the maximum is `600` seconds. For some call flows, we will add a 5-second
@@ -128,7 +125,7 @@ module Twilio
128
125
  # milliseconds of silence after speech activity at which point the speech activity
129
126
  # is considered complete. Possible Values: 500-5000. Default: 1200.
130
127
  # @param [String] machine_detection_silence_timeout The number of milliseconds of
131
- # initial silence after which an unknown AnsweredBy result will be returned.
128
+ # initial silence after which an `unknown` AnsweredBy result will be returned.
132
129
  # Possible Values: 2000-10000. Default: 5000.
133
130
  # @param [String] url The absolute URL that returns the TwiML instructions for the
134
131
  # call. We will call this URL using the `method` when the call connects. For more
@@ -138,7 +135,7 @@ module Twilio
138
135
  # @param [String] application_sid The SID of the Application resource that will
139
136
  # handle the call, if the call will be handled by an application.
140
137
  # @return [CallInstance] Newly created CallInstance
141
- def create(to: nil, from: nil, method: :unset, fallback_url: :unset, fallback_method: :unset, status_callback: :unset, status_callback_event: :unset, status_callback_method: :unset, send_digits: :unset, if_machine: :unset, timeout: :unset, record: :unset, recording_channels: :unset, recording_status_callback: :unset, recording_status_callback_method: :unset, sip_auth_username: :unset, sip_auth_password: :unset, machine_detection: :unset, machine_detection_timeout: :unset, recording_status_callback_event: :unset, trim: :unset, caller_id: :unset, machine_detection_speech_threshold: :unset, machine_detection_speech_end_threshold: :unset, machine_detection_silence_timeout: :unset, url: :unset, application_sid: :unset)
138
+ def create(to: nil, from: nil, method: :unset, fallback_url: :unset, fallback_method: :unset, status_callback: :unset, status_callback_event: :unset, status_callback_method: :unset, send_digits: :unset, timeout: :unset, record: :unset, recording_channels: :unset, recording_status_callback: :unset, recording_status_callback_method: :unset, sip_auth_username: :unset, sip_auth_password: :unset, machine_detection: :unset, machine_detection_timeout: :unset, recording_status_callback_event: :unset, trim: :unset, caller_id: :unset, machine_detection_speech_threshold: :unset, machine_detection_speech_end_threshold: :unset, machine_detection_silence_timeout: :unset, url: :unset, application_sid: :unset)
142
139
  data = Twilio::Values.of({
143
140
  'To' => to,
144
141
  'From' => from,
@@ -151,7 +148,6 @@ module Twilio
151
148
  'StatusCallbackEvent' => Twilio.serialize_list(status_callback_event) { |e| e },
152
149
  'StatusCallbackMethod' => status_callback_method,
153
150
  'SendDigits' => send_digits,
154
- 'IfMachine' => if_machine,
155
151
  'Timeout' => timeout,
156
152
  'Record' => record,
157
153
  'RecordingChannels' => recording_channels,
@@ -69,6 +69,7 @@ module Twilio
69
69
  # seconds. After a message has been accepted by a carrier, however, we cannot
70
70
  # guarantee that the message will not be queued after this period. We recommend
71
71
  # that this value be at least 5 seconds.
72
+ # @param [Boolean] force_delivery Reserved
72
73
  # @param [Boolean] smart_encoded Whether to detect Unicode characters that have a
73
74
  # similar GSM-7 character and replace them. Can be: `true` or `false`.
74
75
  # @param [String] interactive_data A JSON string that represents an interactive
@@ -99,7 +100,7 @@ module Twilio
99
100
  # can include up to 10 `media_url` parameters per message. You can send images in
100
101
  # an SMS message in only the US and Canada.
101
102
  # @return [MessageInstance] Newly created MessageInstance
102
- def create(to: nil, status_callback: :unset, application_sid: :unset, max_price: :unset, provide_feedback: :unset, validity_period: :unset, smart_encoded: :unset, interactive_data: :unset, force_opt_in: :unset, from: :unset, messaging_service_sid: :unset, body: :unset, media_url: :unset)
103
+ def create(to: nil, status_callback: :unset, application_sid: :unset, max_price: :unset, provide_feedback: :unset, validity_period: :unset, force_delivery: :unset, smart_encoded: :unset, interactive_data: :unset, force_opt_in: :unset, from: :unset, messaging_service_sid: :unset, body: :unset, media_url: :unset)
103
104
  data = Twilio::Values.of({
104
105
  'To' => to,
105
106
  'From' => from,
@@ -111,6 +112,7 @@ module Twilio
111
112
  'MaxPrice' => max_price,
112
113
  'ProvideFeedback' => provide_feedback,
113
114
  'ValidityPeriod' => validity_period,
115
+ 'ForceDelivery' => force_delivery,
114
116
  'SmartEncoded' => smart_encoded,
115
117
  'InteractiveData' => interactive_data,
116
118
  'ForceOptIn' => force_opt_in,
@@ -19,8 +19,7 @@ module Twilio
19
19
  # @param [String] account_sid The SID of the
20
20
  # [Account](https://www.twilio.com/docs/api/rest/account) that created this Queue
21
21
  # resource.
22
- # @param [String] queue_sid The unique string that that we created to identify
23
- # this Queue resource.
22
+ # @param [String] queue_sid The SID of the Queue the member is in.
24
23
  # @return [MemberList] MemberList
25
24
  def initialize(version, account_sid: nil, queue_sid: nil)
26
25
  super(version)
@@ -160,7 +159,8 @@ module Twilio
160
159
  # @param [String] account_sid The SID of the
161
160
  # [Account](https://www.twilio.com/docs/api/rest/account) that created the Member
162
161
  # resource(s) to fetch.
163
- # @param [String] queue_sid The Queue in which to find the members to fetch.
162
+ # @param [String] queue_sid The SID of the Queue in which to find the members to
163
+ # fetch.
164
164
  # @param [String] call_sid The [Call](https://www.twilio.com/docs/api/voice/call)
165
165
  # SID of the resource(s) to fetch.
166
166
  # @return [MemberContext] MemberContext
@@ -195,7 +195,7 @@ module Twilio
195
195
 
196
196
  ##
197
197
  # Update the MemberInstance
198
- # @param [String] url The absolute URL of this Queue resource.
198
+ # @param [String] url The absolute URL of the Queue resource.
199
199
  # @param [String] method How to pass the update request data. Can be `GET` or
200
200
  # `POST` and the default is `POST`. `POST` sends the data as encoded form data and
201
201
  # `GET` sends the data as query parameters.
@@ -241,8 +241,7 @@ module Twilio
241
241
  # @param [String] account_sid The SID of the
242
242
  # [Account](https://www.twilio.com/docs/api/rest/account) that created this Queue
243
243
  # resource.
244
- # @param [String] queue_sid The unique string that that we created to identify
245
- # this Queue resource.
244
+ # @param [String] queue_sid The SID of the Queue the member is in.
246
245
  # @param [String] call_sid The [Call](https://www.twilio.com/docs/api/voice/call)
247
246
  # SID of the resource(s) to fetch.
248
247
  # @return [MemberInstance] MemberInstance
@@ -256,6 +255,7 @@ module Twilio
256
255
  'position' => payload['position'].to_i,
257
256
  'uri' => payload['uri'],
258
257
  'wait_time' => payload['wait_time'].to_i,
258
+ 'queue_sid' => payload['queue_sid'],
259
259
  }
260
260
 
261
261
  # Context
@@ -284,7 +284,7 @@ module Twilio
284
284
  end
285
285
 
286
286
  ##
287
- # @return [String] The SID of the Call this resource is associated with
287
+ # @return [String] The SID of the Call the resource is associated with
288
288
  def call_sid
289
289
  @properties['call_sid']
290
290
  end
@@ -302,7 +302,7 @@ module Twilio
302
302
  end
303
303
 
304
304
  ##
305
- # @return [String] The URI of this resource, relative to `https://api.twilio.com`
305
+ # @return [String] The URI of the resource, relative to `https://api.twilio.com`
306
306
  def uri
307
307
  @properties['uri']
308
308
  end
@@ -313,6 +313,12 @@ module Twilio
313
313
  @properties['wait_time']
314
314
  end
315
315
 
316
+ ##
317
+ # @return [String] The SID of the Queue the member is in
318
+ def queue_sid
319
+ @properties['queue_sid']
320
+ end
321
+
316
322
  ##
317
323
  # Fetch a MemberInstance
318
324
  # @return [MemberInstance] Fetched MemberInstance
@@ -322,7 +328,7 @@ module Twilio
322
328
 
323
329
  ##
324
330
  # Update the MemberInstance
325
- # @param [String] url The absolute URL of this Queue resource.
331
+ # @param [String] url The absolute URL of the Queue resource.
326
332
  # @param [String] method How to pass the update request data. Can be `GET` or
327
333
  # `POST` and the default is `POST`. `POST` sends the data as encoded form data and
328
334
  # `GET` sends the data as query parameters.
@@ -289,6 +289,7 @@ module Twilio
289
289
  'max_size' => payload['max_size'].to_i,
290
290
  'sid' => payload['sid'],
291
291
  'uri' => payload['uri'],
292
+ 'subresource_uris' => payload['subresource_uris'],
292
293
  }
293
294
 
294
295
  # Context
@@ -361,6 +362,12 @@ module Twilio
361
362
  @properties['uri']
362
363
  end
363
364
 
365
+ ##
366
+ # @return [String] Queue Instance Subresources
367
+ def subresource_uris
368
+ @properties['subresource_uris']
369
+ end
370
+
364
371
  ##
365
372
  # Fetch a QueueInstance
366
373
  # @return [QueueInstance] Fetched QueueInstance
@@ -116,11 +116,11 @@ module Twilio
116
116
  # Retrieve a single page of CredentialInstance records from the API.
117
117
  # Request is executed immediately.
118
118
  # @param [String] username The username that will be passed when authenticating
119
- # SIP requests. The username should be sent in response to Twilios challenge of
119
+ # SIP requests. The username should be sent in response to Twilio's challenge of
120
120
  # the initial INVITE. It can be up to 32 characters long.
121
121
  # @param [String] password The password that the username will use when
122
122
  # authenticating SIP requests. The password must be a minimum of 12 characters,
123
- # contain at least 1 digit, and have mixed case. (eg IWasAtSignal2018)
123
+ # contain at least 1 digit, and have mixed case. (eg `IWasAtSignal2018`)
124
124
  # @return [CredentialInstance] Newly created CredentialInstance
125
125
  def create(username: nil, password: nil)
126
126
  data = Twilio::Values.of({'Username' => username, 'Password' => password, })
@@ -223,7 +223,7 @@ module Twilio
223
223
  # Update the CredentialInstance
224
224
  # @param [String] password The password that the username will use when
225
225
  # authenticating SIP requests. The password must be a minimum of 12 characters,
226
- # contain at least 1 digit, and have mixed case. (eg IWasAtSignal2018)
226
+ # contain at least 1 digit, and have mixed case. (eg `IWasAtSignal2018`)
227
227
  # @return [CredentialInstance] Updated CredentialInstance
228
228
  def update(password: :unset)
229
229
  data = Twilio::Values.of({'Password' => password, })
@@ -352,7 +352,7 @@ module Twilio
352
352
  end
353
353
 
354
354
  ##
355
- # @return [String] The URI for this resource, relative to https://api.
355
+ # @return [String] The URI for this resource, relative to https://api.twilio.com
356
356
  def uri
357
357
  @properties['uri']
358
358
  end
@@ -368,7 +368,7 @@ module Twilio
368
368
  # Update the CredentialInstance
369
369
  # @param [String] password The password that the username will use when
370
370
  # authenticating SIP requests. The password must be a minimum of 12 characters,
371
- # contain at least 1 digit, and have mixed case. (eg IWasAtSignal2018)
371
+ # contain at least 1 digit, and have mixed case. (eg `IWasAtSignal2018`)
372
372
  # @return [CredentialInstance] Updated CredentialInstance
373
373
  def update(password: :unset)
374
374
  context.update(password: password, )
@@ -62,7 +62,9 @@ module Twilio
62
62
  ##
63
63
  # Initialize the PhoneNumberContext
64
64
  # @param [Version] version Version that contains the resource
65
- # @param [String] phone_number The phone_number
65
+ # @param [String] phone_number The phone number to lookup in
66
+ # [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists
67
+ # of a + followed by the country code and subscriber number.
66
68
  # @return [PhoneNumberContext] PhoneNumberContext
67
69
  def initialize(version, phone_number)
68
70
  super(version)
@@ -74,23 +76,23 @@ module Twilio
74
76
 
75
77
  ##
76
78
  # Fetch a PhoneNumberInstance
77
- # @param [String] country_code Optional [ISO country
78
- # code](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the phone number. This
79
- # is used to specify the country when the number is provided in a national format.
80
- # @param [String] type Indicates the type of information you would like returned
81
- # with your request. Possible values are `carrier` or `caller-name`. If not
82
- # specified, the default is null. Carrier information costs $0.005 per phone
83
- # number looked up. Caller Name information costs $0.01 per phone number looked
84
- # up, and is currently ONLY available in the US. You can retrieve both types of
85
- # information by including two `Type` arguments or making two separate requests.
86
- # @param [String] add_ons Indicates the particular Add-on you would like to use to
87
- # get more information. Possible values are the *Add-on Unique Names* of Add-ons
88
- # installed on your account. You can specify multiple instances of this parameter
89
- # to invoke different Add-ons. See [Add-ons
90
- # documentation](https://www.twilio.com/docs/api/addons) for information on
91
- # installing Add-ons. Add-on pricing is available in your list of Installed
92
- # Add-ons in the Console.
93
- # @param [Hash] add_ons_data The add_ons_data
79
+ # @param [String] country_code The [ISO country
80
+ # code](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the phone number to
81
+ # fetch. This is used to specify the country when the phone number is provided in
82
+ # a national format.
83
+ # @param [String] type The type of information to return. Can be: `carrier` or
84
+ # `caller-name`. The default is null. Carrier information costs $0.005 per phone
85
+ # number looked up. Caller Name information is currently available only in the US
86
+ # and costs $0.01 per phone number looked up. To retrieve both types on
87
+ # information, specify this parameter twice; once with `carrier` and once with
88
+ # `caller-name` as the value.
89
+ # @param [String] add_ons The `unique_name` of an Add-on you would like to invoke.
90
+ # Can be the `unique_name` of an Add-on that is installed on your account. You can
91
+ # specify multiple instances of this parameter to invoke multiple Add-ons. For
92
+ # more information about Add-ons, see the [Add-ons
93
+ # documentation](https://www.twilio.com/docs/api/addons).
94
+ # @param [Hash] add_ons_data Data specific to the add-on you would like to invoke.
95
+ # The content and format of this value depends on the add-on.
94
96
  # @return [PhoneNumberInstance] Fetched PhoneNumberInstance
95
97
  def fetch(country_code: :unset, type: :unset, add_ons: :unset, add_ons_data: :unset)
96
98
  params = Twilio::Values.of({
@@ -129,7 +131,9 @@ module Twilio
129
131
  # Initialize the PhoneNumberInstance
130
132
  # @param [Version] version Version that contains the resource
131
133
  # @param [Hash] payload payload that contains response from Twilio
132
- # @param [String] phone_number The phone_number
134
+ # @param [String] phone_number The phone number to lookup in
135
+ # [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists
136
+ # of a + followed by the country code and subscriber number.
133
137
  # @return [PhoneNumberInstance] PhoneNumberInstance
134
138
  def initialize(version, payload, phone_number: nil)
135
139
  super(version)
@@ -162,66 +166,66 @@ module Twilio
162
166
  end
163
167
 
164
168
  ##
165
- # @return [String] String indicating the name of the owner of the phone number.
169
+ # @return [String] The name of the phone number's owner
166
170
  def caller_name
167
171
  @properties['caller_name']
168
172
  end
169
173
 
170
174
  ##
171
- # @return [String] The ISO country code for the phone number.
175
+ # @return [String] The ISO country code for the phone number
172
176
  def country_code
173
177
  @properties['country_code']
174
178
  end
175
179
 
176
180
  ##
177
- # @return [String] The phone number, in E.
181
+ # @return [String] The phone number in E.164 format
178
182
  def phone_number
179
183
  @properties['phone_number']
180
184
  end
181
185
 
182
186
  ##
183
- # @return [String] The phone number, in national format.
187
+ # @return [String] The phone number, in national format
184
188
  def national_format
185
189
  @properties['national_format']
186
190
  end
187
191
 
188
192
  ##
189
- # @return [String] The carrier
193
+ # @return [String] The telecom company that provides the phone number
190
194
  def carrier
191
195
  @properties['carrier']
192
196
  end
193
197
 
194
198
  ##
195
- # @return [Hash] Results of any Add-ons you have specified using the AddOn parameter in the request, as a JSON dictionary.
199
+ # @return [Hash] A JSON string with the results of the Add-ons you specified
196
200
  def add_ons
197
201
  @properties['add_ons']
198
202
  end
199
203
 
200
204
  ##
201
- # @return [String] The url
205
+ # @return [String] The absolute URL of the resource
202
206
  def url
203
207
  @properties['url']
204
208
  end
205
209
 
206
210
  ##
207
211
  # Fetch a PhoneNumberInstance
208
- # @param [String] country_code Optional [ISO country
209
- # code](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the phone number. This
210
- # is used to specify the country when the number is provided in a national format.
211
- # @param [String] type Indicates the type of information you would like returned
212
- # with your request. Possible values are `carrier` or `caller-name`. If not
213
- # specified, the default is null. Carrier information costs $0.005 per phone
214
- # number looked up. Caller Name information costs $0.01 per phone number looked
215
- # up, and is currently ONLY available in the US. You can retrieve both types of
216
- # information by including two `Type` arguments or making two separate requests.
217
- # @param [String] add_ons Indicates the particular Add-on you would like to use to
218
- # get more information. Possible values are the *Add-on Unique Names* of Add-ons
219
- # installed on your account. You can specify multiple instances of this parameter
220
- # to invoke different Add-ons. See [Add-ons
221
- # documentation](https://www.twilio.com/docs/api/addons) for information on
222
- # installing Add-ons. Add-on pricing is available in your list of Installed
223
- # Add-ons in the Console.
224
- # @param [Hash] add_ons_data The add_ons_data
212
+ # @param [String] country_code The [ISO country
213
+ # code](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the phone number to
214
+ # fetch. This is used to specify the country when the phone number is provided in
215
+ # a national format.
216
+ # @param [String] type The type of information to return. Can be: `carrier` or
217
+ # `caller-name`. The default is null. Carrier information costs $0.005 per phone
218
+ # number looked up. Caller Name information is currently available only in the US
219
+ # and costs $0.01 per phone number looked up. To retrieve both types on
220
+ # information, specify this parameter twice; once with `carrier` and once with
221
+ # `caller-name` as the value.
222
+ # @param [String] add_ons The `unique_name` of an Add-on you would like to invoke.
223
+ # Can be the `unique_name` of an Add-on that is installed on your account. You can
224
+ # specify multiple instances of this parameter to invoke multiple Add-ons. For
225
+ # more information about Add-ons, see the [Add-ons
226
+ # documentation](https://www.twilio.com/docs/api/addons).
227
+ # @param [Hash] add_ons_data Data specific to the add-on you would like to invoke.
228
+ # The content and format of this value depends on the add-on.
225
229
  # @return [PhoneNumberInstance] Fetched PhoneNumberInstance
226
230
  def fetch(country_code: :unset, type: :unset, add_ons: :unset, add_ons_data: :unset)
227
231
  context.fetch(country_code: country_code, type: type, add_ons: add_ons, add_ons_data: add_ons_data, )
@@ -19,7 +19,9 @@ module Twilio
19
19
  end
20
20
 
21
21
  ##
22
- # @param [String] phone_number The phone_number
22
+ # @param [String] phone_number The phone number to lookup in
23
+ # [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists
24
+ # of a + followed by the country code and subscriber number.
23
25
  # @return [Twilio::REST::Lookups::V1::PhoneNumberContext] if phone_number was passed.
24
26
  # @return [Twilio::REST::Lookups::V1::PhoneNumberList]
25
27
  def phone_numbers(phone_number=:unset)
@@ -29,9 +29,9 @@ module Twilio
29
29
  end
30
30
 
31
31
  ##
32
- # @param [String] phone_number The phone number, in
33
- # [E.164](https://www.twilio.com/docs/api/rest/response#phone-numbers) format
34
- # (i.e. "+1").
32
+ # @param [String] phone_number The phone number in
33
+ # [E.164](https://www.twilio.com/docs/glossary/what-e164) format, which consists
34
+ # of a + followed by the country code and subscriber number.
35
35
  # @return [Twilio::REST::Lookups::V1::PhoneNumberInstance] if phone_number was passed.
36
36
  # @return [Twilio::REST::Lookups::V1::PhoneNumberList]
37
37
  def phone_numbers(phone_number=:unset)
@@ -0,0 +1,448 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+ #
7
+ # frozen_string_literal: true
8
+
9
+ module Twilio
10
+ module REST
11
+ class Messaging < Domain
12
+ class V1 < Version
13
+ class SessionContext < InstanceContext
14
+ ##
15
+ # 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.
16
+ class WebhookList < ListResource
17
+ ##
18
+ # Initialize the WebhookList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] session_sid The unique id of the
21
+ # [Session](https://www.twilio.com/docs/sessions/api/session) for this webhook.
22
+ # @return [WebhookList] WebhookList
23
+ def initialize(version, session_sid: nil)
24
+ super(version)
25
+
26
+ # Path Solution
27
+ @solution = {session_sid: session_sid}
28
+ @uri = "/Sessions/#{@solution[:session_sid]}/Webhooks"
29
+ end
30
+
31
+ ##
32
+ # Lists WebhookInstance records from the API as a list.
33
+ # Unlike stream(), this operation is eager and will load `limit` records into
34
+ # memory before returning.
35
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
36
+ # guarantees to never return more than limit. Default is no limit
37
+ # @param [Integer] page_size Number of records to fetch per request, when
38
+ # not set will use the default value of 50 records. If no page_size is defined
39
+ # but a limit is defined, stream() will attempt to read the limit with the most
40
+ # efficient page size, i.e. min(limit, 1000)
41
+ # @return [Array] Array of up to limit results
42
+ def list(limit: nil, page_size: nil)
43
+ self.stream(limit: limit, page_size: page_size).entries
44
+ end
45
+
46
+ ##
47
+ # Streams WebhookInstance records from the API as an Enumerable.
48
+ # This operation lazily loads records as efficiently as possible until the limit
49
+ # is reached.
50
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
51
+ # guarantees to never return more than limit. Default is no limit.
52
+ # @param [Integer] page_size Number of records to fetch per request, when
53
+ # not set will use the default value of 50 records. If no page_size is defined
54
+ # but a limit is defined, stream() will attempt to read the limit with the most
55
+ # efficient page size, i.e. min(limit, 1000)
56
+ # @return [Enumerable] Enumerable that will yield up to limit results
57
+ def stream(limit: nil, page_size: nil)
58
+ limits = @version.read_limits(limit, page_size)
59
+
60
+ page = self.page(page_size: limits[:page_size], )
61
+
62
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
63
+ end
64
+
65
+ ##
66
+ # When passed a block, yields WebhookInstance 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(page_size: limits[:page_size], )
73
+
74
+ @version.stream(page,
75
+ limit: limits[:limit],
76
+ page_limit: limits[:page_limit]).each {|x| yield x}
77
+ end
78
+
79
+ ##
80
+ # Retrieve a single page of WebhookInstance records from the API.
81
+ # Request is executed immediately.
82
+ # @param [String] page_token PageToken provided by the API
83
+ # @param [Integer] page_number Page Number, this value is simply for client state
84
+ # @param [Integer] page_size Number of records to return, defaults to 50
85
+ # @return [Page] Page of WebhookInstance
86
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
87
+ params = Twilio::Values.of({
88
+ 'PageToken' => page_token,
89
+ 'Page' => page_number,
90
+ 'PageSize' => page_size,
91
+ })
92
+ response = @version.page(
93
+ 'GET',
94
+ @uri,
95
+ params
96
+ )
97
+ WebhookPage.new(@version, response, @solution)
98
+ end
99
+
100
+ ##
101
+ # Retrieve a single page of WebhookInstance records from the API.
102
+ # Request is executed immediately.
103
+ # @param [String] target_url API-generated URL for the requested results page
104
+ # @return [Page] Page of WebhookInstance
105
+ def get_page(target_url)
106
+ response = @version.domain.request(
107
+ 'GET',
108
+ target_url
109
+ )
110
+ WebhookPage.new(@version, response, @solution)
111
+ end
112
+
113
+ ##
114
+ # Retrieve a single page of WebhookInstance records from the API.
115
+ # Request is executed immediately.
116
+ # @param [webhook.Target] target The target of this webhook.
117
+ # @param [String] configuration_url The absolute url the webhook request should be
118
+ # sent to.
119
+ # @param [webhook.Method] configuration_method The HTTP method to be used when
120
+ # sending a webhook request.
121
+ # @param [String] configuration_filters The list of events, firing webhook event
122
+ # for this Session.
123
+ # @param [String] configuration_triggers The list of keywords, firing webhook
124
+ # event for this Session.
125
+ # @param [String] configuration_flow_sid The studio flow sid, where the webhook
126
+ # should be sent to.
127
+ # @param [String] configuration_retry_count The number of retries in case of
128
+ # webhook request failures. Maximum 3 retries are allowed, the default value is 0.
129
+ # @param [String] configuration_replay_after The message index for which and it's
130
+ # successors the webhook will be replayed. Not set by default
131
+ # @param [Boolean] configuration_buffer_messages The flag whether buffering should
132
+ # be applied to messages. Not set by default
133
+ # @param [String] configuration_buffer_window The period of buffering messages.
134
+ # Default is 3000 ms.
135
+ # @return [WebhookInstance] Newly created WebhookInstance
136
+ def create(target: nil, configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_retry_count: :unset, configuration_replay_after: :unset, configuration_buffer_messages: :unset, configuration_buffer_window: :unset)
137
+ data = Twilio::Values.of({
138
+ 'Target' => target,
139
+ 'Configuration.Url' => configuration_url,
140
+ 'Configuration.Method' => configuration_method,
141
+ 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e },
142
+ 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e },
143
+ 'Configuration.FlowSid' => configuration_flow_sid,
144
+ 'Configuration.RetryCount' => configuration_retry_count,
145
+ 'Configuration.ReplayAfter' => configuration_replay_after,
146
+ 'Configuration.BufferMessages' => configuration_buffer_messages,
147
+ 'Configuration.BufferWindow' => configuration_buffer_window,
148
+ })
149
+
150
+ payload = @version.create(
151
+ 'POST',
152
+ @uri,
153
+ data: data
154
+ )
155
+
156
+ WebhookInstance.new(@version, payload, session_sid: @solution[:session_sid], )
157
+ end
158
+
159
+ ##
160
+ # Provide a user friendly representation
161
+ def to_s
162
+ '#<Twilio.Messaging.V1.WebhookList>'
163
+ end
164
+ end
165
+
166
+ ##
167
+ # 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.
168
+ class WebhookPage < Page
169
+ ##
170
+ # Initialize the WebhookPage
171
+ # @param [Version] version Version that contains the resource
172
+ # @param [Response] response Response from the API
173
+ # @param [Hash] solution Path solution for the resource
174
+ # @return [WebhookPage] WebhookPage
175
+ def initialize(version, response, solution)
176
+ super(version, response)
177
+
178
+ # Path Solution
179
+ @solution = solution
180
+ end
181
+
182
+ ##
183
+ # Build an instance of WebhookInstance
184
+ # @param [Hash] payload Payload response from the API
185
+ # @return [WebhookInstance] WebhookInstance
186
+ def get_instance(payload)
187
+ WebhookInstance.new(@version, payload, session_sid: @solution[:session_sid], )
188
+ end
189
+
190
+ ##
191
+ # Provide a user friendly representation
192
+ def to_s
193
+ '<Twilio.Messaging.V1.WebhookPage>'
194
+ end
195
+ end
196
+
197
+ ##
198
+ # 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.
199
+ class WebhookContext < InstanceContext
200
+ ##
201
+ # Initialize the WebhookContext
202
+ # @param [Version] version Version that contains the resource
203
+ # @param [String] session_sid The unique id of the
204
+ # [Session](https://www.twilio.com/docs/sessions/api/session) for this webhook.
205
+ # @param [String] sid A 34 character string that uniquely identifies this
206
+ # resource.
207
+ # @return [WebhookContext] WebhookContext
208
+ def initialize(version, session_sid, sid)
209
+ super(version)
210
+
211
+ # Path Solution
212
+ @solution = {session_sid: session_sid, sid: sid, }
213
+ @uri = "/Sessions/#{@solution[:session_sid]}/Webhooks/#{@solution[:sid]}"
214
+ end
215
+
216
+ ##
217
+ # Fetch a WebhookInstance
218
+ # @return [WebhookInstance] Fetched WebhookInstance
219
+ def fetch
220
+ params = Twilio::Values.of({})
221
+
222
+ payload = @version.fetch(
223
+ 'GET',
224
+ @uri,
225
+ params,
226
+ )
227
+
228
+ WebhookInstance.new(@version, payload, session_sid: @solution[:session_sid], sid: @solution[:sid], )
229
+ end
230
+
231
+ ##
232
+ # Update the WebhookInstance
233
+ # @param [String] configuration_url The absolute url the webhook request should be
234
+ # sent to.
235
+ # @param [webhook.Method] configuration_method The HTTP method to be used when
236
+ # sending a webhook request.
237
+ # @param [String] configuration_filters The list of events, firing webhook event
238
+ # for this Session.
239
+ # @param [String] configuration_triggers The list of keywords, firing webhook
240
+ # event for this Session.
241
+ # @param [String] configuration_flow_sid The studio flow sid, where the webhook
242
+ # should be sent to.
243
+ # @param [String] configuration_retry_count The number of retries in case of
244
+ # webhook request failures. Maximum 3 retries are allowed, the default value is 0.
245
+ # @param [Boolean] configuration_buffer_messages The flag whether buffering should
246
+ # be applied to messages. Not set by default
247
+ # @param [String] configuration_buffer_window The period of buffering messages.
248
+ # Default is 3000 ms.
249
+ # @return [WebhookInstance] Updated WebhookInstance
250
+ def update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_retry_count: :unset, configuration_buffer_messages: :unset, configuration_buffer_window: :unset)
251
+ data = Twilio::Values.of({
252
+ 'Configuration.Url' => configuration_url,
253
+ 'Configuration.Method' => configuration_method,
254
+ 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e },
255
+ 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e },
256
+ 'Configuration.FlowSid' => configuration_flow_sid,
257
+ 'Configuration.RetryCount' => configuration_retry_count,
258
+ 'Configuration.BufferMessages' => configuration_buffer_messages,
259
+ 'Configuration.BufferWindow' => configuration_buffer_window,
260
+ })
261
+
262
+ payload = @version.update(
263
+ 'POST',
264
+ @uri,
265
+ data: data,
266
+ )
267
+
268
+ WebhookInstance.new(@version, payload, session_sid: @solution[:session_sid], sid: @solution[:sid], )
269
+ end
270
+
271
+ ##
272
+ # Deletes the WebhookInstance
273
+ # @return [Boolean] true if delete succeeds, true otherwise
274
+ def delete
275
+ @version.delete('delete', @uri)
276
+ end
277
+
278
+ ##
279
+ # Provide a user friendly representation
280
+ def to_s
281
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
282
+ "#<Twilio.Messaging.V1.WebhookContext #{context}>"
283
+ end
284
+
285
+ ##
286
+ # Provide a detailed, user friendly representation
287
+ def inspect
288
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
289
+ "#<Twilio.Messaging.V1.WebhookContext #{context}>"
290
+ end
291
+ end
292
+
293
+ ##
294
+ # 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.
295
+ class WebhookInstance < InstanceResource
296
+ ##
297
+ # Initialize the WebhookInstance
298
+ # @param [Version] version Version that contains the resource
299
+ # @param [Hash] payload payload that contains response from Twilio
300
+ # @param [String] session_sid The unique id of the
301
+ # [Session](https://www.twilio.com/docs/sessions/api/session) for this webhook.
302
+ # @param [String] sid A 34 character string that uniquely identifies this
303
+ # resource.
304
+ # @return [WebhookInstance] WebhookInstance
305
+ def initialize(version, payload, session_sid: nil, sid: nil)
306
+ super(version)
307
+
308
+ # Marshaled Properties
309
+ @properties = {
310
+ 'sid' => payload['sid'],
311
+ 'account_sid' => payload['account_sid'],
312
+ 'session_sid' => payload['session_sid'],
313
+ 'target' => payload['target'],
314
+ 'url' => payload['url'],
315
+ 'configuration' => payload['configuration'],
316
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
317
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
318
+ }
319
+
320
+ # Context
321
+ @instance_context = nil
322
+ @params = {'session_sid' => session_sid, 'sid' => sid || @properties['sid'], }
323
+ end
324
+
325
+ ##
326
+ # Generate an instance context for the instance, the context is capable of
327
+ # performing various actions. All instance actions are proxied to the context
328
+ # @return [WebhookContext] WebhookContext for this WebhookInstance
329
+ def context
330
+ unless @instance_context
331
+ @instance_context = WebhookContext.new(@version, @params['session_sid'], @params['sid'], )
332
+ end
333
+ @instance_context
334
+ end
335
+
336
+ ##
337
+ # @return [String] A 34 character string that uniquely identifies this resource.
338
+ def sid
339
+ @properties['sid']
340
+ end
341
+
342
+ ##
343
+ # @return [String] The unique id of the Account responsible for this session.
344
+ def account_sid
345
+ @properties['account_sid']
346
+ end
347
+
348
+ ##
349
+ # @return [String] The unique id of the Session for this webhook.
350
+ def session_sid
351
+ @properties['session_sid']
352
+ end
353
+
354
+ ##
355
+ # @return [String] The target of this webhook.
356
+ def target
357
+ @properties['target']
358
+ end
359
+
360
+ ##
361
+ # @return [String] An absolute URL for this webhook.
362
+ def url
363
+ @properties['url']
364
+ end
365
+
366
+ ##
367
+ # @return [Hash] The configuration of this webhook.
368
+ def configuration
369
+ @properties['configuration']
370
+ end
371
+
372
+ ##
373
+ # @return [Time] The date that this resource was created.
374
+ def date_created
375
+ @properties['date_created']
376
+ end
377
+
378
+ ##
379
+ # @return [Time] The date that this resource was last updated.
380
+ def date_updated
381
+ @properties['date_updated']
382
+ end
383
+
384
+ ##
385
+ # Fetch a WebhookInstance
386
+ # @return [WebhookInstance] Fetched WebhookInstance
387
+ def fetch
388
+ context.fetch
389
+ end
390
+
391
+ ##
392
+ # Update the WebhookInstance
393
+ # @param [String] configuration_url The absolute url the webhook request should be
394
+ # sent to.
395
+ # @param [webhook.Method] configuration_method The HTTP method to be used when
396
+ # sending a webhook request.
397
+ # @param [String] configuration_filters The list of events, firing webhook event
398
+ # for this Session.
399
+ # @param [String] configuration_triggers The list of keywords, firing webhook
400
+ # event for this Session.
401
+ # @param [String] configuration_flow_sid The studio flow sid, where the webhook
402
+ # should be sent to.
403
+ # @param [String] configuration_retry_count The number of retries in case of
404
+ # webhook request failures. Maximum 3 retries are allowed, the default value is 0.
405
+ # @param [Boolean] configuration_buffer_messages The flag whether buffering should
406
+ # be applied to messages. Not set by default
407
+ # @param [String] configuration_buffer_window The period of buffering messages.
408
+ # Default is 3000 ms.
409
+ # @return [WebhookInstance] Updated WebhookInstance
410
+ def update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_retry_count: :unset, configuration_buffer_messages: :unset, configuration_buffer_window: :unset)
411
+ context.update(
412
+ configuration_url: configuration_url,
413
+ configuration_method: configuration_method,
414
+ configuration_filters: configuration_filters,
415
+ configuration_triggers: configuration_triggers,
416
+ configuration_flow_sid: configuration_flow_sid,
417
+ configuration_retry_count: configuration_retry_count,
418
+ configuration_buffer_messages: configuration_buffer_messages,
419
+ configuration_buffer_window: configuration_buffer_window,
420
+ )
421
+ end
422
+
423
+ ##
424
+ # Deletes the WebhookInstance
425
+ # @return [Boolean] true if delete succeeds, true otherwise
426
+ def delete
427
+ context.delete
428
+ end
429
+
430
+ ##
431
+ # Provide a user friendly representation
432
+ def to_s
433
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
434
+ "<Twilio.Messaging.V1.WebhookInstance #{values}>"
435
+ end
436
+
437
+ ##
438
+ # Provide a detailed, user friendly representation
439
+ def inspect
440
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
441
+ "<Twilio.Messaging.V1.WebhookInstance #{values}>"
442
+ end
443
+ end
444
+ end
445
+ end
446
+ end
447
+ end
448
+ end