twilio-ruby 7.3.0 → 7.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,328 @@
1
+ ##
2
+ # This code was generated by
3
+ # ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
4
+ # | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
5
+ # | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
6
+ #
7
+ # Twilio - Assistants
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 Assistants < AssistantsBase
19
+ class V1 < Version
20
+ class SessionList < ListResource
21
+
22
+ ##
23
+ # Initialize the SessionList
24
+ # @param [Version] version Version that contains the resource
25
+ # @return [SessionList] SessionList
26
+ def initialize(version)
27
+ super(version)
28
+ # Path Solution
29
+ @solution = { }
30
+ @uri = "/Sessions"
31
+
32
+ end
33
+
34
+ ##
35
+ # Lists SessionInstance records from the API as a list.
36
+ # Unlike stream(), this operation is eager and will load `limit` records into
37
+ # memory before returning.
38
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
39
+ # guarantees to never return more than limit. Default is no limit
40
+ # @param [Integer] page_size Number of records to fetch per request, when
41
+ # not set will use the default value of 50 records. If no page_size is defined
42
+ # but a limit is defined, stream() will attempt to read the limit with the most
43
+ # efficient page size, i.e. min(limit, 1000)
44
+ # @return [Array] Array of up to limit results
45
+ def list(limit: nil, page_size: nil)
46
+ self.stream(
47
+ limit: limit,
48
+ page_size: page_size
49
+ ).entries
50
+ end
51
+
52
+ ##
53
+ # Streams Instance records from the API as an Enumerable.
54
+ # This operation lazily loads records as efficiently as possible until the limit
55
+ # is reached.
56
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
57
+ # guarantees to never return more than limit. Default is no limit
58
+ # @param [Integer] page_size Number of records to fetch per request, when
59
+ # not set will use the default value of 50 records. If no page_size is defined
60
+ # but a limit is defined, stream() will attempt to read the limit with the most
61
+ # efficient page size, i.e. min(limit, 1000)
62
+ # @return [Enumerable] Enumerable that will yield up to limit results
63
+ def stream(limit: nil, page_size: nil)
64
+ limits = @version.read_limits(limit, page_size)
65
+
66
+ page = self.page(
67
+ page_size: limits[:page_size], )
68
+
69
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
70
+ end
71
+
72
+ ##
73
+ # When passed a block, yields SessionInstance records from the API.
74
+ # This operation lazily loads records as efficiently as possible until the limit
75
+ # is reached.
76
+ def each
77
+ limits = @version.read_limits
78
+
79
+ page = self.page(page_size: limits[:page_size], )
80
+
81
+ @version.stream(page,
82
+ limit: limits[:limit],
83
+ page_limit: limits[:page_limit]).each {|x| yield x}
84
+ end
85
+
86
+ ##
87
+ # Retrieve a single page of SessionInstance records from the API.
88
+ # Request is executed immediately.
89
+ # @param [String] page_token PageToken provided by the API
90
+ # @param [Integer] page_number Page Number, this value is simply for client state
91
+ # @param [Integer] page_size Number of records to return, defaults to 50
92
+ # @return [Page] Page of SessionInstance
93
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
94
+ params = Twilio::Values.of({
95
+ 'PageToken' => page_token,
96
+ 'Page' => page_number,
97
+ 'PageSize' => page_size,
98
+ })
99
+
100
+ response = @version.page('GET', @uri, params: params)
101
+
102
+ SessionPage.new(@version, response, @solution)
103
+ end
104
+
105
+ ##
106
+ # Retrieve a single page of SessionInstance records from the API.
107
+ # Request is executed immediately.
108
+ # @param [String] target_url API-generated URL for the requested results page
109
+ # @return [Page] Page of SessionInstance
110
+ def get_page(target_url)
111
+ response = @version.domain.request(
112
+ 'GET',
113
+ target_url
114
+ )
115
+ SessionPage.new(@version, response, @solution)
116
+ end
117
+
118
+
119
+
120
+ # Provide a user friendly representation
121
+ def to_s
122
+ '#<Twilio.Assistants.V1.SessionList>'
123
+ end
124
+ end
125
+
126
+
127
+ class SessionContext < InstanceContext
128
+ ##
129
+ # Initialize the SessionContext
130
+ # @param [Version] version Version that contains the resource
131
+ # @param [String] id
132
+ # @return [SessionContext] SessionContext
133
+ def initialize(version, id)
134
+ super(version)
135
+
136
+ # Path Solution
137
+ @solution = { id: id, }
138
+ @uri = "/Sessions/#{@solution[:id]}"
139
+
140
+ # Dependents
141
+ @messages = nil
142
+ end
143
+ ##
144
+ # Fetch the SessionInstance
145
+ # @return [SessionInstance] Fetched SessionInstance
146
+ def fetch
147
+
148
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
149
+
150
+ payload = @version.fetch('GET', @uri, headers: headers)
151
+ SessionInstance.new(
152
+ @version,
153
+ payload,
154
+ id: @solution[:id],
155
+ )
156
+ end
157
+
158
+ ##
159
+ # Access the messages
160
+ # @return [MessageList]
161
+ # @return [MessageContext]
162
+ def messages
163
+ unless @messages
164
+ @messages = MessageList.new(
165
+ @version, )
166
+ end
167
+ @messages
168
+ end
169
+
170
+ ##
171
+ # Provide a user friendly representation
172
+ def to_s
173
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
174
+ "#<Twilio.Assistants.V1.SessionContext #{context}>"
175
+ end
176
+
177
+ ##
178
+ # Provide a detailed, user friendly representation
179
+ def inspect
180
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
181
+ "#<Twilio.Assistants.V1.SessionContext #{context}>"
182
+ end
183
+ end
184
+
185
+ class SessionPage < Page
186
+ ##
187
+ # Initialize the SessionPage
188
+ # @param [Version] version Version that contains the resource
189
+ # @param [Response] response Response from the API
190
+ # @param [Hash] solution Path solution for the resource
191
+ # @return [SessionPage] SessionPage
192
+ def initialize(version, response, solution)
193
+ super(version, response)
194
+
195
+ # Path Solution
196
+ @solution = solution
197
+ end
198
+
199
+ ##
200
+ # Build an instance of SessionInstance
201
+ # @param [Hash] payload Payload response from the API
202
+ # @return [SessionInstance] SessionInstance
203
+ def get_instance(payload)
204
+ SessionInstance.new(@version, payload)
205
+ end
206
+
207
+ ##
208
+ # Provide a user friendly representation
209
+ def to_s
210
+ '<Twilio.Assistants.V1.SessionPage>'
211
+ end
212
+ end
213
+ class SessionInstance < InstanceResource
214
+ ##
215
+ # Initialize the SessionInstance
216
+ # @param [Version] version Version that contains the resource
217
+ # @param [Hash] payload payload that contains response from Twilio
218
+ # @param [String] account_sid The SID of the
219
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Session
220
+ # resource.
221
+ # @param [String] sid The SID of the Call resource to fetch.
222
+ # @return [SessionInstance] SessionInstance
223
+ def initialize(version, payload , id: nil)
224
+ super(version)
225
+
226
+ # Marshaled Properties
227
+ @properties = {
228
+ 'id' => payload['id'],
229
+ 'account_sid' => payload['account_sid'],
230
+ 'assistant_id' => payload['assistant_id'],
231
+ 'verified' => payload['verified'],
232
+ 'identity' => payload['identity'],
233
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
234
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
235
+ }
236
+
237
+ # Context
238
+ @instance_context = nil
239
+ @params = { 'id' => id || @properties['id'] , }
240
+ end
241
+
242
+ ##
243
+ # Generate an instance context for the instance, the context is capable of
244
+ # performing various actions. All instance actions are proxied to the context
245
+ # @return [SessionContext] CallContext for this CallInstance
246
+ def context
247
+ unless @instance_context
248
+ @instance_context = SessionContext.new(@version , @params['id'])
249
+ end
250
+ @instance_context
251
+ end
252
+
253
+ ##
254
+ # @return [String] The Session ID.
255
+ def id
256
+ @properties['id']
257
+ end
258
+
259
+ ##
260
+ # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Session resource.
261
+ def account_sid
262
+ @properties['account_sid']
263
+ end
264
+
265
+ ##
266
+ # @return [String] The Assistant ID.
267
+ def assistant_id
268
+ @properties['assistant_id']
269
+ end
270
+
271
+ ##
272
+ # @return [Boolean] True if the session is verified.
273
+ def verified
274
+ @properties['verified']
275
+ end
276
+
277
+ ##
278
+ # @return [String] The unique identity of user for the session.
279
+ def identity
280
+ @properties['identity']
281
+ end
282
+
283
+ ##
284
+ # @return [Time] The date and time in GMT when the Session was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
285
+ def date_created
286
+ @properties['date_created']
287
+ end
288
+
289
+ ##
290
+ # @return [Time] The date and time in GMT when the Session was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
291
+ def date_updated
292
+ @properties['date_updated']
293
+ end
294
+
295
+ ##
296
+ # Fetch the SessionInstance
297
+ # @return [SessionInstance] Fetched SessionInstance
298
+ def fetch
299
+
300
+ context.fetch
301
+ end
302
+
303
+ ##
304
+ # Access the messages
305
+ # @return [messages] messages
306
+ def messages
307
+ context.messages
308
+ end
309
+
310
+ ##
311
+ # Provide a user friendly representation
312
+ def to_s
313
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
314
+ "<Twilio.Assistants.V1.SessionInstance #{values}>"
315
+ end
316
+
317
+ ##
318
+ # Provide a detailed, user friendly representation
319
+ def inspect
320
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
321
+ "<Twilio.Assistants.V1.SessionInstance #{values}>"
322
+ end
323
+ end
324
+
325
+ end
326
+ end
327
+ end
328
+ end