twilio-ruby 6.0.1 → 6.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,540 @@
1
+ ##
2
+ # This code was generated by
3
+ # ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
4
+ # | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
5
+ # | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
6
+ #
7
+ # Twilio - Intelligence
8
+ # This is the public Twilio REST API.
9
+ #
10
+ # NOTE: This class is auto generated by OpenAPI Generator.
11
+ # https://openapi-generator.tech
12
+ # Do not edit the class manually.
13
+ #
14
+
15
+
16
+ module Twilio
17
+ module REST
18
+ class Intelligence < IntelligenceBase
19
+ class V2 < Version
20
+ class TranscriptList < ListResource
21
+ ##
22
+ # Initialize the TranscriptList
23
+ # @param [Version] version Version that contains the resource
24
+ # @return [TranscriptList] TranscriptList
25
+ def initialize(version)
26
+ super(version)
27
+ # Path Solution
28
+ @solution = { }
29
+ @uri = "/Transcripts"
30
+
31
+ end
32
+ ##
33
+ # Create the TranscriptInstance
34
+ # @param [String] service_sid The unique SID identifier of the Service.
35
+ # @param [Object] channel JSON object describing Media Channel including Source and Participants
36
+ # @param [String] customer_key Used to store client provided metadata. Maximum of 64 double-byte UTF8 characters.
37
+ # @param [Time] media_start_time The date that this Transcript's media was started, given in ISO 8601 format.
38
+ # @return [TranscriptInstance] Created TranscriptInstance
39
+ def create(
40
+ service_sid: nil,
41
+ channel: nil,
42
+ customer_key: :unset,
43
+ media_start_time: :unset
44
+ )
45
+
46
+ data = Twilio::Values.of({
47
+ 'ServiceSid' => service_sid,
48
+ 'Channel' => Twilio.serialize_object(channel),
49
+ 'CustomerKey' => customer_key,
50
+ 'MediaStartTime' => Twilio.serialize_iso8601_datetime(media_start_time),
51
+ })
52
+
53
+ payload = @version.create('POST', @uri, data: data)
54
+ TranscriptInstance.new(
55
+ @version,
56
+ payload,
57
+ )
58
+ end
59
+
60
+
61
+ ##
62
+ # Lists TranscriptInstance records from the API as a list.
63
+ # Unlike stream(), this operation is eager and will load `limit` records into
64
+ # memory before returning.
65
+ # @param [String] service_sid The unique SID identifier of the Service.
66
+ # @param [String] before_start_time Filter by before StartTime.
67
+ # @param [String] after_start_time Filter by after StartTime.
68
+ # @param [String] before_date_created Filter by before DateCreated.
69
+ # @param [String] after_date_created Filter by after DateCreated.
70
+ # @param [String] status Filter by status.
71
+ # @param [String] language_code Filter by Language Code.
72
+ # @param [String] source_sid Filter by SourceSid.
73
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
74
+ # guarantees to never return more than limit. Default is no limit
75
+ # @param [Integer] page_size Number of records to fetch per request, when
76
+ # not set will use the default value of 50 records. If no page_size is defined
77
+ # but a limit is defined, stream() will attempt to read the limit with the most
78
+ # efficient page size, i.e. min(limit, 1000)
79
+ # @return [Array] Array of up to limit results
80
+ def list(service_sid: :unset, before_start_time: :unset, after_start_time: :unset, before_date_created: :unset, after_date_created: :unset, status: :unset, language_code: :unset, source_sid: :unset, limit: nil, page_size: nil)
81
+ self.stream(
82
+ service_sid: service_sid,
83
+ before_start_time: before_start_time,
84
+ after_start_time: after_start_time,
85
+ before_date_created: before_date_created,
86
+ after_date_created: after_date_created,
87
+ status: status,
88
+ language_code: language_code,
89
+ source_sid: source_sid,
90
+ limit: limit,
91
+ page_size: page_size
92
+ ).entries
93
+ end
94
+
95
+ ##
96
+ # Streams Instance records from the API as an Enumerable.
97
+ # This operation lazily loads records as efficiently as possible until the limit
98
+ # is reached.
99
+ # @param [String] service_sid The unique SID identifier of the Service.
100
+ # @param [String] before_start_time Filter by before StartTime.
101
+ # @param [String] after_start_time Filter by after StartTime.
102
+ # @param [String] before_date_created Filter by before DateCreated.
103
+ # @param [String] after_date_created Filter by after DateCreated.
104
+ # @param [String] status Filter by status.
105
+ # @param [String] language_code Filter by Language Code.
106
+ # @param [String] source_sid Filter by SourceSid.
107
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
108
+ # guarantees to never return more than limit. Default is no limit
109
+ # @param [Integer] page_size Number of records to fetch per request, when
110
+ # not set will use the default value of 50 records. If no page_size is defined
111
+ # but a limit is defined, stream() will attempt to read the limit with the most
112
+ # efficient page size, i.e. min(limit, 1000)
113
+ # @return [Enumerable] Enumerable that will yield up to limit results
114
+ def stream(service_sid: :unset, before_start_time: :unset, after_start_time: :unset, before_date_created: :unset, after_date_created: :unset, status: :unset, language_code: :unset, source_sid: :unset, limit: nil, page_size: nil)
115
+ limits = @version.read_limits(limit, page_size)
116
+
117
+ page = self.page(
118
+ service_sid: service_sid,
119
+ before_start_time: before_start_time,
120
+ after_start_time: after_start_time,
121
+ before_date_created: before_date_created,
122
+ after_date_created: after_date_created,
123
+ status: status,
124
+ language_code: language_code,
125
+ source_sid: source_sid,
126
+ page_size: limits[:page_size], )
127
+
128
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
129
+ end
130
+
131
+ ##
132
+ # When passed a block, yields TranscriptInstance records from the API.
133
+ # This operation lazily loads records as efficiently as possible until the limit
134
+ # is reached.
135
+ def each
136
+ limits = @version.read_limits
137
+
138
+ page = self.page(page_size: limits[:page_size], )
139
+
140
+ @version.stream(page,
141
+ limit: limits[:limit],
142
+ page_limit: limits[:page_limit]).each {|x| yield x}
143
+ end
144
+
145
+ ##
146
+ # Retrieve a single page of TranscriptInstance records from the API.
147
+ # Request is executed immediately.
148
+ # @param [String] service_sid The unique SID identifier of the Service.
149
+ # @param [String] before_start_time Filter by before StartTime.
150
+ # @param [String] after_start_time Filter by after StartTime.
151
+ # @param [String] before_date_created Filter by before DateCreated.
152
+ # @param [String] after_date_created Filter by after DateCreated.
153
+ # @param [String] status Filter by status.
154
+ # @param [String] language_code Filter by Language Code.
155
+ # @param [String] source_sid Filter by SourceSid.
156
+ # @param [String] page_token PageToken provided by the API
157
+ # @param [Integer] page_number Page Number, this value is simply for client state
158
+ # @param [Integer] page_size Number of records to return, defaults to 50
159
+ # @return [Page] Page of TranscriptInstance
160
+ def page(service_sid: :unset, before_start_time: :unset, after_start_time: :unset, before_date_created: :unset, after_date_created: :unset, status: :unset, language_code: :unset, source_sid: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
161
+ params = Twilio::Values.of({
162
+
163
+ 'ServiceSid' => service_sid,
164
+
165
+ 'BeforeStartTime' => before_start_time,
166
+
167
+ 'AfterStartTime' => after_start_time,
168
+
169
+ 'BeforeDateCreated' => before_date_created,
170
+
171
+ 'AfterDateCreated' => after_date_created,
172
+
173
+ 'Status' => status,
174
+
175
+ 'LanguageCode' => language_code,
176
+
177
+ 'SourceSid' => source_sid,
178
+
179
+ 'PageToken' => page_token,
180
+ 'Page' => page_number,
181
+ 'PageSize' => page_size,
182
+ })
183
+
184
+ response = @version.page('GET', @uri, params: params)
185
+
186
+ TranscriptPage.new(@version, response, @solution)
187
+ end
188
+
189
+ ##
190
+ # Retrieve a single page of TranscriptInstance records from the API.
191
+ # Request is executed immediately.
192
+ # @param [String] target_url API-generated URL for the requested results page
193
+ # @return [Page] Page of TranscriptInstance
194
+ def get_page(target_url)
195
+ response = @version.domain.request(
196
+ 'GET',
197
+ target_url
198
+ )
199
+ TranscriptPage.new(@version, response, @solution)
200
+ end
201
+
202
+
203
+
204
+ # Provide a user friendly representation
205
+ def to_s
206
+ '#<Twilio.Intelligence.V2.TranscriptList>'
207
+ end
208
+ end
209
+
210
+
211
+ ##
212
+ #PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
213
+ class TranscriptContext < InstanceContext
214
+ ##
215
+ # Initialize the TranscriptContext
216
+ # @param [Version] version Version that contains the resource
217
+ # @param [String] sid A 34 character string that uniquely identifies this Transcript.
218
+ # @return [TranscriptContext] TranscriptContext
219
+ def initialize(version, sid)
220
+ super(version)
221
+
222
+ # Path Solution
223
+ @solution = { sid: sid, }
224
+ @uri = "/Transcripts/#{@solution[:sid]}"
225
+
226
+ # Dependents
227
+ @sentences = nil
228
+ @operator_results = nil
229
+ @media = nil
230
+ end
231
+ ##
232
+ # Delete the TranscriptInstance
233
+ # @return [Boolean] True if delete succeeds, false otherwise
234
+ def delete
235
+
236
+ @version.delete('DELETE', @uri)
237
+ end
238
+
239
+ ##
240
+ # Fetch the TranscriptInstance
241
+ # @param [Boolean] redacted Grant access to PII Redacted/Unredacted Transcript. The default is `true` to access redacted Transcript.
242
+ # @return [TranscriptInstance] Fetched TranscriptInstance
243
+ def fetch(
244
+ redacted: :unset
245
+ )
246
+
247
+ params = Twilio::Values.of({
248
+ 'Redacted' => redacted,
249
+ })
250
+ payload = @version.fetch('GET', @uri, params: params)
251
+ TranscriptInstance.new(
252
+ @version,
253
+ payload,
254
+ sid: @solution[:sid],
255
+ )
256
+ end
257
+
258
+ ##
259
+ # Access the sentences
260
+ # @return [SentenceList]
261
+ # @return [SentenceContext]
262
+ def sentences
263
+ unless @sentences
264
+ @sentences = SentenceList.new(
265
+ @version, transcript_sid: @solution[:sid], )
266
+ end
267
+ @sentences
268
+ end
269
+ ##
270
+ # Access the operator_results
271
+ # @return [OperatorResultList]
272
+ # @return [OperatorResultContext] if sid was passed.
273
+ def operator_results(operator_sid=:unset)
274
+
275
+ raise ArgumentError, 'operator_sid cannot be nil' if operator_sid.nil?
276
+
277
+ if operator_sid != :unset
278
+ return OperatorResultContext.new(@version, @solution[:sid],operator_sid )
279
+ end
280
+
281
+ unless @operator_results
282
+ @operator_results = OperatorResultList.new(
283
+ @version, transcript_sid: @solution[:sid], )
284
+ end
285
+
286
+ @operator_results
287
+ end
288
+ ##
289
+ # Access the media
290
+ # @return [MediaList]
291
+ # @return [MediaContext]
292
+ def media
293
+ MediaContext.new(
294
+ @version,
295
+ @solution[:sid]
296
+ )
297
+ end
298
+
299
+ ##
300
+ # Provide a user friendly representation
301
+ def to_s
302
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
303
+ "#<Twilio.Intelligence.V2.TranscriptContext #{context}>"
304
+ end
305
+
306
+ ##
307
+ # Provide a detailed, user friendly representation
308
+ def inspect
309
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
310
+ "#<Twilio.Intelligence.V2.TranscriptContext #{context}>"
311
+ end
312
+ end
313
+
314
+ class TranscriptPage < Page
315
+ ##
316
+ # Initialize the TranscriptPage
317
+ # @param [Version] version Version that contains the resource
318
+ # @param [Response] response Response from the API
319
+ # @param [Hash] solution Path solution for the resource
320
+ # @return [TranscriptPage] TranscriptPage
321
+ def initialize(version, response, solution)
322
+ super(version, response)
323
+
324
+ # Path Solution
325
+ @solution = solution
326
+ end
327
+
328
+ ##
329
+ # Build an instance of TranscriptInstance
330
+ # @param [Hash] payload Payload response from the API
331
+ # @return [TranscriptInstance] TranscriptInstance
332
+ def get_instance(payload)
333
+ TranscriptInstance.new(@version, payload)
334
+ end
335
+
336
+ ##
337
+ # Provide a user friendly representation
338
+ def to_s
339
+ '<Twilio.Intelligence.V2.TranscriptPage>'
340
+ end
341
+ end
342
+ class TranscriptInstance < InstanceResource
343
+ ##
344
+ # Initialize the TranscriptInstance
345
+ # @param [Version] version Version that contains the resource
346
+ # @param [Hash] payload payload that contains response from Twilio
347
+ # @param [String] account_sid The SID of the
348
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Transcript
349
+ # resource.
350
+ # @param [String] sid The SID of the Call resource to fetch.
351
+ # @return [TranscriptInstance] TranscriptInstance
352
+ def initialize(version, payload , sid: nil)
353
+ super(version)
354
+
355
+ # Marshaled Properties
356
+ @properties = {
357
+ 'account_sid' => payload['account_sid'],
358
+ 'service_sid' => payload['service_sid'],
359
+ 'sid' => payload['sid'],
360
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
361
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
362
+ 'status' => payload['status'],
363
+ 'channel' => payload['channel'],
364
+ 'data_logging' => payload['data_logging'],
365
+ 'language_code' => payload['language_code'],
366
+ 'customer_key' => payload['customer_key'],
367
+ 'media_start_time' => Twilio.deserialize_iso8601_datetime(payload['media_start_time']),
368
+ 'duration' => payload['duration'] == nil ? payload['duration'] : payload['duration'].to_i,
369
+ 'url' => payload['url'],
370
+ 'redaction' => payload['redaction'],
371
+ 'links' => payload['links'],
372
+ }
373
+
374
+ # Context
375
+ @instance_context = nil
376
+ @params = { 'sid' => sid || @properties['sid'] , }
377
+ end
378
+
379
+ ##
380
+ # Generate an instance context for the instance, the context is capable of
381
+ # performing various actions. All instance actions are proxied to the context
382
+ # @return [TranscriptContext] CallContext for this CallInstance
383
+ def context
384
+ unless @instance_context
385
+ @instance_context = TranscriptContext.new(@version , @params['sid'])
386
+ end
387
+ @instance_context
388
+ end
389
+
390
+ ##
391
+ # @return [String] The unique SID identifier of the Account.
392
+ def account_sid
393
+ @properties['account_sid']
394
+ end
395
+
396
+ ##
397
+ # @return [String] The unique SID identifier of the Service.
398
+ def service_sid
399
+ @properties['service_sid']
400
+ end
401
+
402
+ ##
403
+ # @return [String] A 34 character string that uniquely identifies this Transcript.
404
+ def sid
405
+ @properties['sid']
406
+ end
407
+
408
+ ##
409
+ # @return [Time] The date that this Transcript was created, given in ISO 8601 format.
410
+ def date_created
411
+ @properties['date_created']
412
+ end
413
+
414
+ ##
415
+ # @return [Time] The date that this Transcript was updated, given in ISO 8601 format.
416
+ def date_updated
417
+ @properties['date_updated']
418
+ end
419
+
420
+ ##
421
+ # @return [Status]
422
+ def status
423
+ @properties['status']
424
+ end
425
+
426
+ ##
427
+ # @return [Hash] Media Channel describing Transcript Source and Participant Mapping
428
+ def channel
429
+ @properties['channel']
430
+ end
431
+
432
+ ##
433
+ # @return [Boolean] Data logging allows Twilio to improve the quality of the speech recognition through using customer data to refine its speech recognition models.
434
+ def data_logging
435
+ @properties['data_logging']
436
+ end
437
+
438
+ ##
439
+ # @return [String] The default language code of the audio.
440
+ def language_code
441
+ @properties['language_code']
442
+ end
443
+
444
+ ##
445
+ # @return [String]
446
+ def customer_key
447
+ @properties['customer_key']
448
+ end
449
+
450
+ ##
451
+ # @return [Time] The date that this Transcript's media was started, given in ISO 8601 format.
452
+ def media_start_time
453
+ @properties['media_start_time']
454
+ end
455
+
456
+ ##
457
+ # @return [String] The duration of this Transcript's source
458
+ def duration
459
+ @properties['duration']
460
+ end
461
+
462
+ ##
463
+ # @return [String] The URL of this resource.
464
+ def url
465
+ @properties['url']
466
+ end
467
+
468
+ ##
469
+ # @return [Boolean] If the transcript has been redacted, a redacted alternative of the transcript will be available.
470
+ def redaction
471
+ @properties['redaction']
472
+ end
473
+
474
+ ##
475
+ # @return [Hash]
476
+ def links
477
+ @properties['links']
478
+ end
479
+
480
+ ##
481
+ # Delete the TranscriptInstance
482
+ # @return [Boolean] True if delete succeeds, false otherwise
483
+ def delete
484
+
485
+ context.delete
486
+ end
487
+
488
+ ##
489
+ # Fetch the TranscriptInstance
490
+ # @param [Boolean] redacted Grant access to PII Redacted/Unredacted Transcript. The default is `true` to access redacted Transcript.
491
+ # @return [TranscriptInstance] Fetched TranscriptInstance
492
+ def fetch(
493
+ redacted: :unset
494
+ )
495
+
496
+ context.fetch(
497
+ redacted: redacted,
498
+ )
499
+ end
500
+
501
+ ##
502
+ # Access the sentences
503
+ # @return [sentences] sentences
504
+ def sentences
505
+ context.sentences
506
+ end
507
+
508
+ ##
509
+ # Access the operator_results
510
+ # @return [operator_results] operator_results
511
+ def operator_results
512
+ context.operator_results
513
+ end
514
+
515
+ ##
516
+ # Access the media
517
+ # @return [media] media
518
+ def media
519
+ context.media
520
+ end
521
+
522
+ ##
523
+ # Provide a user friendly representation
524
+ def to_s
525
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
526
+ "<Twilio.Intelligence.V2.TranscriptInstance #{values}>"
527
+ end
528
+
529
+ ##
530
+ # Provide a detailed, user friendly representation
531
+ def inspect
532
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
533
+ "<Twilio.Intelligence.V2.TranscriptInstance #{values}>"
534
+ end
535
+ end
536
+
537
+ end
538
+ end
539
+ end
540
+ end
@@ -0,0 +1,64 @@
1
+ ##
2
+ # This code was generated by
3
+ # ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
4
+ # | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
5
+ # | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
6
+ #
7
+ # Twilio - Intelligence
8
+ # This is the public Twilio REST API.
9
+ #
10
+ # NOTE: This class is auto generated by OpenAPI Generator.
11
+ # https://openapi-generator.tech
12
+ # Do not edit the class manually.
13
+ #
14
+
15
+ module Twilio
16
+ module REST
17
+ class Intelligence
18
+ class V2 < Version
19
+ ##
20
+ # Initialize the V2 version of Intelligence
21
+ def initialize(domain)
22
+ super
23
+ @version = 'v2'
24
+ @services = nil
25
+ @transcripts = nil
26
+ end
27
+
28
+ ##
29
+ # @param [String] sid A 34 character string that uniquely identifies this Service.
30
+ # @return [Twilio::REST::Intelligence::V2::ServiceContext] if sid was passed.
31
+ # @return [Twilio::REST::Intelligence::V2::ServiceList]
32
+ def services(sid=:unset)
33
+ if sid.nil?
34
+ raise ArgumentError, 'sid cannot be nil'
35
+ end
36
+ if sid == :unset
37
+ @services ||= ServiceList.new self
38
+ else
39
+ ServiceContext.new(self, sid)
40
+ end
41
+ end
42
+ ##
43
+ # @param [String] sid A 34 character string that uniquely identifies this Transcript.
44
+ # @return [Twilio::REST::Intelligence::V2::TranscriptContext] if sid was passed.
45
+ # @return [Twilio::REST::Intelligence::V2::TranscriptList]
46
+ def transcripts(sid=:unset)
47
+ if sid.nil?
48
+ raise ArgumentError, 'sid cannot be nil'
49
+ end
50
+ if sid == :unset
51
+ @transcripts ||= TranscriptList.new self
52
+ else
53
+ TranscriptContext.new(self, sid)
54
+ end
55
+ end
56
+ ##
57
+ # Provide a user friendly representation
58
+ def to_s
59
+ '<Twilio::REST::Intelligence::V2>';
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,6 @@
1
+ module Twilio
2
+ module REST
3
+ class Intelligence < IntelligenceBase;
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,38 @@
1
+ ##
2
+ # This code was generated by
3
+ # ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
4
+ # | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
5
+ # | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
6
+ #
7
+ # NOTE: This class is auto generated by OpenAPI Generator.
8
+ # https://openapi-generator.tech
9
+ # Do not edit the class manually.
10
+ # frozen_string_literal: true
11
+ module Twilio
12
+ module REST
13
+ class IntelligenceBase < Domain
14
+ ##
15
+ # Initialize intelligence domain
16
+ #
17
+ # @param twilio - The twilio client
18
+ #
19
+ def initialize(twilio)
20
+ super(twilio)
21
+ @base_url = "https://intelligence.twilio.com"
22
+ @host = "intelligence.twilio.com"
23
+ @port = 443
24
+ @v2 = nil
25
+ end
26
+
27
+ def v2
28
+ @v2 ||= Intelligence::V2.new self
29
+ end
30
+
31
+ ##
32
+ # Provide a user friendly representation
33
+ def to_s
34
+ '<Twilio::REST::Intelligence::V2>';
35
+ end
36
+ end
37
+ end
38
+ end
@@ -305,6 +305,7 @@ module Twilio
305
305
  'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
306
306
  'url' => payload['url'],
307
307
  'mock' => payload['mock'],
308
+ 'errors' => payload['errors'],
308
309
  }
309
310
 
310
311
  # Context
@@ -467,6 +468,12 @@ module Twilio
467
468
  @properties['mock']
468
469
  end
469
470
 
471
+ ##
472
+ # @return [Array<Hash>] Details indicating why a campaign registration failed. These errors can indicate one or more fields that were incorrect or did not meet review requirements.
473
+ def errors
474
+ @properties['errors']
475
+ end
476
+
470
477
  ##
471
478
  # Delete the UsAppToPersonInstance
472
479
  # @return [Boolean] True if delete succeeds, false otherwise