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,229 @@
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 Knowledge < InstanceContext
21
+
22
+ class ChunkList < ListResource
23
+
24
+ ##
25
+ # Initialize the ChunkList
26
+ # @param [Version] version Version that contains the resource
27
+ # @return [ChunkList] ChunkList
28
+ def initialize(version, id: nil)
29
+ super(version)
30
+ # Path Solution
31
+ @solution = { id: id }
32
+ @uri = "/Knowledge/#{@solution[:id]}/Chunks"
33
+
34
+ end
35
+
36
+ ##
37
+ # Lists ChunkInstance 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 ChunkInstance 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 ChunkInstance 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 ChunkInstance
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
+ ChunkPage.new(@version, response, @solution)
105
+ end
106
+
107
+ ##
108
+ # Retrieve a single page of ChunkInstance 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 ChunkInstance
112
+ def get_page(target_url)
113
+ response = @version.domain.request(
114
+ 'GET',
115
+ target_url
116
+ )
117
+ ChunkPage.new(@version, response, @solution)
118
+ end
119
+
120
+
121
+
122
+ # Provide a user friendly representation
123
+ def to_s
124
+ '#<Twilio.Assistants.V1.ChunkList>'
125
+ end
126
+ end
127
+
128
+ class ChunkPage < Page
129
+ ##
130
+ # Initialize the ChunkPage
131
+ # @param [Version] version Version that contains the resource
132
+ # @param [Response] response Response from the API
133
+ # @param [Hash] solution Path solution for the resource
134
+ # @return [ChunkPage] ChunkPage
135
+ def initialize(version, response, solution)
136
+ super(version, response)
137
+
138
+ # Path Solution
139
+ @solution = solution
140
+ end
141
+
142
+ ##
143
+ # Build an instance of ChunkInstance
144
+ # @param [Hash] payload Payload response from the API
145
+ # @return [ChunkInstance] ChunkInstance
146
+ def get_instance(payload)
147
+ ChunkInstance.new(@version, payload, id: @solution[:id])
148
+ end
149
+
150
+ ##
151
+ # Provide a user friendly representation
152
+ def to_s
153
+ '<Twilio.Assistants.V1.ChunkPage>'
154
+ end
155
+ end
156
+ class ChunkInstance < InstanceResource
157
+ ##
158
+ # Initialize the ChunkInstance
159
+ # @param [Version] version Version that contains the resource
160
+ # @param [Hash] payload payload that contains response from Twilio
161
+ # @param [String] account_sid The SID of the
162
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Chunk
163
+ # resource.
164
+ # @param [String] sid The SID of the Call resource to fetch.
165
+ # @return [ChunkInstance] ChunkInstance
166
+ def initialize(version, payload , id: nil)
167
+ super(version)
168
+
169
+ # Marshaled Properties
170
+ @properties = {
171
+ 'account_sid' => payload['account_sid'],
172
+ 'content' => payload['content'],
173
+ 'metadata' => payload['metadata'],
174
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
175
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
176
+ }
177
+ end
178
+
179
+
180
+ ##
181
+ # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Knowledge resource.
182
+ def account_sid
183
+ @properties['account_sid']
184
+ end
185
+
186
+ ##
187
+ # @return [String] The chunk content.
188
+ def content
189
+ @properties['content']
190
+ end
191
+
192
+ ##
193
+ # @return [Hash] The metadata of the chunk.
194
+ def metadata
195
+ @properties['metadata']
196
+ end
197
+
198
+ ##
199
+ # @return [Time] The date and time in GMT when the Chunk was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
200
+ def date_created
201
+ @properties['date_created']
202
+ end
203
+
204
+ ##
205
+ # @return [Time] The date and time in GMT when the Chunk was updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
206
+ def date_updated
207
+ @properties['date_updated']
208
+ end
209
+
210
+ ##
211
+ # Provide a user friendly representation
212
+ def to_s
213
+ "<Twilio.Assistants.V1.ChunkInstance>"
214
+ end
215
+
216
+ ##
217
+ # Provide a detailed, user friendly representation
218
+ def inspect
219
+ "<Twilio.Assistants.V1.ChunkInstance>"
220
+ end
221
+ end
222
+
223
+ end
224
+ end
225
+ end
226
+ end
227
+ end
228
+
229
+