twilio-ruby 5.0.0.rc20 → 5.0.0.rc21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +9 -3
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/http/http_client.rb +0 -1
  5. data/lib/twilio-ruby/rest/preview/bulk_exports/export/day.rb +196 -0
  6. data/lib/twilio-ruby/rest/preview/bulk_exports/export.rb +197 -0
  7. data/lib/twilio-ruby/rest/preview/bulk_exports/export_configuration.rb +232 -0
  8. data/lib/twilio-ruby/rest/preview/bulk_exports.rb +44 -0
  9. data/lib/twilio-ruby/rest/preview/hosted_numbers/hosted_number_order.rb +517 -0
  10. data/lib/twilio-ruby/rest/preview/hosted_numbers.rb +35 -0
  11. data/lib/twilio-ruby/rest/preview/proxy/service/phone_number.rb +336 -0
  12. data/lib/twilio-ruby/rest/preview/proxy/service/session/interaction.rb +393 -0
  13. data/lib/twilio-ruby/rest/preview/proxy/service/session/participant/message_interaction.rb +409 -0
  14. data/lib/twilio-ruby/rest/preview/proxy/service/session/participant.rb +479 -0
  15. data/lib/twilio-ruby/rest/preview/proxy/service/session.rb +506 -0
  16. data/lib/twilio-ruby/rest/preview/proxy/service/short_code.rb +336 -0
  17. data/lib/twilio-ruby/rest/preview/proxy/service.rb +467 -0
  18. data/lib/twilio-ruby/rest/preview/proxy.rb +35 -0
  19. data/lib/twilio-ruby/rest/preview.rb +34 -1
  20. data/lib/twilio-ruby/version.rb +1 -1
  21. data/spec/integration/preview/bulk_exports/export/day_spec.rb +56 -0
  22. data/spec/integration/preview/bulk_exports/export_configuration_spec.rb +79 -0
  23. data/spec/integration/preview/bulk_exports/export_spec.rb +43 -0
  24. data/spec/integration/preview/hosted_numbers/hosted_number_order_spec.rb +277 -0
  25. data/spec/integration/preview/proxy/service/phone_number_spec.rb +173 -0
  26. data/spec/integration/preview/proxy/service/session/interaction_spec.rb +104 -0
  27. data/spec/integration/preview/proxy/service/session/participant/message_interaction_spec.rb +164 -0
  28. data/spec/integration/preview/proxy/service/session/participant_spec.rb +226 -0
  29. data/spec/integration/preview/proxy/service/session_spec.rb +216 -0
  30. data/spec/integration/preview/proxy/service/short_code_spec.rb +173 -0
  31. data/spec/integration/preview/proxy/service_spec.rb +200 -0
  32. metadata +38 -2
