twilio-ruby 5.5.1 → 5.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +18 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number.rb +96 -0
  5. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/machine_to_machine.rb +396 -0
  6. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/national.rb +396 -0
  7. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/shared_cost.rb +396 -0
  8. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/voip.rb +396 -0
  9. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +4 -1
  10. data/lib/twilio-ruby/rest/api/v2010/account/call/recording.rb +15 -15
  11. data/lib/twilio-ruby/rest/api/v2010/account/conference.rb +1 -1
  12. data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +7 -1
  13. data/lib/twilio-ruby/rest/api/v2010/account/recording.rb +17 -10
  14. data/lib/twilio-ruby/rest/preview/hosted_numbers/hosted_number_order.rb +41 -3
  15. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +6 -6
  16. data/lib/twilio-ruby/twiml/messaging_response.rb +3 -2
  17. data/lib/twilio-ruby/twiml/voice_response.rb +10 -6
  18. data/lib/twilio-ruby/version.rb +1 -1
  19. data/spec/integration/api/v2010/account/available_phone_number/machine_to_machine_spec.rb +101 -0
  20. data/spec/integration/api/v2010/account/available_phone_number/national_spec.rb +101 -0
  21. data/spec/integration/api/v2010/account/available_phone_number/shared_cost_spec.rb +101 -0
  22. data/spec/integration/api/v2010/account/available_phone_number/voip_spec.rb +101 -0
  23. data/spec/integration/api/v2010/account/call/recording_spec.rb +28 -28
  24. data/spec/integration/api/v2010/account/conference_spec.rb +6 -3
  25. data/spec/integration/api/v2010/account/recording_spec.rb +32 -24
  26. data/spec/integration/notify/v1/service_spec.rb +4 -0
  27. data/spec/integration/preview/hosted_numbers/hosted_number_order_spec.rb +50 -5
  28. data/spec/integration/proxy/v1/service/session_spec.rb +3 -3
  29. metadata +14 -2
