twilio-ruby 7.3.1 → 7.3.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,362 @@
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 AssistantsToolList < ListResource
23
+
24
+ ##
25
+ # Initialize the AssistantsToolList
26
+ # @param [Version] version Version that contains the resource
27
+ # @return [AssistantsToolList] AssistantsToolList
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]}/Tools"
33
+
34
+ end
35
+
36
+ ##
37
+ # Lists AssistantsToolInstance 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 AssistantsToolInstance 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 AssistantsToolInstance 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 AssistantsToolInstance
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
+ AssistantsToolPage.new(@version, response, @solution)
105
+ end
106
+
107
+ ##
108
+ # Retrieve a single page of AssistantsToolInstance 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 AssistantsToolInstance
112
+ def get_page(target_url)
113
+ response = @version.domain.request(
114
+ 'GET',
115
+ target_url
116
+ )
117
+ AssistantsToolPage.new(@version, response, @solution)
118
+ end
119
+
120
+
121
+
122
+ # Provide a user friendly representation
123
+ def to_s
124
+ '#<Twilio.Assistants.V1.AssistantsToolList>'
125
+ end
126
+ end
127
+
128
+
129
+ class AssistantsToolContext < InstanceContext
130
+ ##
131
+ # Initialize the AssistantsToolContext
132
+ # @param [Version] version Version that contains the resource
133
+ # @param [String] assistant_id The assistant ID.
134
+ # @param [String] id The tool ID.
135
+ # @return [AssistantsToolContext] AssistantsToolContext
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]}/Tools/#{@solution[:id]}"
142
+
143
+
144
+ end
145
+ ##
146
+ # Create the AssistantsToolInstance
147
+ # @return [AssistantsToolInstance] Created AssistantsToolInstance
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
+ AssistantsToolInstance.new(
154
+ @version,
155
+ payload,
156
+ assistant_id: @solution[:assistant_id],
157
+ id: @solution[:id],
158
+ )
159
+ end
160
+
161
+ ##
162
+ # Delete the AssistantsToolInstance
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.AssistantsToolContext #{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.AssistantsToolContext #{context}>"
184
+ end
185
+ end
186
+
187
+ class AssistantsToolPage < Page
188
+ ##
189
+ # Initialize the AssistantsToolPage
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 [AssistantsToolPage] AssistantsToolPage
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 AssistantsToolInstance
203
+ # @param [Hash] payload Payload response from the API
204
+ # @return [AssistantsToolInstance] AssistantsToolInstance
205
+ def get_instance(payload)
206
+ AssistantsToolInstance.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.AssistantsToolPage>'
213
+ end
214
+ end
215
+ class AssistantsToolInstance < InstanceResource
216
+ ##
217
+ # Initialize the AssistantsToolInstance
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 AssistantsTool
222
+ # resource.
223
+ # @param [String] sid The SID of the Call resource to fetch.
224
+ # @return [AssistantsToolInstance] AssistantsToolInstance
225
+ def initialize(version, payload , assistant_id: nil, id: nil)
226
+ super(version)
227
+
228
+ # Marshaled Properties
229
+ @properties = {
230
+ 'account_sid' => payload['account_sid'],
231
+ 'description' => payload['description'],
232
+ 'enabled' => payload['enabled'],
233
+ 'id' => payload['id'],
234
+ 'meta' => payload['meta'],
235
+ 'name' => payload['name'],
236
+ 'requires_auth' => payload['requires_auth'],
237
+ 'type' => payload['type'],
238
+ 'url' => payload['url'],
239
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
240
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
241
+ }
242
+
243
+ # Context
244
+ @instance_context = nil
245
+ @params = { 'assistant_id' => assistant_id || @properties['assistant_id'] ,'id' => id || @properties['id'] , }
246
+ end
247
+
248
+ ##
249
+ # Generate an instance context for the instance, the context is capable of
250
+ # performing various actions. All instance actions are proxied to the context
251
+ # @return [AssistantsToolContext] CallContext for this CallInstance
252
+ def context
253
+ unless @instance_context
254
+ @instance_context = AssistantsToolContext.new(@version , @params['assistant_id'], @params['id'])
255
+ end
256
+ @instance_context
257
+ end
258
+
259
+ ##
260
+ # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Tool resource.
261
+ def account_sid
262
+ @properties['account_sid']
263
+ end
264
+
265
+ ##
266
+ # @return [String] The description of the tool.
267
+ def description
268
+ @properties['description']
269
+ end
270
+
271
+ ##
272
+ # @return [Boolean] True if the tool is enabled.
273
+ def enabled
274
+ @properties['enabled']
275
+ end
276
+
277
+ ##
278
+ # @return [String] The tool ID.
279
+ def id
280
+ @properties['id']
281
+ end
282
+
283
+ ##
284
+ # @return [Hash] The metadata related to method, url, input_schema to used with the Tool.
285
+ def meta
286
+ @properties['meta']
287
+ end
288
+
289
+ ##
290
+ # @return [String] The name of the tool.
291
+ def name
292
+ @properties['name']
293
+ end
294
+
295
+ ##
296
+ # @return [Boolean] The authentication requirement for the tool.
297
+ def requires_auth
298
+ @properties['requires_auth']
299
+ end
300
+
301
+ ##
302
+ # @return [String] The type of the tool. ('WEBHOOK')
303
+ def type
304
+ @properties['type']
305
+ end
306
+
307
+ ##
308
+ # @return [String] The url of the tool resource.
309
+ def url
310
+ @properties['url']
311
+ end
312
+
313
+ ##
314
+ # @return [Time] The date and time in GMT when the Tool was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
315
+ def date_created
316
+ @properties['date_created']
317
+ end
318
+
319
+ ##
320
+ # @return [Time] The date and time in GMT when the Tool was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
321
+ def date_updated
322
+ @properties['date_updated']
323
+ end
324
+
325
+ ##
326
+ # Create the AssistantsToolInstance
327
+ # @return [AssistantsToolInstance] Created AssistantsToolInstance
328
+ def create
329
+
330
+ context.create
331
+ end
332
+
333
+ ##
334
+ # Delete the AssistantsToolInstance
335
+ # @return [Boolean] True if delete succeeds, false otherwise
336
+ def delete
337
+
338
+ context.delete
339
+ end
340
+
341
+ ##
342
+ # Provide a user friendly representation
343
+ def to_s
344
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
345
+ "<Twilio.Assistants.V1.AssistantsToolInstance #{values}>"
346
+ end
347
+
348
+ ##
349
+ # Provide a detailed, user friendly representation
350
+ def inspect
351
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
352
+ "<Twilio.Assistants.V1.AssistantsToolInstance #{values}>"
353
+ end
354
+ end
355
+
356
+ end
357
+ end
358
+ end
359
+ end
360
+ end
361
+
362
+
@@ -17,7 +17,7 @@ module Twilio
17
17
  module REST