@@ -0,0 +1,506 @@
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 Proxy < Version
11
+ class ServiceContext < InstanceContext
12
+ class SessionList < ListResource
13
+ ##
14
+ # Initialize the SessionList
15
+ # @param [Version] version Version that contains the resource
16
+ # @param [String] service_sid The unique SID identifier of the Service.
17
+ # @return [SessionList] SessionList
18
+ def initialize(version, service_sid: nil)
19
+ super(version)
20
+
21
+ # Path Solution
22
+ @solution = {
23
+ service_sid: service_sid
24
+ }
25
+ @uri = "/Services/#{@solution[:service_sid]}/Sessions"
26
+ end
27
+
28
+ ##
29
+ # Lists SessionInstance records from the API as a list.
30
+ # Unlike stream(), this operation is eager and will load `limit` records into
31
+ # memory before returning.
32
+ # @param [String] unique_name Provides a unique and addressable name to be
33
+ # assigned to this Session, assigned by the developer, to be optionally used in
34
+ # addition to SID.
35
+ # @param [session.Status] status The Status of this Session. One of `in-progess`
36
+ # or `completed`.
37
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
38
+ # guarantees to never return more than limit. Default is no limit
39
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
40
+ # the default value of 50 records. If no page_size is defined
41
+ # but a limit is defined, stream() will attempt to read the
42
+ # limit with the most efficient page size, i.e. min(limit, 1000)
43
+ # @return [Array] Array of up to limit results
44
+ def list(unique_name: nil, status: nil, limit: nil, page_size: nil)
45
+ self.stream(
46
+ unique_name: unique_name,
47
+ status: status,
48
+ limit: limit,
49
+ page_size: page_size
50
+ ).entries
51
+ end
52
+
53
+ ##
54
+ # Streams SessionInstance records from the API as an Enumerable.
55
+ # This operation lazily loads records as efficiently as possible until the limit
56
+ # is reached.
57
+ # @param [String] unique_name Provides a unique and addressable name to be
58
+ # assigned to this Session, assigned by the developer, to be optionally used in
59
+ # addition to SID.
60
+ # @param [session.Status] status The Status of this Session. One of `in-progess`
61
+ # or `completed`.
62
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
63
+ # guarantees to never return more than limit. Default is no limit
64
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
65
+ # the default value of 50 records. If no page_size is defined
66
+ # but a limit is defined, stream() will attempt to read the
67
+ # limit with the most efficient page size, i.e. min(limit, 1000)
68
+ # @return [Enumerable] Enumerable that will yield up to limit results
69
+ def stream(unique_name: nil, status: nil, limit: nil, page_size: nil)
70
+ limits = @version.read_limits(limit, page_size)
71
+
72
+ page = self.page(
73
+ unique_name: unique_name,
74
+ status: status,
75
+ page_size: limits[:page_size],
76
+ )
77
+
78
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
79
+ end
80
+
81
+ ##
82
+ # When passed a block, yields SessionInstance records from the API.
83
+ # This operation lazily loads records as efficiently as possible until the limit
84
+ # is reached.
85
+ # @param [String] unique_name Provides a unique and addressable name to be
86
+ # assigned to this Session, assigned by the developer, to be optionally used in
87
+ # addition to SID.
88
+ # @param [session.Status] status The Status of this Session. One of `in-progess`
89
+ # or `completed`.
90
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
91
+ # guarantees to never return more than limit. Default is no limit
92
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
93
+ # the default value of 50 records. If no page_size is defined
94
+ # but a limit is defined, stream() will attempt to read the
95
+ # limit with the most efficient page size, i.e. min(limit, 1000)
96
+ def each
97
+ limits = @version.read_limits
98
+
99
+ page = self.page(
100
+ page_size: limits[:page_size],
101
+ )
102
+
103
+ @version.stream(page,
104
+ limit: limits[:limit],
105
+ page_limit: limits[:page_limit]).each {|x| yield x}
106
+ end
107
+
108
+ ##
109
+ # Retrieve a single page of SessionInstance records from the API.
110
+ # Request is executed immediately.
111
+ # @param [String] unique_name Provides a unique and addressable name to be
112
+ # assigned to this Session, assigned by the developer, to be optionally used in
113
+ # addition to SID.
114
+ # @param [session.Status] status The Status of this Session. One of `in-progess`
115
+ # or `completed`.
116
+ # @param [String] page_token PageToken provided by the API
117
+ # @param [Integer] page_number Page Number, this value is simply for client state
118
+ # @param [Integer] page_size Number of records to return, defaults to 50
119
+ # @return [Page] Page of SessionInstance
120
+ def page(unique_name: nil, status: nil, page_token: nil, page_number: nil, page_size: nil)
121
+ params = {
122
+ 'UniqueName' => unique_name,
123
+ 'Status' => status,
124
+ 'PageToken' => page_token,
125
+ 'Page' => page_number,
126
+ 'PageSize' => page_size,
127
+ }
128
+ response = @version.page(
129
+ 'GET',
130
+ @uri,
131
+ params
132
+ )
133
+ return SessionPage.new(@version, response, @solution)
134
+ end
135
+
136
+ ##
137
+ # Retrieve a single page of SessionInstance records from the API.
138
+ # Request is executed immediately.
139
+ # @param [String] unique_name Provides a unique and addressable name to be
140
+ # assigned to this Session, assigned by the developer, to be optionally used in
141
+ # addition to SID.
142
+ # @param [String] ttl How long will this session stay open, in seconds. Each new
143
+ # interaction resets this timer.
144
+ # @param [session.Status] status The Status of this Session. One of `in-progess`
145
+ # or `completed`.
146
+ # @param [String] participants The participants
147
+ # @return [SessionInstance] Newly created SessionInstance
148
+ def create(unique_name: nil, ttl: nil, status: nil, participants: nil)
149
+ data = {
150
+ 'UniqueName' => unique_name,
151
+ 'Ttl' => ttl,
152
+ 'Status' => status,
153
+ 'Participants' => participants,
154
+ }
155
+
156
+ payload = @version.create(
157
+ 'POST',
158
+ @uri,
159
+ data: data
160
+ )
161
+
162
+ return SessionInstance.new(
163
+ @version,
164
+ payload,
165
+ service_sid: @solution[:service_sid],
166
+ )
167
+ end
168
+
169
+ ##
170
+ # Provide a user friendly representation
171
+ def to_s
172
+ '#<Twilio.Preview.Proxy.SessionList>'
173
+ end
174
+ end
175
+
176
+ class SessionPage < Page
177
+ ##
178
+ # Initialize the SessionPage
179
+ # @param [Version] version Version that contains the resource
180
+ # @param [Response] response Response from the API
181
+ # @param [Hash] solution Path solution for the resource
182
+ # @param [String] service_sid The unique SID identifier of the Service.
183
+ # @return [SessionPage] SessionPage
184
+ def initialize(version, response, solution)
185
+ super(version, response)
186
+
187
+ # Path Solution
188
+ @solution = solution
189
+ end
190
+
191
+ ##
192
+ # Build an instance of SessionInstance
193
+ # @param [Hash] payload Payload response from the API
194
+ # @return [SessionInstance] SessionInstance
195
+ def get_instance(payload)
196
+ return SessionInstance.new(
197
+ @version,
198
+ payload,
199
+ service_sid: @solution[:service_sid],
200
+ )
201
+ end
202
+
203
+ ##
204
+ # Provide a user friendly representation
205
+ def to_s
206
+ '<Twilio.Preview.Proxy.SessionPage>'
207
+ end
208
+ end
209
+
210
+ class SessionContext < InstanceContext
211
+ ##
212
+ # Initialize the SessionContext
213
+ # @param [Version] version Version that contains the resource
214
+ # @param [String] service_sid The unique SID identifier of the Service.
215
+ # @param [String] sid A 34 character string that uniquely identifies this Session.
216
+ # @return [SessionContext] SessionContext
217
+ def initialize(version, service_sid, sid)
218
+ super(version)
219
+
220
+ # Path Solution
221
+ @solution = {
222
+ service_sid: service_sid,
223
+ sid: sid,
224
+ }
225
+ @uri = "/Services/#{@solution[:service_sid]}/Sessions/#{@solution[:sid]}"
226
+
227
+ # Dependents
228
+ @interactions = nil
229
+ @participants = nil
230
+ end
231
+
232
+ ##
233
+ # Fetch a SessionInstance
234
+ # @return [SessionInstance] Fetched SessionInstance
235
+ def fetch
236
+ params = {}
237
+
238
+ payload = @version.fetch(
239
+ 'GET',
240
+ @uri,
241
+ params,
242
+ )
243
+
244
+ return SessionInstance.new(
245
+ @version,
246
+ payload,
247
+ service_sid: @solution[:service_sid],
248
+ sid: @solution[:sid],
249
+ )
250
+ end
251
+
252
+ ##
253
+ # Deletes the SessionInstance
254
+ # @return [Boolean] true if delete succeeds, true otherwise
255
+ def delete
256
+ return @version.delete('delete', @uri)
257
+ end
258
+
259
+ ##
260
+ # Update the SessionInstance
261
+ # @param [String] unique_name Provides a unique and addressable name to be
262
+ # assigned to this Session, assigned by the developer, to be optionally used in
263
+ # addition to SID.
264
+ # @param [String] ttl How long will this session stay open, in seconds. Each new
265
+ # interaction resets this timer.
266
+ # @param [session.Status] status The Status of this Session. One of `in-progess`
267
+ # or `completed`.
268
+ # @param [String] participants The participants
269
+ # @return [SessionInstance] Updated SessionInstance
270
+ def update(unique_name: nil, ttl: nil, status: nil, participants: nil)
271
+ data = {
272
+ 'UniqueName' => unique_name,
273
+ 'Ttl' => ttl,
274
+ 'Status' => status,
275
+ 'Participants' => participants,
276
+ }
277
+
278
+ payload = @version.update(
279
+ 'POST',
280
+ @uri,
281
+ data: data,
282
+ )
283
+
284
+ return SessionInstance.new(
285
+ @version,
286
+ payload,
287
+ service_sid: @solution[:service_sid],
288
+ sid: @solution[:sid],
289
+ )
290
+ end
291
+
292
+ ##
293
+ # Access the interactions
294
+ # @return [InteractionList] InteractionList
295
+ def interactions(sid=:unset)
296
+ if sid != :unset
297
+ return InteractionContext.new(
298
+ @version,
299
+ @solution[:service_sid],
300
+ @solution[:sid],
301
+ sid,
302
+ )
303
+ end
304
+
305
+ unless @interactions
306
+ @interactions = InteractionList.new(
307
+ @version,
308
+ service_sid: @solution[:service_sid],
309
+ session_sid: @solution[:sid],
310
+ )
311
+ end
312
+
313
+ @interactions
314
+ end
315
+
316
+ ##
317
+ # Access the participants
318
+ # @return [ParticipantList] ParticipantList
319
+ def participants(sid=:unset)
320
+ if sid != :unset
321
+ return ParticipantContext.new(
322
+ @version,
323
+ @solution[:service_sid],
324
+ @solution[:sid],
325
+ sid,
326
+ )
327
+ end
328
+
329
+ unless @participants
330
+ @participants = ParticipantList.new(
331
+ @version,
332
+ service_sid: @solution[:service_sid],
333
+ session_sid: @solution[:sid],
334
+ )
335
+ end
336
+
337
+ @participants
338
+ end
339
+
340
+ ##
341
+ # Provide a user friendly representation
342
+ def to_s
343
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
344
+ "#<Twilio.Preview.Proxy.SessionContext #{context}>"
345
+ end
346
+ end
347
+
348
+ class SessionInstance < InstanceResource
349
+ ##
350
+ # Initialize the SessionInstance
351
+ # @param [Version] version Version that contains the resource
352
+ # @param [Hash] payload payload that contains response from Twilio
353
+ # @param [String] service_sid The unique SID identifier of the Service.
354
+ # @param [String] sid A 34 character string that uniquely identifies this Session.
355
+ # @return [SessionInstance] SessionInstance
356
+ def initialize(version, payload, service_sid: nil, sid: nil)
357
+ super(version)
358
+
359
+ # Marshaled Properties
360
+ @properties = {
361
+ 'sid' => payload['sid'],
362
+ 'service_sid' => payload['service_sid'],
363
+ 'account_sid' => payload['account_sid'],
364
+ 'unique_name' => payload['unique_name'],
365
+ 'ttl' => payload['ttl'].to_i,
366
+ 'status' => payload['status'],
367
+ 'start_time' => Twilio.deserialize_iso8601(payload['start_time']),
368
+ 'end_time' => Twilio.deserialize_iso8601(payload['end_time']),
369
+ 'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
370
+ 'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
371
+ 'url' => payload['url'],
372
+ 'links' => payload['links'],
373
+ }
374
+
375
+ # Context
376
+ @instance_context = nil
377
+ @params = {
378
+ 'service_sid' => service_sid,
379
+ 'sid' => sid || @properties['sid'],
380
+ }
381
+ end
382
+
383
+ ##
384
+ # Generate an instance context for the instance, the context is capable of
385
+ # performing various actions. All instance actions are proxied to the context
386
+ # @param [Version] version Version that contains the resource
387
+ # @return [SessionContext] SessionContext for this SessionInstance
388
+ def context
389
+ unless @instance_context
390
+ @instance_context = SessionContext.new(
391
+ @version,
392
+ @params['service_sid'],
393
+ @params['sid'],
394
+ )
395
+ end
396
+ @instance_context
397
+ end
398
+
399
+ def sid
400
+ @properties['sid']
401
+ end
402
+
403
+ def service_sid
404
+ @properties['service_sid']
405
+ end
406
+
407
+ def account_sid
408
+ @properties['account_sid']
409
+ end
410
+
411
+ def unique_name
412
+ @properties['unique_name']
413
+ end
414
+
415
+ def ttl
416
+ @properties['ttl']
417
+ end
418
+
419
+ def status
420
+ @properties['status']
421
+ end
422
+
423
+ def start_time
424
+ @properties['start_time']
425
+ end
426
+
427
+ def end_time
428
+ @properties['end_time']
429
+ end
430
+
431
+ def date_created
432
+ @properties['date_created']
433
+ end
434
+
435
+ def date_updated
436
+ @properties['date_updated']
437
+ end
438
+
439
+ def url
440
+ @properties['url']
441
+ end
442
+
443
+ def links
444
+ @properties['links']
445
+ end
446
+
447
+ ##
448
+ # Fetch a SessionInstance
449
+ # @return [SessionInstance] Fetched SessionInstance
450
+ def fetch
451
+ context.fetch
452
+ end
453
+
454
+ ##
455
+ # Deletes the SessionInstance
456
+ # @return [Boolean] true if delete succeeds, true otherwise
457
+ def delete
458
+ context.delete
459
+ end
460
+
461
+ ##
462
+ # Update the SessionInstance
463
+ # @param [String] unique_name Provides a unique and addressable name to be
464
+ # assigned to this Session, assigned by the developer, to be optionally used in
465
+ # addition to SID.
466
+ # @param [String] ttl How long will this session stay open, in seconds. Each new
467
+ # interaction resets this timer.
468
+ # @param [session.Status] status The Status of this Session. One of `in-progess`
469
+ # or `completed`.
470
+ # @param [String] participants The participants
471
+ # @return [SessionInstance] Updated SessionInstance
472
+ def update(unique_name: nil, ttl: nil, status: nil, participants: nil)
473
+ context.update(
474
+ unique_name: unique_name,
475
+ ttl: ttl,
476
+ status: status,
477
+ participants: participants,
478
+ )
479
+ end
480
+
481
+ ##
482
+ # Access the interactions
483
+ # @return [interactions] interactions
484
+ def interactions
485
+ context.interactions
486
+ end
487
+
488
+ ##
489
+ # Access the participants
490
+ # @return [participants] participants
491
+ def participants
492
+ context.participants
493
+ end
494
+
495
+ ##
496
+ # Provide a user friendly representation
497
+ def to_s
498
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
499
+ "<Twilio.Preview.Proxy.SessionInstance #{values}>"
500
+ end
501
+ end
502
+ end
503
+ end
504
+ end
505
+ end
506
+ end