@@ -0,0 +1,396 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Api < Domain
10
+ class V2010 < Version
11
+ class AccountContext < InstanceContext
12
+ class AvailablePhoneNumberCountryContext < InstanceContext
13
+ class VoipList < ListResource
14
+ ##
15
+ # Initialize the VoipList
16
+ # @param [Version] version Version that contains the resource
17
+ # @param [String] account_sid The 34 character string that uniquely identifies
18
+ # your account.
19
+ # @param [String] country_code The ISO Country code to lookup phone numbers for.
20
+ # @return [VoipList] VoipList
21
+ def initialize(version, account_sid: nil, country_code: nil)
22
+ super(version)
23
+
24
+ # Path Solution
25
+ @solution = {account_sid: account_sid, country_code: country_code}
26
+ @uri = "/Accounts/#{@solution[:account_sid]}/AvailablePhoneNumbers/#{@solution[:country_code]}/Voip.json"
27
+ end
28
+
29
+ ##
30
+ # Lists VoipInstance records from the API as a list.
31
+ # Unlike stream(), this operation is eager and will load `limit` records into
32
+ # memory before returning.
33
+ # @param [String] area_code The area_code
34
+ # @param [String] contains The contains
35
+ # @param [Boolean] sms_enabled The sms_enabled
36
+ # @param [Boolean] mms_enabled The mms_enabled
37
+ # @param [Boolean] voice_enabled The voice_enabled
38
+ # @param [Boolean] exclude_all_address_required The exclude_all_address_required
39
+ # @param [Boolean] exclude_local_address_required The
40
+ # exclude_local_address_required
41
+ # @param [Boolean] exclude_foreign_address_required The
42
+ # exclude_foreign_address_required
43
+ # @param [Boolean] beta The beta
44
+ # @param [String] near_number The near_number
45
+ # @param [String] near_lat_long The near_lat_long
46
+ # @param [String] distance The distance
47
+ # @param [String] in_postal_code The in_postal_code
48
+ # @param [String] in_region The in_region
49
+ # @param [String] in_rate_center The in_rate_center
50
+ # @param [String] in_lata The in_lata
51
+ # @param [String] in_locality The in_locality
52
+ # @param [Boolean] fax_enabled The fax_enabled
53
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
54
+ # guarantees to never return more than limit. Default is no limit
55
+ # @param [Integer] page_size Number of records to fetch per request, when
56
+ # not set will use the default value of 50 records. If no page_size is defined
57
+ # but a limit is defined, stream() will attempt to read the limit with the most
58
+ # efficient page size, i.e. min(limit, 1000)
59
+ # @return [Array] Array of up to limit results
60
+ def list(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled: :unset, voice_enabled: :unset, exclude_all_address_required: :unset, exclude_local_address_required: :unset, exclude_foreign_address_required: :unset, beta: :unset, near_number: :unset, near_lat_long: :unset, distance: :unset, in_postal_code: :unset, in_region: :unset, in_rate_center: :unset, in_lata: :unset, in_locality: :unset, fax_enabled: :unset, limit: nil, page_size: nil)
61
+ self.stream(
62
+ area_code: area_code,
63
+ contains: contains,
64
+ sms_enabled: sms_enabled,
65
+ mms_enabled: mms_enabled,
66
+ voice_enabled: voice_enabled,
67
+ exclude_all_address_required: exclude_all_address_required,
68
+ exclude_local_address_required: exclude_local_address_required,
69
+ exclude_foreign_address_required: exclude_foreign_address_required,
70
+ beta: beta,
71
+ near_number: near_number,
72
+ near_lat_long: near_lat_long,
73
+ distance: distance,
74
+ in_postal_code: in_postal_code,
75
+ in_region: in_region,
76
+ in_rate_center: in_rate_center,
77
+ in_lata: in_lata,
78
+ in_locality: in_locality,
79
+ fax_enabled: fax_enabled,
80
+ limit: limit,
81
+ page_size: page_size
82
+ ).entries
83
+ end
84
+
85
+ ##
86
+ # Streams VoipInstance records from the API as an Enumerable.
87
+ # This operation lazily loads records as efficiently as possible until the limit
88
+ # is reached.
89
+ # @param [String] area_code The area_code
90
+ # @param [String] contains The contains
91
+ # @param [Boolean] sms_enabled The sms_enabled
92
+ # @param [Boolean] mms_enabled The mms_enabled
93
+ # @param [Boolean] voice_enabled The voice_enabled
94
+ # @param [Boolean] exclude_all_address_required The exclude_all_address_required
95
+ # @param [Boolean] exclude_local_address_required The
96
+ # exclude_local_address_required
97
+ # @param [Boolean] exclude_foreign_address_required The
98
+ # exclude_foreign_address_required
99
+ # @param [Boolean] beta The beta
100
+ # @param [String] near_number The near_number
101
+ # @param [String] near_lat_long The near_lat_long
102
+ # @param [String] distance The distance
103
+ # @param [String] in_postal_code The in_postal_code
104
+ # @param [String] in_region The in_region
105
+ # @param [String] in_rate_center The in_rate_center
106
+ # @param [String] in_lata The in_lata
107
+ # @param [String] in_locality The in_locality
108
+ # @param [Boolean] fax_enabled The fax_enabled
109
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
110
+ # guarantees to never return more than limit. Default is no limit.
111
+ # @param [Integer] page_size Number of records to fetch per request, when
112
+ # not set will use the default value of 50 records. If no page_size is defined
113
+ # but a limit is defined, stream() will attempt to read the limit with the most
114
+ # efficient page size, i.e. min(limit, 1000)
115
+ # @return [Enumerable] Enumerable that will yield up to limit results
116
+ def stream(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled: :unset, voice_enabled: :unset, exclude_all_address_required: :unset, exclude_local_address_required: :unset, exclude_foreign_address_required: :unset, beta: :unset, near_number: :unset, near_lat_long: :unset, distance: :unset, in_postal_code: :unset, in_region: :unset, in_rate_center: :unset, in_lata: :unset, in_locality: :unset, fax_enabled: :unset, limit: nil, page_size: nil)
117
+ limits = @version.read_limits(limit, page_size)
118
+
119
+ page = self.page(
120
+ area_code: area_code,
121
+ contains: contains,
122
+ sms_enabled: sms_enabled,
123
+ mms_enabled: mms_enabled,
124
+ voice_enabled: voice_enabled,
125
+ exclude_all_address_required: exclude_all_address_required,
126
+ exclude_local_address_required: exclude_local_address_required,
127
+ exclude_foreign_address_required: exclude_foreign_address_required,
128
+ beta: beta,
129
+ near_number: near_number,
130
+ near_lat_long: near_lat_long,
131
+ distance: distance,
132
+ in_postal_code: in_postal_code,
133
+ in_region: in_region,
134
+ in_rate_center: in_rate_center,
135
+ in_lata: in_lata,
136
+ in_locality: in_locality,
137
+ fax_enabled: fax_enabled,
138
+ page_size: limits[:page_size],
139
+ )
140
+
141
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
142
+ end
143
+
144
+ ##
145
+ # When passed a block, yields VoipInstance records from the API.
146
+ # This operation lazily loads records as efficiently as possible until the limit
147
+ # is reached.
148
+ def each
149
+ limits = @version.read_limits
150
+
151
+ page = self.page(page_size: limits[:page_size])
152
+
153
+ @version.stream(page,
154
+ limit: limits[:limit],
155
+ page_limit: limits[:page_limit]).each {|x| yield x}
156
+ end
157
+
158
+ ##
159
+ # Retrieve a single page of VoipInstance records from the API.
160
+ # Request is executed immediately.
161
+ # @param [String] area_code The area_code
162
+ # @param [String] contains The contains
163
+ # @param [Boolean] sms_enabled The sms_enabled
164
+ # @param [Boolean] mms_enabled The mms_enabled
165
+ # @param [Boolean] voice_enabled The voice_enabled
166
+ # @param [Boolean] exclude_all_address_required The exclude_all_address_required
167
+ # @param [Boolean] exclude_local_address_required The
168
+ # exclude_local_address_required
169
+ # @param [Boolean] exclude_foreign_address_required The
170
+ # exclude_foreign_address_required
171
+ # @param [Boolean] beta The beta
172
+ # @param [String] near_number The near_number
173
+ # @param [String] near_lat_long The near_lat_long
174
+ # @param [String] distance The distance
175
+ # @param [String] in_postal_code The in_postal_code
176
+ # @param [String] in_region The in_region
177
+ # @param [String] in_rate_center The in_rate_center
178
+ # @param [String] in_lata The in_lata
179
+ # @param [String] in_locality The in_locality
180
+ # @param [Boolean] fax_enabled The fax_enabled
181
+ # @param [String] page_token PageToken provided by the API
182
+ # @param [Integer] page_number Page Number, this value is simply for client state
183
+ # @param [Integer] page_size Number of records to return, defaults to 50
184
+ # @return [Page] Page of VoipInstance
185
+ def page(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled: :unset, voice_enabled: :unset, exclude_all_address_required: :unset, exclude_local_address_required: :unset, exclude_foreign_address_required: :unset, beta: :unset, near_number: :unset, near_lat_long: :unset, distance: :unset, in_postal_code: :unset, in_region: :unset, in_rate_center: :unset, in_lata: :unset, in_locality: :unset, fax_enabled: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
186
+ params = Twilio::Values.of({
187
+ 'AreaCode' => area_code,
188
+ 'Contains' => contains,
189
+ 'SmsEnabled' => sms_enabled,
190
+ 'MmsEnabled' => mms_enabled,
191
+ 'VoiceEnabled' => voice_enabled,
192
+ 'ExcludeAllAddressRequired' => exclude_all_address_required,
193
+ 'ExcludeLocalAddressRequired' => exclude_local_address_required,
194
+ 'ExcludeForeignAddressRequired' => exclude_foreign_address_required,
195
+ 'Beta' => beta,
196
+ 'NearNumber' => near_number,
197
+ 'NearLatLong' => near_lat_long,
198
+ 'Distance' => distance,
199
+ 'InPostalCode' => in_postal_code,
200
+ 'InRegion' => in_region,
201
+ 'InRateCenter' => in_rate_center,
202
+ 'InLata' => in_lata,
203
+ 'InLocality' => in_locality,
204
+ 'FaxEnabled' => fax_enabled,
205
+ 'PageToken' => page_token,
206
+ 'Page' => page_number,
207
+ 'PageSize' => page_size,
208
+ })
209
+ response = @version.page(
210
+ 'GET',
211
+ @uri,
212
+ params
213
+ )
214
+ VoipPage.new(@version, response, @solution)
215
+ end
216
+
217
+ ##
218
+ # Retrieve a single page of VoipInstance records from the API.
219
+ # Request is executed immediately.
220
+ # @param [String] target_url API-generated URL for the requested results page
221
+ # @return [Page] Page of VoipInstance
222
+ def get_page(target_url)
223
+ response = @version.domain.request(
224
+ 'GET',
225
+ target_url
226
+ )
227
+ VoipPage.new(@version, response, @solution)
228
+ end
229
+
230
+ ##
231
+ # Provide a user friendly representation
232
+ def to_s
233
+ '#<Twilio.Api.V2010.VoipList>'
234
+ end
235
+ end
236
+
237
+ class VoipPage < Page
238
+ ##
239
+ # Initialize the VoipPage
240
+ # @param [Version] version Version that contains the resource
241
+ # @param [Response] response Response from the API
242
+ # @param [Hash] solution Path solution for the resource
243
+ # @return [VoipPage] VoipPage
244
+ def initialize(version, response, solution)
245
+ super(version, response)
246
+
247
+ # Path Solution
248
+ @solution = solution
249
+ end
250
+
251
+ ##
252
+ # Build an instance of VoipInstance
253
+ # @param [Hash] payload Payload response from the API
254
+ # @return [VoipInstance] VoipInstance
255
+ def get_instance(payload)
256
+ VoipInstance.new(
257
+ @version,
258
+ payload,
259
+ account_sid: @solution[:account_sid],
260
+ country_code: @solution[:country_code],
261
+ )
262
+ end
263
+
264
+ ##
265
+ # Provide a user friendly representation
266
+ def to_s
267
+ '<Twilio.Api.V2010.VoipPage>'
268
+ end
269
+ end
270
+
271
+ class VoipInstance < InstanceResource
272
+ ##
273
+ # Initialize the VoipInstance
274
+ # @param [Version] version Version that contains the resource
275
+ # @param [Hash] payload payload that contains response from Twilio
276
+ # @param [String] account_sid The 34 character string that uniquely identifies
277
+ # your account.
278
+ # @param [String] country_code The ISO Country code to lookup phone numbers for.
279
+ # @return [VoipInstance] VoipInstance
280
+ def initialize(version, payload, account_sid: nil, country_code: nil)
281
+ super(version)
282
+
283
+ # Marshaled Properties
284
+ @properties = {
285
+ 'friendly_name' => payload['friendly_name'],
286
+ 'phone_number' => payload['phone_number'],
287
+ 'lata' => payload['lata'],
288
+ 'locality' => payload['locality'],
289
+ 'rate_center' => payload['rate_center'],
290
+ 'latitude' => payload['latitude'].to_f,
291
+ 'longitude' => payload['longitude'].to_f,
292
+ 'region' => payload['region'],
293
+ 'postal_code' => payload['postal_code'],
294
+ 'iso_country' => payload['iso_country'],
295
+ 'address_requirements' => payload['address_requirements'],
296
+ 'beta' => payload['beta'],
297
+ 'capabilities' => payload['capabilities'],
298
+ }
299
+ end
300
+
301
+ ##
302
+ # @return [String] The friendly_name
303
+ def friendly_name
304
+ @properties['friendly_name']
305
+ end
306
+
307
+ ##
308
+ # @return [String] The phone_number
309
+ def phone_number
310
+ @properties['phone_number']
311
+ end
312
+
313
+ ##
314
+ # @return [String] The lata
315
+ def lata
316
+ @properties['lata']
317
+ end
318
+
319
+ ##
320
+ # @return [String] The locality
321
+ def locality
322
+ @properties['locality']
323
+ end
324
+
325
+ ##
326
+ # @return [String] The rate_center
327
+ def rate_center
328
+ @properties['rate_center']
329
+ end
330
+
331
+ ##
332
+ # @return [String] The latitude
333
+ def latitude
334
+ @properties['latitude']
335
+ end
336
+
337
+ ##
338
+ # @return [String] The longitude
339
+ def longitude
340
+ @properties['longitude']
341
+ end
342
+
343
+ ##
344
+ # @return [String] The region
345
+ def region
346
+ @properties['region']
347
+ end
348
+
349
+ ##
350
+ # @return [String] The postal_code
351
+ def postal_code
352
+ @properties['postal_code']
353
+ end
354
+
355
+ ##
356
+ # @return [String] The iso_country
357
+ def iso_country
358
+ @properties['iso_country']
359
+ end
360
+
361
+ ##
362
+ # @return [String] The address_requirements
363
+ def address_requirements
364
+ @properties['address_requirements']
365
+ end
366
+
367
+ ##
368
+ # @return [Boolean] The beta
369
+ def beta
370
+ @properties['beta']
371
+ end
372
+
373
+ ##
374
+ # @return [String] The capabilities
375
+ def capabilities
376
+ @properties['capabilities']
377
+ end
378
+
379
+ ##
380
+ # Provide a user friendly representation
381
+ def to_s
382
+ "<Twilio.Api.V2010.VoipInstance>"
383
+ end
384
+
385
+ ##
386
+ # Provide a detailed, user friendly representation
387
+ def inspect
388
+ "<Twilio.Api.V2010.VoipInstance>"
389
+ end
390
+ end
391
+ end
392
+ end
393
+ end
394
+ end
395
+ end
396
+ end
@@ -76,6 +76,8 @@ module Twilio
76
76
  # and `DetectMessageEnd`.
77
77
  # @param [String] machine_detection_timeout The integer number of miliseconds that
78
78
  # Twilio should wait while machine_detection is performned before timing out.
79
+ # @param [String] recording_status_callback_event The
80
+ # recording_status_callback_event
79
81
  # @param [String] url The fully qualified URL that should be consulted when the
80
82
  # call connects. Just like when you set a URL on a phone number for handling
81
83
  # inbound calls.
@@ -83,7 +85,7 @@ module Twilio
83
85
  # should use to handle this phone call. If this parameter is present, Twilio will
84
86
  # ignore all of the voice URLs passed and use the URLs set on the application.
85
87
  # @return [CallInstance] Newly created CallInstance
86
- 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, url: :unset, application_sid: :unset)
88
+ 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, url: :unset, application_sid: :unset)
87
89
  data = Twilio::Values.of({
88
90
  'To' => to,
89
91
  'From' => from,
@@ -106,6 +108,7 @@ module Twilio
106
108
  'SipAuthPassword' => sip_auth_password,
107
109
  'MachineDetection' => machine_detection,
108
110
  'MachineDetectionTimeout' => machine_detection_timeout,
111
+ 'RecordingStatusCallbackEvent' => Twilio.serialize_list(recording_status_callback_event) { |e| e },
109
112
  })
