twilio-ruby 5.3.1 → 5.4.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,465 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Proxy < Domain
10
+ class V1 < Version
11
+ class ServiceContext < InstanceContext
12
+ class SessionContext < InstanceContext
13
+ class ParticipantContext < InstanceContext
14
+ ##
15
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
16
+ class MessageInteractionList < ListResource
17
+ ##
18
+ # Initialize the MessageInteractionList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] service_sid The unique SID identifier of the Service.
21
+ # @param [String] session_sid The unique SID identifier of the Session.
22
+ # @param [String] participant_sid The unique SID identifier of the Participant.
23
+ # @return [MessageInteractionList] MessageInteractionList
24
+ def initialize(version, service_sid: nil, session_sid: nil, participant_sid: nil)
25
+ super(version)
26
+
27
+ # Path Solution
28
+ @solution = {
29
+ service_sid: service_sid,
30
+ session_sid: session_sid,
31
+ participant_sid: participant_sid
32
+ }
33
+ @uri = "/Services/#{@solution[:service_sid]}/Sessions/#{@solution[:session_sid]}/Participants/#{@solution[:participant_sid]}/MessageInteractions"
34
+ end
35
+
36
+ ##
37
+ # Retrieve a single page of MessageInteractionInstance records from the API.
38
+ # Request is executed immediately.
39
+ # @param [String] body The body
40
+ # @param [String] media_url The media_url
41
+ # @return [MessageInteractionInstance] Newly created MessageInteractionInstance
42
+ def create(body: :unset, media_url: :unset)
43
+ data = Twilio::Values.of({
44
+ 'Body' => body,
45
+ 'MediaUrl' => media_url,
46
+ })
47
+
48
+ payload = @version.create(
49
+ 'POST',
50
+ @uri,
51
+ data: data
52
+ )
53
+
54
+ MessageInteractionInstance.new(
55
+ @version,
56
+ payload,
57
+ service_sid: @solution[:service_sid],
58
+ session_sid: @solution[:session_sid],
59
+ participant_sid: @solution[:participant_sid],
60
+ )
61
+ end
62
+
63
+ ##
64
+ # Lists MessageInteractionInstance records from the API as a list.
65
+ # Unlike stream(), this operation is eager and will load `limit` records into
66
+ # memory before returning.
67
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
68
+ # guarantees to never return more than limit. Default is no limit
69
+ # @param [Integer] page_size Number of records to fetch per request, when
70
+ # not set will use the default value of 50 records. If no page_size is defined
71
+ # but a limit is defined, stream() will attempt to read the limit with the most
72
+ # efficient page size, i.e. min(limit, 1000)
73
+ # @return [Array] Array of up to limit results
74
+ def list(limit: nil, page_size: nil)
75
+ self.stream(
76
+ limit: limit,
77
+ page_size: page_size
78
+ ).entries
79
+ end
80
+
81
+ ##
82
+ # Streams MessageInteractionInstance records from the API as an Enumerable.
83
+ # This operation lazily loads records as efficiently as possible until the limit
84
+ # is reached.
85
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
86
+ # guarantees to never return more than limit. Default is no limit.
87
+ # @param [Integer] page_size Number of records to fetch per request, when
88
+ # not set will use the default value of 50 records. If no page_size is defined
89
+ # but a limit is defined, stream() will attempt to read the limit with the most
90
+ # efficient page size, i.e. min(limit, 1000)
91
+ # @return [Enumerable] Enumerable that will yield up to limit results
92
+ def stream(limit: nil, page_size: nil)
93
+ limits = @version.read_limits(limit, page_size)
94
+
95
+ page = self.page(
96
+ page_size: limits[:page_size],
97
+ )
98
+
99
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
100
+ end
101
+
102
+ ##
103
+ # When passed a block, yields MessageInteractionInstance records from the API.
104
+ # This operation lazily loads records as efficiently as possible until the limit
105
+ # is reached.
106
+ def each
107
+ limits = @version.read_limits
108
+
109
+ page = self.page(
110
+ page_size: limits[:page_size],
111
+ )
112
+
113
+ @version.stream(page,
114
+ limit: limits[:limit],
115
+ page_limit: limits[:page_limit]).each {|x| yield x}
116
+ end
117
+
118
+ ##
119
+ # Retrieve a single page of MessageInteractionInstance records from the API.
120
+ # Request is executed immediately.
121
+ # @param [String] page_token PageToken provided by the API
122
+ # @param [Integer] page_number Page Number, this value is simply for client state
123
+ # @param [Integer] page_size Number of records to return, defaults to 50
124
+ # @return [Page] Page of MessageInteractionInstance
125
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
126
+ params = Twilio::Values.of({
127
+ 'PageToken' => page_token,
128
+ 'Page' => page_number,
129
+ 'PageSize' => page_size,
130
+ })
131
+ response = @version.page(
132
+ 'GET',
133
+ @uri,
134
+ params
135
+ )
136
+ MessageInteractionPage.new(@version, response, @solution)
137
+ end
138
+
139
+ ##
140
+ # Retrieve a single page of MessageInteractionInstance records from the API.
141
+ # Request is executed immediately.
142
+ # @param [String] target_url API-generated URL for the requested results page
143
+ # @return [Page] Page of MessageInteractionInstance
144
+ def get_page(target_url)
145
+ response = @version.domain.request(
146
+ 'GET',
147
+ target_url
148
+ )
149
+ MessageInteractionPage.new(@version, response, @solution)
150
+ end
151
+
152
+ ##
153
+ # Provide a user friendly representation
154
+ def to_s
155
+ '#<Twilio.Proxy.V1.MessageInteractionList>'
156
+ end
157
+ end
158
+
159
+ ##
160
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
161
+ class MessageInteractionPage < Page
162
+ ##
163
+ # Initialize the MessageInteractionPage
164
+ # @param [Version] version Version that contains the resource
165
+ # @param [Response] response Response from the API
166
+ # @param [Hash] solution Path solution for the resource
167
+ # @return [MessageInteractionPage] MessageInteractionPage
168
+ def initialize(version, response, solution)
169
+ super(version, response)
170
+
171
+ # Path Solution
172
+ @solution = solution
173
+ end
174
+
175
+ ##
176
+ # Build an instance of MessageInteractionInstance
177
+ # @param [Hash] payload Payload response from the API
178
+ # @return [MessageInteractionInstance] MessageInteractionInstance
179
+ def get_instance(payload)
180
+ MessageInteractionInstance.new(
181
+ @version,
182
+ payload,
183
+ service_sid: @solution[:service_sid],
184
+ session_sid: @solution[:session_sid],
185
+ participant_sid: @solution[:participant_sid],
186
+ )
187
+ end
188
+
189
+ ##
190
+ # Provide a user friendly representation
191
+ def to_s
192
+ '<Twilio.Proxy.V1.MessageInteractionPage>'
193
+ end
194
+ end
195
+
196
+ ##
197
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
198
+ class MessageInteractionContext < InstanceContext
199
+ ##
200
+ # Initialize the MessageInteractionContext
201
+ # @param [Version] version Version that contains the resource
202
+ # @param [String] service_sid The unique SID identifier of the Service.
203
+ # @param [String] session_sid The unique SID identifier of the Session.
204
+ # @param [String] participant_sid The unique SID identifier of the Participant.
205
+ # @param [String] sid A 34 character string that uniquely identifies this Message
206
+ # Interaction.
207
+ # @return [MessageInteractionContext] MessageInteractionContext
208
+ def initialize(version, service_sid, session_sid, participant_sid, sid)
209
+ super(version)
210
+
211
+ # Path Solution
212
+ @solution = {
213
+ service_sid: service_sid,
214
+ session_sid: session_sid,
215
+ participant_sid: participant_sid,
216
+ sid: sid,
217
+ }
218
+ @uri = "/Services/#{@solution[:service_sid]}/Sessions/#{@solution[:session_sid]}/Participants/#{@solution[:participant_sid]}/MessageInteractions/#{@solution[:sid]}"
219
+ end
220
+
221
+ ##
222
+ # Fetch a MessageInteractionInstance
223
+ # @return [MessageInteractionInstance] Fetched MessageInteractionInstance
224
+ def fetch
225
+ params = Twilio::Values.of({})
226
+
227
+ payload = @version.fetch(
228
+ 'GET',
229
+ @uri,
230
+ params,
231
+ )
232
+
233
+ MessageInteractionInstance.new(
234
+ @version,
235
+ payload,
236
+ service_sid: @solution[:service_sid],
237
+ session_sid: @solution[:session_sid],
238
+ participant_sid: @solution[:participant_sid],
239
+ sid: @solution[:sid],
240
+ )
241
+ end
242
+
243
+ ##
244
+ # Provide a user friendly representation
245
+ def to_s
246
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
247
+ "#<Twilio.Proxy.V1.MessageInteractionContext #{context}>"
248
+ end
249
+ end
250
+
251
+ ##
252
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
253
+ class MessageInteractionInstance < InstanceResource
254
+ ##
255
+ # Initialize the MessageInteractionInstance
256
+ # @param [Version] version Version that contains the resource
257
+ # @param [Hash] payload payload that contains response from Twilio
258
+ # @param [String] service_sid The unique SID identifier of the Service.
259
+ # @param [String] session_sid The unique SID identifier of the Session.
260
+ # @param [String] participant_sid The unique SID identifier of the Participant.
261
+ # @param [String] sid A 34 character string that uniquely identifies this Message
262
+ # Interaction.
263
+ # @return [MessageInteractionInstance] MessageInteractionInstance
264
+ def initialize(version, payload, service_sid: nil, session_sid: nil, participant_sid: nil, sid: nil)
265
+ super(version)
266
+
267
+ # Marshaled Properties
268
+ @properties = {
269
+ 'sid' => payload['sid'],
270
+ 'session_sid' => payload['session_sid'],
271
+ 'service_sid' => payload['service_sid'],
272
+ 'account_sid' => payload['account_sid'],
273
+ 'data' => payload['data'],
274
+ 'type' => payload['type'],
275
+ 'participant_sid' => payload['participant_sid'],
276
+ 'inbound_participant_sid' => payload['inbound_participant_sid'],
277
+ 'inbound_resource_sid' => payload['inbound_resource_sid'],
278
+ 'inbound_resource_status' => payload['inbound_resource_status'],
279
+ 'inbound_resource_type' => payload['inbound_resource_type'],
280
+ 'inbound_resource_url' => payload['inbound_resource_url'],
281
+ 'outbound_participant_sid' => payload['outbound_participant_sid'],
282
+ 'outbound_resource_sid' => payload['outbound_resource_sid'],
283
+ 'outbound_resource_status' => payload['outbound_resource_status'],
284
+ 'outbound_resource_type' => payload['outbound_resource_type'],
285
+ 'outbound_resource_url' => payload['outbound_resource_url'],
286
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
287
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
288
+ 'url' => payload['url'],
289
+ }
290
+
291
+ # Context
292
+ @instance_context = nil
293
+ @params = {
294
+ 'service_sid' => service_sid,
295
+ 'session_sid' => session_sid,
296
+ 'participant_sid' => participant_sid,
297
+ 'sid' => sid || @properties['sid'],
298
+ }
299
+ end
300
+
301
+ ##
302
+ # Generate an instance context for the instance, the context is capable of
303
+ # performing various actions. All instance actions are proxied to the context
304
+ # @return [MessageInteractionContext] MessageInteractionContext for this MessageInteractionInstance
305
+ def context
306
+ unless @instance_context
307
+ @instance_context = MessageInteractionContext.new(
308
+ @version,
309
+ @params['service_sid'],
310
+ @params['session_sid'],
311
+ @params['participant_sid'],
312
+ @params['sid'],
313
+ )
314
+ end
315
+ @instance_context
316
+ end
317
+
318
+ ##
319
+ # @return [String] A string that uniquely identifies this Message Interaction.
320
+ def sid
321
+ @properties['sid']
322
+ end
323
+
324
+ ##
325
+ # @return [String] Session Sid.
326
+ def session_sid
327
+ @properties['session_sid']
328
+ end
329
+
330
+ ##
331
+ # @return [String] Service Sid.
332
+ def service_sid
333
+ @properties['service_sid']
334
+ end
335
+
336
+ ##
337
+ # @return [String] Account Sid.
338
+ def account_sid
339
+ @properties['account_sid']
340
+ end
341
+
342
+ ##
343
+ # @return [String] Further details about an interaction.
344
+ def data
345
+ @properties['data']
346
+ end
347
+
348
+ ##
349
+ # @return [message_interaction.Type] The Type of this Message Interaction
350
+ def type
351
+ @properties['type']
352
+ end
353
+
354
+ ##
355
+ # @return [String] Participant Sid.
356
+ def participant_sid
357
+ @properties['participant_sid']
358
+ end
359
+
360
+ ##
361
+ # @return [String] Inbound Participant Sid.
362
+ def inbound_participant_sid
363
+ @properties['inbound_participant_sid']
364
+ end
365
+
366
+ ##
367
+ # @return [String] Inbound Resource Sid.
368
+ def inbound_resource_sid
369
+ @properties['inbound_resource_sid']
370
+ end
371
+
372
+ ##
373
+ # @return [message_interaction.ResourceStatus] The Inbound Resource Status of this Message Interaction
374
+ def inbound_resource_status
375
+ @properties['inbound_resource_status']
376
+ end
377
+
378
+ ##
379
+ # @return [String] The type of the Inbound Resource, Call or Message.
380
+ def inbound_resource_type
381
+ @properties['inbound_resource_type']
382
+ end
383
+
384
+ ##
385
+ # @return [String] The URL of the Twilio resource.
386
+ def inbound_resource_url
387
+ @properties['inbound_resource_url']
388
+ end
389
+
390
+ ##
391
+ # @return [String] Outbound Participant Sid.
392
+ def outbound_participant_sid
393
+ @properties['outbound_participant_sid']
394
+ end
395
+
396
+ ##
397
+ # @return [String] Outbound Resource Sid.
398
+ def outbound_resource_sid
399
+ @properties['outbound_resource_sid']
400
+ end
401
+
402
+ ##
403
+ # @return [message_interaction.ResourceStatus] The Outbound Resource Status of this Message Interaction
404
+ def outbound_resource_status
405
+ @properties['outbound_resource_status']
406
+ end
407
+
408
+ ##
409
+ # @return [String] The type of the Outbound Resource, Call or Message.
410
+ def outbound_resource_type
411
+ @properties['outbound_resource_type']
412
+ end
413
+
414
+ ##
415
+ # @return [String] The URL of the Twilio resource.
416
+ def outbound_resource_url
417
+ @properties['outbound_resource_url']
418
+ end
419
+
420
+ ##
421
+ # @return [Time] The date this Message Interaction was created
422
+ def date_created
423
+ @properties['date_created']
424
+ end
425
+
426
+ ##
427
+ # @return [Time] The date this Message Interaction was updated
428
+ def date_updated
429
+ @properties['date_updated']
430
+ end
431
+
432
+ ##
433
+ # @return [String] The URL of this resource.
434
+ def url
435
+ @properties['url']
436
+ end
437
+
438
+ ##
439
+ # Fetch a MessageInteractionInstance
440
+ # @return [MessageInteractionInstance] Fetched MessageInteractionInstance
441
+ def fetch
442
+ context.fetch
443
+ end
444
+
445
+ ##
446
+ # Provide a user friendly representation
447
+ def to_s
448
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
449
+ "<Twilio.Proxy.V1.MessageInteractionInstance #{values}>"
450
+ end
451
+
452
+ ##
453
+ # Provide a detailed, user friendly representation
454
+ def inspect
455
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
456
+ "<Twilio.Proxy.V1.MessageInteractionInstance #{values}>"
457
+ end
458
+ end
459
+ end
460
+ end
461
+ end
462
+ end
463
+ end
464
+ end
465
+ end