twilio-ruby 6.0.1 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,226 @@
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 TranscriptContext < InstanceContext
21
+
22
+ class MediaList < ListResource
23
+ ##
24
+ # Initialize the MediaList
25
+ # @param [Version] version Version that contains the resource
26
+ # @return [MediaList] MediaList
27
+ def initialize(version, sid: nil)
28
+ super(version)
29
+ # Path Solution
30
+ @solution = { sid: sid }
31
+
32
+
33
+ end
34
+
35
+
36
+
37
+ # Provide a user friendly representation
38
+ def to_s
39
+ '#<Twilio.Intelligence.V2.MediaList>'
40
+ end
41
+ end
42
+
43
+
44
+ ##
45
+ #PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
46
+ class MediaContext < InstanceContext
47
+ ##
48
+ # Initialize the MediaContext
49
+ # @param [Version] version Version that contains the resource
50
+ # @param [String] sid The unique SID identifier of the Transcript.
51
+ # @return [MediaContext] MediaContext
52
+ def initialize(version, sid)
53
+ super(version)
54
+
55
+ # Path Solution
56
+ @solution = { sid: sid, }
57
+ @uri = "/Transcripts/#{@solution[:sid]}/Media"
58
+
59
+
60
+ end
61
+ ##
62
+ # Fetch the MediaInstance
63
+ # @param [Boolean] redacted Grant access to PII Redacted/Unredacted Media. The default is `true` to access redacted media.
64
+ # @return [MediaInstance] Fetched MediaInstance
65
+ def fetch(
66
+ redacted: :unset
67
+ )
68
+
69
+ params = Twilio::Values.of({
70
+ 'Redacted' => redacted,
71
+ })
72
+ payload = @version.fetch('GET', @uri, params: params)
73
+ MediaInstance.new(
74
+ @version,
75
+ payload,
76
+ sid: @solution[:sid],
77
+ )
78
+ end
79
+
80
+
81
+ ##
82
+ # Provide a user friendly representation
83
+ def to_s
84
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
85
+ "#<Twilio.Intelligence.V2.MediaContext #{context}>"
86
+ end
87
+
88
+ ##
89
+ # Provide a detailed, user friendly representation
90
+ def inspect
91
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
92
+ "#<Twilio.Intelligence.V2.MediaContext #{context}>"
93
+ end
94
+ end
95
+
96
+ class MediaPage < Page
97
+ ##
98
+ # Initialize the MediaPage
99
+ # @param [Version] version Version that contains the resource
100
+ # @param [Response] response Response from the API
101
+ # @param [Hash] solution Path solution for the resource
102
+ # @return [MediaPage] MediaPage
103
+ def initialize(version, response, solution)
104
+ super(version, response)
105
+
106
+ # Path Solution
107
+ @solution = solution
108
+ end
109
+
110
+ ##
111
+ # Build an instance of MediaInstance
112
+ # @param [Hash] payload Payload response from the API
113
+ # @return [MediaInstance] MediaInstance
114
+ def get_instance(payload)
115
+ MediaInstance.new(@version, payload, sid: @solution[:sid])
116
+ end
117
+
118
+ ##
119
+ # Provide a user friendly representation
120
+ def to_s
121
+ '<Twilio.Intelligence.V2.MediaPage>'
122
+ end
123
+ end
124
+ class MediaInstance < InstanceResource
125
+ ##
126
+ # Initialize the MediaInstance
127
+ # @param [Version] version Version that contains the resource
128
+ # @param [Hash] payload payload that contains response from Twilio
129
+ # @param [String] account_sid The SID of the
130
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Media
131
+ # resource.
132
+ # @param [String] sid The SID of the Call resource to fetch.
133
+ # @return [MediaInstance] MediaInstance
134
+ def initialize(version, payload , sid: nil)
135
+ super(version)
136
+
137
+ # Marshaled Properties
138
+ @properties = {
139
+ 'account_sid' => payload['account_sid'],
140
+ 'media_url' => payload['media_url'],
141
+ 'service_sid' => payload['service_sid'],
142
+ 'sid' => payload['sid'],
143
+ 'url' => payload['url'],
144
+ }
145
+
146
+ # Context
147
+ @instance_context = nil
148
+ @params = { 'sid' => sid || @properties['sid'] , }
149
+ end
150
+
151
+ ##
152
+ # Generate an instance context for the instance, the context is capable of
153
+ # performing various actions. All instance actions are proxied to the context
154
+ # @return [MediaContext] CallContext for this CallInstance
155
+ def context
156
+ unless @instance_context
157
+ @instance_context = MediaContext.new(@version , @params['sid'])
158
+ end
159
+ @instance_context
160
+ end
161
+
162
+ ##
163
+ # @return [String] The unique SID identifier of the Account.
164
+ def account_sid
165
+ @properties['account_sid']
166
+ end
167
+
168
+ ##
169
+ # @return [String] Downloadable URL for media, if stored in Twilio AI.
170
+ def media_url
171
+ @properties['media_url']
172
+ end
173
+
174
+ ##
175
+ # @return [String] The unique SID identifier of the Service.
176
+ def service_sid
177
+ @properties['service_sid']
178
+ end
179
+
180
+ ##
181
+ # @return [String] The unique SID identifier of the Transcript.
182
+ def sid
183
+ @properties['sid']
184
+ end
185
+
186
+ ##
187
+ # @return [String] The URL of this resource.
188
+ def url
189
+ @properties['url']
190
+ end
191
+
192
+ ##
193
+ # Fetch the MediaInstance
194
+ # @param [Boolean] redacted Grant access to PII Redacted/Unredacted Media. The default is `true` to access redacted media.
195
+ # @return [MediaInstance] Fetched MediaInstance
196
+ def fetch(
197
+ redacted: :unset
198
+ )
199
+
200
+ context.fetch(
201
+ redacted: redacted,
202
+ )
203
+ end
204
+
205
+ ##
206
+ # Provide a user friendly representation
207
+ def to_s
208
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
209
+ "<Twilio.Intelligence.V2.MediaInstance #{values}>"
210
+ end
211
+
212
+ ##
213
+ # Provide a detailed, user friendly representation
214
+ def inspect
215
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
216
+ "<Twilio.Intelligence.V2.MediaInstance #{values}>"
217
+ end
218
+ end
219
+
220
+ end
221
+ end
222
+ end
223
+ end
224
+ end
225
+
226
+
@@ -0,0 +1,383 @@
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 TranscriptContext < InstanceContext
21
+
22
+ class OperatorResultList < ListResource
23
+ ##
24
+ # Initialize the OperatorResultList
25
+ # @param [Version] version Version that contains the resource
26
+ # @return [OperatorResultList] OperatorResultList
27
+ def initialize(version, transcript_sid: nil)
28
+ super(version)
29
+ # Path Solution
30
+ @solution = { transcript_sid: transcript_sid }
31
+ @uri = "/Transcripts/#{@solution[:transcript_sid]}/OperatorResults"
32
+
33
+ end
34
+
35
+ ##
36
+ # Lists OperatorResultInstance records from the API as a list.
37
+ # Unlike stream(), this operation is eager and will load `limit` records into
38
+ # memory before returning.
39
+ # @param [Boolean] redacted Grant access to PII redacted/unredacted Language Understanding operator. The default is True.
40
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
41
+ # guarantees to never return more than limit. Default is no limit
42
+ # @param [Integer] page_size Number of records to fetch per request, when
43
+ # not set will use the default value of 50 records. If no page_size is defined
44
+ # but a limit is defined, stream() will attempt to read the limit with the most
45
+ # efficient page size, i.e. min(limit, 1000)
46
+ # @return [Array] Array of up to limit results
47
+ def list(redacted: :unset, limit: nil, page_size: nil)
48
+ self.stream(
49
+ redacted: redacted,
50
+ limit: limit,
51
+ page_size: page_size
52
+ ).entries
53
+ end
54
+
55
+ ##
56
+ # Streams Instance records from the API as an Enumerable.
57
+ # This operation lazily loads records as efficiently as possible until the limit
58
+ # is reached.
59
+ # @param [Boolean] redacted Grant access to PII redacted/unredacted Language Understanding operator. The default is True.
60
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
61
+ # guarantees to never return more than limit. Default is no limit
62
+ # @param [Integer] page_size Number of records to fetch per request, when
63
+ # not set will use the default value of 50 records. If no page_size is defined
64
+ # but a limit is defined, stream() will attempt to read the limit with the most
65
+ # efficient page size, i.e. min(limit, 1000)
66
+ # @return [Enumerable] Enumerable that will yield up to limit results
67
+ def stream(redacted: :unset, limit: nil, page_size: nil)
68
+ limits = @version.read_limits(limit, page_size)
69
+
70
+ page = self.page(
71
+ redacted: redacted,
72
+ page_size: limits[:page_size], )
73
+
74
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
75
+ end
76
+
77
+ ##
78
+ # When passed a block, yields OperatorResultInstance records from the API.
79
+ # This operation lazily loads records as efficiently as possible until the limit
80
+ # is reached.
81
+ def each
82
+ limits = @version.read_limits
83
+
84
+ page = self.page(page_size: limits[:page_size], )
85
+
86
+ @version.stream(page,
87
+ limit: limits[:limit],
88
+ page_limit: limits[:page_limit]).each {|x| yield x}
89
+ end
90
+
91
+ ##
92
+ # Retrieve a single page of OperatorResultInstance records from the API.
93
+ # Request is executed immediately.
94
+ # @param [Boolean] redacted Grant access to PII redacted/unredacted Language Understanding operator. The default is True.
95
+ # @param [String] page_token PageToken provided by the API
96
+ # @param [Integer] page_number Page Number, this value is simply for client state
97
+ # @param [Integer] page_size Number of records to return, defaults to 50
98
+ # @return [Page] Page of OperatorResultInstance
99
+ def page(redacted: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
100
+ params = Twilio::Values.of({
101
+
102
+ 'Redacted' => redacted,
103
+
104
+ 'PageToken' => page_token,
105
+ 'Page' => page_number,
106
+ 'PageSize' => page_size,
107
+ })
108
+
109
+ response = @version.page('GET', @uri, params: params)
110
+
111
+ OperatorResultPage.new(@version, response, @solution)
112
+ end
113
+
114
+ ##
115
+ # Retrieve a single page of OperatorResultInstance records from the API.
116
+ # Request is executed immediately.
117
+ # @param [String] target_url API-generated URL for the requested results page
118
+ # @return [Page] Page of OperatorResultInstance
119
+ def get_page(target_url)
120
+ response = @version.domain.request(
121
+ 'GET',
122
+ target_url
123
+ )
124
+ OperatorResultPage.new(@version, response, @solution)
125
+ end
126
+
127
+
128
+
129
+ # Provide a user friendly representation
130
+ def to_s
131
+ '#<Twilio.Intelligence.V2.OperatorResultList>'
132
+ end
133
+ end
134
+
135
+
136
+ ##
137
+ #PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
138
+ class OperatorResultContext < InstanceContext
139
+ ##
140
+ # Initialize the OperatorResultContext
141
+ # @param [Version] version Version that contains the resource
142
+ # @param [String] transcript_sid A 34 character string that uniquely identifies this Transcript.
143
+ # @param [String] operator_sid A 34 character string that identifies this Language Understanding operator sid.
144
+ # @return [OperatorResultContext] OperatorResultContext
145
+ def initialize(version, transcript_sid, operator_sid)
146
+ super(version)
147
+
148
+ # Path Solution
149
+ @solution = { transcript_sid: transcript_sid, operator_sid: operator_sid, }
150
+ @uri = "/Transcripts/#{@solution[:transcript_sid]}/OperatorResults/#{@solution[:operator_sid]}"
151
+
152
+
153
+ end
154
+ ##
155
+ # Fetch the OperatorResultInstance
156
+ # @param [Boolean] redacted Grant access to PII redacted/unredacted Language Understanding operator. The default is True.
157
+ # @return [OperatorResultInstance] Fetched OperatorResultInstance
158
+ def fetch(
159
+ redacted: :unset
160
+ )
161
+
162
+ params = Twilio::Values.of({
163
+ 'Redacted' => redacted,
164
+ })
165
+ payload = @version.fetch('GET', @uri, params: params)
166
+ OperatorResultInstance.new(
167
+ @version,
168
+ payload,
169
+ transcript_sid: @solution[:transcript_sid],
170
+ operator_sid: @solution[:operator_sid],
171
+ )
172
+ end
173
+
174
+
175
+ ##
176
+ # Provide a user friendly representation
177
+ def to_s
178
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
179
+ "#<Twilio.Intelligence.V2.OperatorResultContext #{context}>"
180
+ end
181
+
182
+ ##
183
+ # Provide a detailed, user friendly representation
184
+ def inspect
185
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
186
+ "#<Twilio.Intelligence.V2.OperatorResultContext #{context}>"
187
+ end
188
+ end
189
+
190
+ class OperatorResultPage < Page
191
+ ##
192
+ # Initialize the OperatorResultPage
193
+ # @param [Version] version Version that contains the resource
194
+ # @param [Response] response Response from the API
195
+ # @param [Hash] solution Path solution for the resource
196
+ # @return [OperatorResultPage] OperatorResultPage
197
+ def initialize(version, response, solution)
198
+ super(version, response)
199
+
200
+ # Path Solution
201
+ @solution = solution
202
+ end
203
+
204
+ ##
205
+ # Build an instance of OperatorResultInstance
206
+ # @param [Hash] payload Payload response from the API
207
+ # @return [OperatorResultInstance] OperatorResultInstance
208
+ def get_instance(payload)
209
+ OperatorResultInstance.new(@version, payload, transcript_sid: @solution[:transcript_sid])
210
+ end
211
+
212
+ ##
213
+ # Provide a user friendly representation
214
+ def to_s
215
+ '<Twilio.Intelligence.V2.OperatorResultPage>'
216
+ end
217
+ end
218
+ class OperatorResultInstance < InstanceResource
219
+ ##
220
+ # Initialize the OperatorResultInstance
221
+ # @param [Version] version Version that contains the resource
222
+ # @param [Hash] payload payload that contains response from Twilio
223
+ # @param [String] account_sid The SID of the
224
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this OperatorResult
225
+ # resource.
226
+ # @param [String] sid The SID of the Call resource to fetch.
227
+ # @return [OperatorResultInstance] OperatorResultInstance
228
+ def initialize(version, payload , transcript_sid: nil, operator_sid: nil)
229
+ super(version)
230
+
231
+ # Marshaled Properties
232
+ @properties = {
233
+ 'operator_type' => payload['operator_type'],
234
+ 'name' => payload['name'],
235
+ 'operator_sid' => payload['operator_sid'],
236
+ 'extract_match' => payload['extract_match'],
237
+ 'match_probability' => payload['match_probability'],
238
+ 'normalized_result' => payload['normalized_result'],
239
+ 'utterance_results' => payload['utterance_results'],
240
+ 'utterance_match' => payload['utterance_match'],
241
+ 'predicted_label' => payload['predicted_label'],
242
+ 'predicted_probability' => payload['predicted_probability'],
243
+ 'label_probabilities' => payload['label_probabilities'],
244
+ 'extract_results' => payload['extract_results'],
245
+ 'transcript_sid' => payload['transcript_sid'],
246
+ 'url' => payload['url'],
247
+ }
248
+
249
+ # Context
250
+ @instance_context = nil
251
+ @params = { 'transcript_sid' => transcript_sid || @properties['transcript_sid'] ,'operator_sid' => operator_sid || @properties['operator_sid'] , }
252
+ end
253
+
254
+ ##
255
+ # Generate an instance context for the instance, the context is capable of
256
+ # performing various actions. All instance actions are proxied to the context
257
+ # @return [OperatorResultContext] CallContext for this CallInstance
258
+ def context
259
+ unless @instance_context
260
+ @instance_context = OperatorResultContext.new(@version , @params['transcript_sid'], @params['operator_sid'])
261
+ end
262
+ @instance_context
263
+ end
264
+
265
+ ##
266
+ # @return [OperatorType]
267
+ def operator_type
268
+ @properties['operator_type']
269
+ end
270
+
271
+ ##
272
+ # @return [String] The name of the applied Language Understanding.
273
+ def name
274
+ @properties['name']
275
+ end
276
+
277
+ ##
278
+ # @return [String] A 34 character string that identifies this Language Understanding operator sid.
279
+ def operator_sid
280
+ @properties['operator_sid']
281
+ end
282
+
283
+ ##
284
+ # @return [Boolean] Boolean to tell if extract Language Understanding Processing model matches results.
285
+ def extract_match
286
+ @properties['extract_match']
287
+ end
288
+
289
+ ##
290
+ # @return [Float] Percentage of 'matching' class needed to consider a sentence matches
291
+ def match_probability
292
+ @properties['match_probability']
293
+ end
294
+
295
+ ##
296
+ # @return [String] Normalized output of extraction stage which matches Label.
297
+ def normalized_result
298
+ @properties['normalized_result']
299
+ end
300
+
301
+ ##
302
+ # @return [Array<Hash>] List of mapped utterance object which matches sentences.
303
+ def utterance_results
304
+ @properties['utterance_results']
305
+ end
306
+
307
+ ##
308
+ # @return [Boolean] Boolean to tell if Utterance matches results.
309
+ def utterance_match
310
+ @properties['utterance_match']
311
+ end
312
+
313
+ ##
314
+ # @return [String] The 'matching' class. This might be available on conversation classify model outputs.
315
+ def predicted_label
316
+ @properties['predicted_label']
317
+ end
318
+
319
+ ##
320
+ # @return [Float] Percentage of 'matching' class needed to consider a sentence matches.
321
+ def predicted_probability
322
+ @properties['predicted_probability']
323
+ end
324
+
325
+ ##
326
+ # @return [Hash] The labels probabilities. This might be available on conversation classify model outputs.
327
+ def label_probabilities
328
+ @properties['label_probabilities']
329
+ end
330
+
331
+ ##
332
+ # @return [Hash] List of text extraction results. This might be available on classify-extract model outputs.
333
+ def extract_results
334
+ @properties['extract_results']
335
+ end
336
+
337
+ ##
338
+ # @return [String] A 34 character string that uniquely identifies this Transcript.
339
+ def transcript_sid
340
+ @properties['transcript_sid']
341
+ end
342
+
343
+ ##
344
+ # @return [String] The URL of this resource.
345
+ def url
346
+ @properties['url']
347
+ end
348
+
349
+ ##
350
+ # Fetch the OperatorResultInstance
351
+ # @param [Boolean] redacted Grant access to PII redacted/unredacted Language Understanding operator. The default is True.
352
+ # @return [OperatorResultInstance] Fetched OperatorResultInstance
353
+ def fetch(
354
+ redacted: :unset
355
+ )
356
+
357
+ context.fetch(
358
+ redacted: redacted,
359
+ )
360
+ end
361
+
362
+ ##
363
+ # Provide a user friendly representation
364
+ def to_s
365
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
366
+ "<Twilio.Intelligence.V2.OperatorResultInstance #{values}>"
367
+ end
368
+
369
+ ##
370
+ # Provide a detailed, user friendly representation
371
+ def inspect
372
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
373
+ "<Twilio.Intelligence.V2.OperatorResultInstance #{values}>"
374
+ end
375
+ end
376
+
377
+ end
378
+ end
379
+ end
380
+ end
381
+ end
382
+
383
+