110
113
 
111
114
  payload = @version.create(
@@ -247,11 +247,11 @@ module Twilio
247
247
  'price' => payload['price'].to_f,
248
248
  'uri' => payload['uri'],
249
249
  'encryption_details' => payload['encryption_details'],
250
- 'error_code' => payload['error_code'] == nil ? payload['error_code'] : payload['error_code'].to_i,
250
+ 'price_unit' => payload['price_unit'],
251
251
  'status' => payload['status'],
252
- 'source' => payload['source'],
253
252
  'channels' => payload['channels'].to_i,
254
- 'price_unit' => payload['price_unit'],
253
+ 'source' => payload['source'],
254
+ 'error_code' => payload['error_code'] == nil ? payload['error_code'] : payload['error_code'].to_i,
255
255
  }
256
256
 
257
257
  # Context
@@ -336,9 +336,9 @@ module Twilio
336
336
  end
337
337
 
338
338
  ##
339
- # @return [String] The error_code
340
- def error_code
341
- @properties['error_code']
339
+ # @return [String] The price_unit
340
+ def price_unit
341
+ @properties['price_unit']
342
342
  end
343
343
 
344
344
  ##
@@ -347,12 +347,6 @@ module Twilio
347
347
  @properties['status']
348
348
  end
349
349
 
350
- ##
351
- # @return [recording.Source] The source
352
- def source
353
- @properties['source']
354
- end
355
-
356
350
  ##
357
351
  # @return [String] The channels
358
352
  def channels
@@ -360,9 +354,15 @@ module Twilio
360
354
  end
361
355
 
362
356
  ##
363
- # @return [String] The price_unit
364
- def price_unit
365
- @properties['price_unit']
357
+ # @return [recording.Source] The source
358
+ def source
359
+ @properties['source']
360
+ end
361
+
362
+ ##
363
+ # @return [String] The error_code
364
+ def error_code
365
+ @properties['error_code']
366
366
  end
367
367
 
368
368
  ##