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,250 @@
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 SentenceList < ListResource
23
+ ##
24
+ # Initialize the SentenceList
25
+ # @param [Version] version Version that contains the resource
26
+ # @return [SentenceList] SentenceList
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]}/Sentences"
32
+
33
+ end
34
+
35
+ ##
36
+ # Lists SentenceInstance 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 Sentences. The default is `true` to access redacted sentences.
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 Sentences. The default is `true` to access redacted sentences.
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 SentenceInstance 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 SentenceInstance records from the API.
93
+ # Request is executed immediately.
94
+ # @param [Boolean] redacted Grant access to PII Redacted/Unredacted Sentences. The default is `true` to access redacted sentences.
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 SentenceInstance
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
+ SentencePage.new(@version, response, @solution)
112
+ end
113
+
114
+ ##
115
+ # Retrieve a single page of SentenceInstance 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 SentenceInstance
119
+ def get_page(target_url)
120
+ response = @version.domain.request(
121
+ 'GET',
122
+ target_url
123
+ )
124
+ SentencePage.new(@version, response, @solution)
125
+ end
126
+
127
+
128
+
129
+ # Provide a user friendly representation
130
+ def to_s
131
+ '#<Twilio.Intelligence.V2.SentenceList>'
132
+ end
133
+ end
134
+
135
+ class SentencePage < Page
136
+ ##
137
+ # Initialize the SentencePage
138
+ # @param [Version] version Version that contains the resource
139
+ # @param [Response] response Response from the API
140
+ # @param [Hash] solution Path solution for the resource
141
+ # @return [SentencePage] SentencePage
142
+ def initialize(version, response, solution)
143
+ super(version, response)
144
+
145
+ # Path Solution
146
+ @solution = solution
147
+ end
148
+
149
+ ##
150
+ # Build an instance of SentenceInstance
151
+ # @param [Hash] payload Payload response from the API
152
+ # @return [SentenceInstance] SentenceInstance
153
+ def get_instance(payload)
154
+ SentenceInstance.new(@version, payload, transcript_sid: @solution[:transcript_sid])
155
+ end
156
+
157
+ ##
158
+ # Provide a user friendly representation
159
+ def to_s
160
+ '<Twilio.Intelligence.V2.SentencePage>'
161
+ end
162
+ end
163
+ class SentenceInstance < InstanceResource
164
+ ##
165
+ # Initialize the SentenceInstance
166
+ # @param [Version] version Version that contains the resource
167
+ # @param [Hash] payload payload that contains response from Twilio
168
+ # @param [String] account_sid The SID of the
169
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Sentence
170
+ # resource.
171
+ # @param [String] sid The SID of the Call resource to fetch.
172
+ # @return [SentenceInstance] SentenceInstance
173
+ def initialize(version, payload , transcript_sid: nil)
174
+ super(version)
175
+
176
+ # Marshaled Properties
177
+ @properties = {
178
+ 'media_channel' => payload['media_channel'] == nil ? payload['media_channel'] : payload['media_channel'].to_i,
179
+ 'sentence_index' => payload['sentence_index'] == nil ? payload['sentence_index'] : payload['sentence_index'].to_i,
180
+ 'start_time' => payload['start_time'],
181
+ 'end_time' => payload['end_time'],
182
+ 'transcript' => payload['transcript'],
183
+ 'sid' => payload['sid'],
184
+ 'confidence' => payload['confidence'],
185
+ }
186
+ end
187
+
188
+
189
+ ##
190
+ # @return [String] The channel number.
191
+ def media_channel
192
+ @properties['media_channel']
193
+ end
194
+
195
+ ##
196
+ # @return [String] The index of the sentence in the transcript.
197
+ def sentence_index
198
+ @properties['sentence_index']
199
+ end
200
+
201
+ ##
202
+ # @return [Float] Offset from the beginning of the transcript when this sentence starts.
203
+ def start_time
204
+ @properties['start_time']
205
+ end
206
+
207
+ ##
208
+ # @return [Float] Offset from the beginning of the transcript when this sentence ends.
209
+ def end_time
210
+ @properties['end_time']
211
+ end
212
+
213
+ ##
214
+ # @return [String] Transcript text.
215
+ def transcript
216
+ @properties['transcript']
217
+ end
218
+
219
+ ##
220
+ # @return [String] A 34 character string that uniquely identifies this Sentence.
221
+ def sid
222
+ @properties['sid']
223
+ end
224
+
225
+ ##
226
+ # @return [Float]
227
+ def confidence
228
+ @properties['confidence']
229
+ end
230
+
231
+ ##
232
+ # Provide a user friendly representation
233
+ def to_s
234
+ "<Twilio.Intelligence.V2.SentenceInstance>"
235
+ end
236
+
237
+ ##
238
+ # Provide a detailed, user friendly representation
239
+ def inspect
240
+ "<Twilio.Intelligence.V2.SentenceInstance>"
241
+ end
242
+ end
243
+
244
+ end
245
+ end
246
+ end
247
+ end
248
+ end
249
+
250
+