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,626 @@
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 AssistantList < ListResource
21
+
22
+ class AssistantsV1ServiceCreateAssistantRequest
23
+ # @param [customer_ai]: [AssistantList.AssistantsV1ServiceCustomerAi]
24
+ # @param [name]: [String] The name of the assistant.
25
+ # @param [owner]: [String] The owner/company of the assistant.
26
+ # @param [personality_prompt]: [String] The personality prompt to be used for assistant.
27
+ # @param [segment_credential]: [AssistantList.AssistantsV1ServiceSegmentCredential]
28
+ attr_accessor :customer_ai, :name, :owner, :personality_prompt, :segment_credential
29
+ def initialize(payload)
30
+ @customer_ai = payload["customer_ai"]
31
+ @name = payload["name"]
32
+ @owner = payload["owner"]
33
+ @personality_prompt = payload["personality_prompt"]
34
+ @segment_credential = payload["segment_credential"]
35
+ end
36
+ def to_json(options = {})
37
+ {
38
+ customer_ai: @customer_ai,
39
+ name: @name,
40
+ owner: @owner,
41
+ personality_prompt: @personality_prompt,
42
+ segment_credential: @segment_credential,
43
+ }.to_json(options)
44
+ end
45
+ end
46
+
47
+ class AssistantsV1ServiceCustomerAi
48
+ # @param [perception_engine_enabled]: [Boolean] True if the perception engine is enabled.
49
+ # @param [personalization_engine_enabled]: [Boolean] True if the personalization engine is enabled.
50
+ attr_accessor :perception_engine_enabled, :personalization_engine_enabled
51
+ def initialize(payload)
52
+ @perception_engine_enabled = payload["perception_engine_enabled"]
53
+ @personalization_engine_enabled = payload["personalization_engine_enabled"]
54
+ end
55
+ def to_json(options = {})
56
+ {
57
+ perception_engine_enabled: @perception_engine_enabled,
58
+ personalization_engine_enabled: @personalization_engine_enabled,
59
+ }.to_json(options)
60
+ end
61
+ end
62
+
63
+ class AssistantsV1ServiceSegmentCredential
64
+ # @param [profile_api_key]: [String] The profile API key.
65
+ # @param [space_id]: [String] The space ID.
66
+ # @param [write_key]: [String] The write key.
67
+ attr_accessor :profile_api_key, :space_id, :write_key
68
+ def initialize(payload)
69
+ @profile_api_key = payload["profile_api_key"]
70
+ @space_id = payload["space_id"]
71
+ @write_key = payload["write_key"]
72
+ end
73
+ def to_json(options = {})
74
+ {
75
+ profile_api_key: @profile_api_key,
76
+ space_id: @space_id,
77
+ write_key: @write_key,
78
+ }.to_json(options)
79
+ end
80
+ end
81
+
82
+ class AssistantsV1ServiceUpdateAssistantRequest
83
+ # @param [customer_ai]: [AssistantList.AssistantsV1ServiceCustomerAi]
84
+ # @param [name]: [String] The name of the assistant.
85
+ # @param [owner]: [String] The owner/company of the assistant.
86
+ # @param [personality_prompt]: [String] The personality prompt to be used for assistant.
87
+ # @param [segment_credential]: [AssistantList.AssistantsV1ServiceSegmentCredential]
88
+ attr_accessor :customer_ai, :name, :owner, :personality_prompt, :segment_credential
89
+ def initialize(payload)
90
+ @customer_ai = payload["customer_ai"]
91
+ @name = payload["name"]
92
+ @owner = payload["owner"]
93
+ @personality_prompt = payload["personality_prompt"]
94
+ @segment_credential = payload["segment_credential"]
95
+ end
96
+ def to_json(options = {})
97
+ {
98
+ customer_ai: @customer_ai,
99
+ name: @name,
100
+ owner: @owner,
101
+ personality_prompt: @personality_prompt,
102
+ segment_credential: @segment_credential,
103
+ }.to_json(options)
104
+ end
105
+ end
106
+
107
+ class AssistantsV1ServiceCreateAssistantRequest
108
+ # @param [customer_ai]: [AssistantList.AssistantsV1ServiceCustomerAi]
109
+ # @param [name]: [String] The name of the assistant.
110
+ # @param [owner]: [String] The owner/company of the assistant.
111
+ # @param [personality_prompt]: [String] The personality prompt to be used for assistant.
112
+ # @param [segment_credential]: [AssistantList.AssistantsV1ServiceSegmentCredential]
113
+ attr_accessor :customer_ai, :name, :owner, :personality_prompt, :segment_credential
114
+ def initialize(payload)
115
+ @customer_ai = payload["customer_ai"]
116
+ @name = payload["name"]
117
+ @owner = payload["owner"]
118
+ @personality_prompt = payload["personality_prompt"]
119
+ @segment_credential = payload["segment_credential"]
120
+ end
121
+ def to_json(options = {})
122
+ {
123
+ customer_ai: @customer_ai,
124
+ name: @name,
125
+ owner: @owner,
126
+ personality_prompt: @personality_prompt,
127
+ segment_credential: @segment_credential,
128
+ }.to_json(options)
129
+ end
130
+ end
131
+
132
+ class AssistantsV1ServiceCustomerAi
133
+ # @param [perception_engine_enabled]: [Boolean] True if the perception engine is enabled.
134
+ # @param [personalization_engine_enabled]: [Boolean] True if the personalization engine is enabled.
135
+ attr_accessor :perception_engine_enabled, :personalization_engine_enabled
136
+ def initialize(payload)
137
+ @perception_engine_enabled = payload["perception_engine_enabled"]
138
+ @personalization_engine_enabled = payload["personalization_engine_enabled"]
139
+ end
140
+ def to_json(options = {})
141
+ {
142
+ perception_engine_enabled: @perception_engine_enabled,
143
+ personalization_engine_enabled: @personalization_engine_enabled,
144
+ }.to_json(options)
145
+ end
146
+ end
147
+
148
+ class AssistantsV1ServiceSegmentCredential
149
+ # @param [profile_api_key]: [String] The profile API key.
150
+ # @param [space_id]: [String] The space ID.
151
+ # @param [write_key]: [String] The write key.
152
+ attr_accessor :profile_api_key, :space_id, :write_key
153
+ def initialize(payload)
154
+ @profile_api_key = payload["profile_api_key"]
155
+ @space_id = payload["space_id"]
156
+ @write_key = payload["write_key"]
157
+ end
158
+ def to_json(options = {})
159
+ {
160
+ profile_api_key: @profile_api_key,
161
+ space_id: @space_id,
162
+ write_key: @write_key,
163
+ }.to_json(options)
164
+ end
165
+ end
166
+
167
+ class AssistantsV1ServiceUpdateAssistantRequest
168
+ # @param [customer_ai]: [AssistantList.AssistantsV1ServiceCustomerAi]
169
+ # @param [name]: [String] The name of the assistant.
170
+ # @param [owner]: [String] The owner/company of the assistant.
171
+ # @param [personality_prompt]: [String] The personality prompt to be used for assistant.
172
+ # @param [segment_credential]: [AssistantList.AssistantsV1ServiceSegmentCredential]
173
+ attr_accessor :customer_ai, :name, :owner, :personality_prompt, :segment_credential
174
+ def initialize(payload)
175
+ @customer_ai = payload["customer_ai"]
176
+ @name = payload["name"]
177
+ @owner = payload["owner"]
178
+ @personality_prompt = payload["personality_prompt"]
179
+ @segment_credential = payload["segment_credential"]
180
+ end
181
+ def to_json(options = {})
182
+ {
183
+ customer_ai: @customer_ai,
184
+ name: @name,
185
+ owner: @owner,
186
+ personality_prompt: @personality_prompt,
187
+ segment_credential: @segment_credential,
188
+ }.to_json(options)
189
+ end
190
+ end
191
+
192
+ ##
193
+ # Initialize the AssistantList
194
+ # @param [Version] version Version that contains the resource
195
+ # @return [AssistantList] AssistantList
196
+ def initialize(version)
197
+ super(version)
198
+ # Path Solution
199
+ @solution = { }
200
+ @uri = "/Assistants"
201
+
202
+ end
203
+ ##
204
+ # Create the AssistantInstance
205
+ # @param [AssistantsV1ServiceCreateAssistantRequest] assistants_v1_service_create_assistant_request
206
+ # @return [AssistantInstance] Created AssistantInstance
207
+ def create(assistants_v1_service_create_assistant_request: nil
208
+ )
209
+
210
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
211
+ headers['Content-Type'] = 'application/json'
212
+ payload = @version.create('POST', @uri, headers: headers, data: assistants_v1_service_create_assistant_request.to_json)
213
+ AssistantInstance.new(
214
+ @version,
215
+ payload,
216
+ )
217
+ end
218
+
219
+
220
+ ##
221
+ # Lists AssistantInstance records from the API as a list.
222
+ # Unlike stream(), this operation is eager and will load `limit` records into
223
+ # memory before returning.
224
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
225
+ # guarantees to never return more than limit. Default is no limit
226
+ # @param [Integer] page_size Number of records to fetch per request, when
227
+ # not set will use the default value of 50 records. If no page_size is defined
228
+ # but a limit is defined, stream() will attempt to read the limit with the most
229
+ # efficient page size, i.e. min(limit, 1000)
230
+ # @return [Array] Array of up to limit results
231
+ def list(limit: nil, page_size: nil)
232
+ self.stream(
233
+ limit: limit,
234
+ page_size: page_size
235
+ ).entries
236
+ end
237
+
238
+ ##
239
+ # Streams Instance records from the API as an Enumerable.
240
+ # This operation lazily loads records as efficiently as possible until the limit
241
+ # is reached.
242
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
243
+ # guarantees to never return more than limit. Default is no limit
244
+ # @param [Integer] page_size Number of records to fetch per request, when
245
+ # not set will use the default value of 50 records. If no page_size is defined
246
+ # but a limit is defined, stream() will attempt to read the limit with the most
247
+ # efficient page size, i.e. min(limit, 1000)
248
+ # @return [Enumerable] Enumerable that will yield up to limit results
249
+ def stream(limit: nil, page_size: nil)
250
+ limits = @version.read_limits(limit, page_size)
251
+
252
+ page = self.page(
253
+ page_size: limits[:page_size], )
254
+
255
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
256
+ end
257
+
258
+ ##
259
+ # When passed a block, yields AssistantInstance records from the API.
260
+ # This operation lazily loads records as efficiently as possible until the limit
261
+ # is reached.
262
+ def each
263
+ limits = @version.read_limits
264
+
265
+ page = self.page(page_size: limits[:page_size], )
266
+
267
+ @version.stream(page,
268
+ limit: limits[:limit],
269
+ page_limit: limits[:page_limit]).each {|x| yield x}
270
+ end
271
+
272
+ ##
273
+ # Retrieve a single page of AssistantInstance records from the API.
274
+ # Request is executed immediately.
275
+ # @param [String] page_token PageToken provided by the API
276
+ # @param [Integer] page_number Page Number, this value is simply for client state
277
+ # @param [Integer] page_size Number of records to return, defaults to 50
278
+ # @return [Page] Page of AssistantInstance
279
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
280
+ params = Twilio::Values.of({
281
+ 'PageToken' => page_token,
282
+ 'Page' => page_number,
283
+ 'PageSize' => page_size,
284
+ })
285
+
286
+ response = @version.page('GET', @uri, params: params)
287
+
288
+ AssistantPage.new(@version, response, @solution)
289
+ end
290
+
291
+ ##
292
+ # Retrieve a single page of AssistantInstance records from the API.
293
+ # Request is executed immediately.
294
+ # @param [String] target_url API-generated URL for the requested results page
295
+ # @return [Page] Page of AssistantInstance
296
+ def get_page(target_url)
297
+ response = @version.domain.request(
298
+ 'GET',
299
+ target_url
300
+ )
301
+ AssistantPage.new(@version, response, @solution)
302
+ end
303
+
304
+
305
+
306
+ # Provide a user friendly representation
307
+ def to_s
308
+ '#<Twilio.Assistants.V1.AssistantList>'
309
+ end
310
+ end
311
+
312
+
313
+ class AssistantContext < InstanceContext
314
+ ##
315
+ # Initialize the AssistantContext
316
+ # @param [Version] version Version that contains the resource
317
+ # @param [String] id
318
+ # @return [AssistantContext] AssistantContext
319
+ def initialize(version, id)
320
+ super(version)
321
+
322
+ # Path Solution
323
+ @solution = { id: id, }
324
+ @uri = "/Assistants/#{@solution[:id]}"
325
+
326
+ # Dependents
327
+ @feedbacks = nil
328
+ @messages = nil
329
+ @tools = nil
330
+ end
331
+ ##
332
+ # Delete the AssistantInstance
333
+ # @return [Boolean] True if delete succeeds, false otherwise
334
+ def delete
335
+
336
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
337
+
338
+ @version.delete('DELETE', @uri, headers: headers)
339
+ end
340
+
341
+ ##
342
+ # Fetch the AssistantInstance
343
+ # @return [AssistantInstance] Fetched AssistantInstance
344
+ def fetch
345
+
346
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
347
+
348
+ payload = @version.fetch('GET', @uri, headers: headers)
349
+ AssistantInstance.new(
350
+ @version,
351
+ payload,
352
+ id: @solution[:id],
353
+ )
354
+ end
355
+
356
+ ##
357
+ # Update the AssistantInstance
358
+ # @param [AssistantsV1ServiceUpdateAssistantRequest] assistants_v1_service_update_assistant_request
359
+ # @return [AssistantInstance] Updated AssistantInstance
360
+ def update(assistants_v1_service_update_assistant_request: :unset
361
+ )
362
+
363
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
364
+ headers['Content-Type'] = 'application/json'
365
+ payload = @version.update('PUT', @uri, headers: headers, data: assistants_v1_service_update_assistant_request.to_json)
366
+ AssistantInstance.new(
367
+ @version,
368
+ payload,
369
+ id: @solution[:id],
370
+ )
371
+ end
372
+
373
+ ##
374
+ # Access the feedbacks
375
+ # @return [FeedbackList]
376
+ # @return [FeedbackContext]
377
+ def feedbacks
378
+ unless @feedbacks
379
+ @feedbacks = FeedbackList.new(
380
+ @version, )
381
+ end
382
+ @feedbacks
383
+ end
384
+ ##
385
+ # Access the messages
386
+ # @return [MessageList]
387
+ # @return [MessageContext]
388
+ def messages
389
+ unless @messages
390
+ @messages = MessageList.new(
391
+ @version, )
392
+ end
393
+ @messages
394
+ end
395
+ ##
396
+ # Access the tools
397
+ # @return [ToolList]
398
+ # @return [ToolContext]
399
+ def tools
400
+ unless @tools
401
+ @tools = ToolList.new(
402
+ @version, )
403
+ end
404
+ @tools
405
+ end
406
+
407
+ ##
408
+ # Provide a user friendly representation
409
+ def to_s
410
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
411
+ "#<Twilio.Assistants.V1.AssistantContext #{context}>"
412
+ end
413
+
414
+ ##
415
+ # Provide a detailed, user friendly representation
416
+ def inspect
417
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
418
+ "#<Twilio.Assistants.V1.AssistantContext #{context}>"
419
+ end
420
+ end
421
+
422
+ class AssistantPage < Page
423
+ ##
424
+ # Initialize the AssistantPage
425
+ # @param [Version] version Version that contains the resource
426
+ # @param [Response] response Response from the API
427
+ # @param [Hash] solution Path solution for the resource
428
+ # @return [AssistantPage] AssistantPage
429
+ def initialize(version, response, solution)
430
+ super(version, response)
431
+
432
+ # Path Solution
433
+ @solution = solution
434
+ end
435
+
436
+ ##
437
+ # Build an instance of AssistantInstance
438
+ # @param [Hash] payload Payload response from the API
439
+ # @return [AssistantInstance] AssistantInstance
440
+ def get_instance(payload)
441
+ AssistantInstance.new(@version, payload)
442
+ end
443
+
444
+ ##
445
+ # Provide a user friendly representation
446
+ def to_s
447
+ '<Twilio.Assistants.V1.AssistantPage>'
448
+ end
449
+ end
450
+ class AssistantInstance < InstanceResource
451
+ ##
452
+ # Initialize the AssistantInstance
453
+ # @param [Version] version Version that contains the resource
454
+ # @param [Hash] payload payload that contains response from Twilio
455
+ # @param [String] account_sid The SID of the
456
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Assistant
457
+ # resource.
458
+ # @param [String] sid The SID of the Call resource to fetch.
459
+ # @return [AssistantInstance] AssistantInstance
460
+ def initialize(version, payload , id: nil)
461
+ super(version)
462
+
463
+ # Marshaled Properties
464
+ @properties = {
465
+ 'account_sid' => payload['account_sid'],
466
+ 'customer_ai' => payload['customer_ai'],
467
+ 'id' => payload['id'],
468
+ 'model' => payload['model'],
469
+ 'name' => payload['name'],
470
+ 'owner' => payload['owner'],
471
+ 'personality_prompt' => payload['personality_prompt'],
472
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
473
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
474
+ 'knowledge' => payload['knowledge'],
475
+ 'tools' => payload['tools'],
476
+ }
477
+
478
+ # Context
479
+ @instance_context = nil
480
+ @params = { 'id' => id || @properties['id'] , }
481
+ end
482
+
483
+ ##
484
+ # Generate an instance context for the instance, the context is capable of
485
+ # performing various actions. All instance actions are proxied to the context
486
+ # @return [AssistantContext] CallContext for this CallInstance
487
+ def context
488
+ unless @instance_context
489
+ @instance_context = AssistantContext.new(@version , @params['id'])
490
+ end
491
+ @instance_context
492
+ end
493
+
494
+ ##
495
+ # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Assistant resource.
496
+ def account_sid
497
+ @properties['account_sid']
498
+ end
499
+
500
+ ##
501
+ # @return [Hash] The Personalization and Perception Engine settings.
502
+ def customer_ai
503
+ @properties['customer_ai']
504
+ end
505
+
506
+ ##
507
+ # @return [String] The Assistant ID.
508
+ def id
509
+ @properties['id']
510
+ end
511
+
512
+ ##
513
+ # @return [String] The default model used by the assistant.
514
+ def model
515
+ @properties['model']
516
+ end
517
+
518
+ ##
519
+ # @return [String] The name of the assistant.
520
+ def name
521
+ @properties['name']
522
+ end
523
+
524
+ ##
525
+ # @return [String] The owner/company of the assistant.
526
+ def owner
527
+ @properties['owner']
528
+ end
529
+
530
+ ##
531
+ # @return [String] The personality prompt to be used for assistant.
532
+ def personality_prompt
533
+ @properties['personality_prompt']
534
+ end
535
+
536
+ ##
537
+ # @return [Time] The date and time in GMT when the Assistant was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
538
+ def date_created
539
+ @properties['date_created']
540
+ end
541
+
542
+ ##
543
+ # @return [Time] The date and time in GMT when the Assistant was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
544
+ def date_updated
545
+ @properties['date_updated']
546
+ end
547
+
548
+ ##
549
+ # @return [Array<AssistantsV1ServiceKnowledge>] The list of knowledge sources associated with the assistant.
550
+ def knowledge
551
+ @properties['knowledge']
552
+ end
553
+
554
+ ##
555
+ # @return [Array<AssistantsV1ServiceTool>] The list of tools associated with the assistant.
556
+ def tools
557
+ @properties['tools']
558
+ end
559
+
560
+ ##
561
+ # Delete the AssistantInstance
562
+ # @return [Boolean] True if delete succeeds, false otherwise
563
+ def delete
564
+
565
+ context.delete
566
+ end
567
+
568
+ ##
569
+ # Fetch the AssistantInstance
570
+ # @return [AssistantInstance] Fetched AssistantInstance
571
+ def fetch
572
+
573
+ context.fetch
574
+ end
575
+
576
+ ##
577
+ # Update the AssistantInstance
578
+ # @param [AssistantsV1ServiceUpdateAssistantRequest] assistants_v1_service_update_assistant_request
579
+ # @return [AssistantInstance] Updated AssistantInstance
580
+ def update(assistants_v1_service_update_assistant_request: :unset
581
+ )
582
+
583
+ context.update(
584
+ )
585
+ end
586
+
587
+ ##
588
+ # Access the feedbacks
589
+ # @return [feedbacks] feedbacks
590
+ def feedbacks
591
+ context.feedbacks
592
+ end
593
+
594
+ ##
595
+ # Access the messages
596
+ # @return [messages] messages
597
+ def messages
598
+ context.messages
599
+ end
600
+
601
+ ##
602
+ # Access the tools
603
+ # @return [tools] tools
604
+ def tools
605
+ context.tools
606
+ end
607
+
608
+ ##
609
+ # Provide a user friendly representation
610
+ def to_s
611
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
612
+ "<Twilio.Assistants.V1.AssistantInstance #{values}>"
613
+ end
614
+
615
+ ##
616
+ # Provide a detailed, user friendly representation
617
+ def inspect
618
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
619
+ "<Twilio.Assistants.V1.AssistantInstance #{values}>"
620
+ end
621
+ end
622
+
623
+ end
624
+ end
625
+ end
626
+ end