twilio-ruby 7.3.1 → 7.3.2

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