18
18
  class Assistants < AssistantsBase
19
19
  class V1 < Version
20
- class Assistant < InstanceContext
20
+ class AssistantContext < InstanceContext
21
21
 
22
22
  class FeedbackList < ListResource
23
23
 
@@ -0,0 +1,201 @@
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 MessageList < ListResource
23
+
24
+ class AssistantsV1ServiceAssistantSendMessageRequest
25
+ # @param [identity]: [String] The unique identity of user for the session.
26
+ # @param [session_id]: [String] The unique name for the session.
27
+ # @param [body]: [String] The query to ask the assistant.
28
+ # @param [webhook]: [String] The webhook url to call after the assistant has generated a response or report an error.
29
+ # @param [mode]: [String] one of the modes 'chat', 'email' or 'voice'
30
+ attr_accessor :identity, :session_id, :body, :webhook, :mode
31
+ def initialize(payload)
32
+ @identity = payload["identity"]
33
+ @session_id = payload["session_id"]
34
+ @body = payload["body"]
35
+ @webhook = payload["webhook"]
36
+ @mode = payload["mode"]
37
+ end
38
+ def to_json(options = {})
39
+ {
40
+ identity: @identity,
41
+ session_id: @session_id,
42
+ body: @body,
43
+ webhook: @webhook,
44
+ mode: @mode,
45
+ }.to_json(options)
46
+ end
47
+ end
48
+
49
+ ##
50
+ # Initialize the MessageList
51
+ # @param [Version] version Version that contains the resource
52
+ # @return [MessageList] MessageList
53
+ def initialize(version, id: nil)
54
+ super(version)
55
+ # Path Solution
56
+ @solution = { id: id }
57
+ @uri = "/Assistants/#{@solution[:id]}/Messages"
58
+
59
+ end
60
+ ##
61
+ # Create the MessageInstance
62
+ # @param [AssistantsV1ServiceAssistantSendMessageRequest] assistants_v1_service_assistant_send_message_request
63
+ # @return [MessageInstance] Created MessageInstance
64
+ def create(assistants_v1_service_assistant_send_message_request: nil
65
+ )
66
+
67
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
68
+ headers['Content-Type'] = 'application/json'
69
+ payload = @version.create('POST', @uri, headers: headers, data: assistants_v1_service_assistant_send_message_request.to_json)
70
+ MessageInstance.new(
71
+ @version,
72
+ payload,
73
+ id: @solution[:id],
74
+ )
75
+ end
76
+
77
+
78
+
79
+
80
+ # Provide a user friendly representation
81
+ def to_s
82
+ '#<Twilio.Assistants.V1.MessageList>'
83
+ end
84
+ end
85
+
86
+ class MessagePage < Page
87
+ ##
88
+ # Initialize the MessagePage
89
+ # @param [Version] version Version that contains the resource
90
+ # @param [Response] response Response from the API
91
+ # @param [Hash] solution Path solution for the resource
92
+ # @return [MessagePage] MessagePage
93
+ def initialize(version, response, solution)
94
+ super(version, response)
95
+
96
+ # Path Solution
97
+ @solution = solution
98
+ end
99
+
100
+ ##
101
+ # Build an instance of MessageInstance
102
+ # @param [Hash] payload Payload response from the API
103
+ # @return [MessageInstance] MessageInstance
104
+ def get_instance(payload)
105
+ MessageInstance.new(@version, payload, id: @solution[:id])
106
+ end
107
+
108
+ ##
109
+ # Provide a user friendly representation
110
+ def to_s
111
+ '<Twilio.Assistants.V1.MessagePage>'
112
+ end
113
+ end
114
+ class MessageInstance < InstanceResource
115
+ ##
116
+ # Initialize the MessageInstance
117
+ # @param [Version] version Version that contains the resource
118
+ # @param [Hash] payload payload that contains response from Twilio
119
+ # @param [String] account_sid The SID of the
120
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Message
121
+ # resource.
122
+ # @param [String] sid The SID of the Call resource to fetch.
123
+ # @return [MessageInstance] MessageInstance
124
+ def initialize(version, payload , id: nil)
125
+ super(version)
126
+
127
+ # Marshaled Properties
128
+ @properties = {
129
+ 'status' => payload['status'],
130
+ 'flagged' => payload['flagged'],
131
+ 'aborted' => payload['aborted'],
132
+ 'session_id' => payload['session_id'],
133
+ 'account_sid' => payload['account_sid'],
134
+ 'body' => payload['body'],
135
+ 'error' => payload['error'],
136
+ }
137
+ end
138
+
139
+
140
+ ##
141
+ # @return [String] success or failure based on whether the request successfully generated a response.
142
+ def status
143
+ @properties['status']
144
+ end
145
+
146
+ ##
147
+ # @return [Boolean] If successful, this property will denote whether the response was flagged or not.
148
+ def flagged
149
+ @properties['flagged']
150
+ end
151
+
152
+ ##
153
+ # @return [Boolean] This property will denote whether the request was aborted or not.
154
+ def aborted
155
+ @properties['aborted']
156
+ end
157
+
158
+ ##
159
+ # @return [String] The unique name for the session.
160
+ def session_id
161
+ @properties['session_id']
162
+ end
163
+
164
+ ##
165
+ # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that sent the Message.
166
+ def account_sid
167
+ @properties['account_sid']
168
+ end
169
+
170
+ ##
171
+ # @return [String] If successful, the body of the generated response
172
+ def body
173
+ @properties['body']
174
+ end
175
+
176
+ ##
177
+ # @return [String] The error message if generation was not successful
178
+ def error
179
+ @properties['error']
180
+ end
181
+
182
+ ##
183
+ # Provide a user friendly representation
184
+ def to_s
185
+ "<Twilio.Assistants.V1.MessageInstance>"
186
+ end
187
+
188
+ ##
189
+ # Provide a detailed, user friendly representation
190
+ def inspect
191
+ "<Twilio.Assistants.V1.MessageInstance>"
192
+ end
193
+ end
194
+
195
+ end
196
+ end
197
+ end
198
+ end
199
+ end
200
+
201
+