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,264 @@
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 PolicyList < ListResource
21
+
22
+ ##
23
+ # Initialize the PolicyList
24
+ # @param [Version] version Version that contains the resource
25
+ # @return [PolicyList] PolicyList
26
+ def initialize(version)
27
+ super(version)
28
+ # Path Solution
29
+ @solution = { }
30
+ @uri = "/Policies"
31
+
32
+ end
33
+
34
+ ##
35
+ # Lists PolicyInstance 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 [String] tool_id The tool ID.
39
+ # @param [String] knowledge_id The knowledge ID.
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(tool_id: :unset, knowledge_id: :unset, limit: nil, page_size: nil)
48
+ self.stream(
49
+ tool_id: tool_id,
50
+ knowledge_id: knowledge_id,
51
+ limit: limit,
52
+ page_size: page_size
53
+ ).entries
54
+ end
55
+
56
+ ##
57
+ # Streams Instance records from the API as an Enumerable.
58
+ # This operation lazily loads records as efficiently as possible until the limit
59
+ # is reached.
60
+ # @param [String] tool_id The tool ID.
61
+ # @param [String] knowledge_id The knowledge ID.
62
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
63
+ # guarantees to never return more than limit. Default is no limit
64
+ # @param [Integer] page_size Number of records to fetch per request, when
65
+ # not set will use the default value of 50 records. If no page_size is defined
66
+ # but a limit is defined, stream() will attempt to read the limit with the most
67
+ # efficient page size, i.e. min(limit, 1000)
68
+ # @return [Enumerable] Enumerable that will yield up to limit results
69
+ def stream(tool_id: :unset, knowledge_id: :unset, limit: nil, page_size: nil)
70
+ limits = @version.read_limits(limit, page_size)
71
+
72
+ page = self.page(
73
+ tool_id: tool_id,
74
+ knowledge_id: knowledge_id,
75
+ page_size: limits[:page_size], )
76
+
77
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
78
+ end
79
+
80
+ ##
81
+ # When passed a block, yields PolicyInstance records from the API.
82
+ # This operation lazily loads records as efficiently as possible until the limit
83
+ # is reached.
84
+ def each
85
+ limits = @version.read_limits
86
+
87
+ page = self.page(page_size: limits[:page_size], )
88
+
89
+ @version.stream(page,
90
+ limit: limits[:limit],
91
+ page_limit: limits[:page_limit]).each {|x| yield x}
92
+ end
93
+
94
+ ##
95
+ # Retrieve a single page of PolicyInstance records from the API.
96
+ # Request is executed immediately.
97
+ # @param [String] tool_id The tool ID.
98
+ # @param [String] knowledge_id The knowledge ID.
99
+ # @param [String] page_token PageToken provided by the API
100
+ # @param [Integer] page_number Page Number, this value is simply for client state
101
+ # @param [Integer] page_size Number of records to return, defaults to 50
102
+ # @return [Page] Page of PolicyInstance
103
+ def page(tool_id: :unset, knowledge_id: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
104
+ params = Twilio::Values.of({
105
+ 'ToolId' => tool_id,
106
+ 'KnowledgeId' => knowledge_id,
107
+ 'PageToken' => page_token,
108
+ 'Page' => page_number,
109
+ 'PageSize' => page_size,
110
+ })
111
+
112
+ response = @version.page('GET', @uri, params: params)
113
+
114
+ PolicyPage.new(@version, response, @solution)
115
+ end
116
+
117
+ ##
118
+ # Retrieve a single page of PolicyInstance records from the API.
119
+ # Request is executed immediately.
120
+ # @param [String] target_url API-generated URL for the requested results page
121
+ # @return [Page] Page of PolicyInstance
122
+ def get_page(target_url)
123
+ response = @version.domain.request(
124
+ 'GET',
125
+ target_url
126
+ )
127
+ PolicyPage.new(@version, response, @solution)
128
+ end
129
+
130
+
131
+
132
+ # Provide a user friendly representation
133
+ def to_s
134
+ '#<Twilio.Assistants.V1.PolicyList>'
135
+ end
136
+ end
137
+
138
+ class PolicyPage < Page
139
+ ##
140
+ # Initialize the PolicyPage
141
+ # @param [Version] version Version that contains the resource
142
+ # @param [Response] response Response from the API
143
+ # @param [Hash] solution Path solution for the resource
144
+ # @return [PolicyPage] PolicyPage
145
+ def initialize(version, response, solution)
146
+ super(version, response)
147
+
148
+ # Path Solution
149
+ @solution = solution
150
+ end
151
+
152
+ ##
153
+ # Build an instance of PolicyInstance
154
+ # @param [Hash] payload Payload response from the API
155
+ # @return [PolicyInstance] PolicyInstance
156
+ def get_instance(payload)
157
+ PolicyInstance.new(@version, payload)
158
+ end
159
+
160
+ ##
161
+ # Provide a user friendly representation
162
+ def to_s
163
+ '<Twilio.Assistants.V1.PolicyPage>'
164
+ end
165
+ end
166
+ class PolicyInstance < InstanceResource
167
+ ##
168
+ # Initialize the PolicyInstance
169
+ # @param [Version] version Version that contains the resource
170
+ # @param [Hash] payload payload that contains response from Twilio
171
+ # @param [String] account_sid The SID of the
172
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Policy
173
+ # resource.
174
+ # @param [String] sid The SID of the Call resource to fetch.
175
+ # @return [PolicyInstance] PolicyInstance
176
+ def initialize(version, payload )
177
+ super(version)
178
+
179
+ # Marshaled Properties
180
+ @properties = {
181
+ 'id' => payload['id'],
182
+ 'name' => payload['name'],
183
+ 'description' => payload['description'],
184
+ 'account_sid' => payload['account_sid'],
185
+ 'user_sid' => payload['user_sid'],
186
+ 'type' => payload['type'],
187
+ 'policy_details' => payload['policy_details'],
188
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
189
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
190
+ }
191
+ end
192
+
193
+
194
+ ##
195
+ # @return [String] The Policy ID.
196
+ def id
197
+ @properties['id']
198
+ end
199
+
200
+ ##
201
+ # @return [String] The name of the policy.
202
+ def name
203
+ @properties['name']
204
+ end
205
+
206
+ ##
207
+ # @return [String] The description of the policy.
208
+ def description
209
+ @properties['description']
210
+ end
211
+
212
+ ##
213
+ # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Policy resource.
214
+ def account_sid
215
+ @properties['account_sid']
216
+ end
217
+
218
+ ##
219
+ # @return [String] The SID of the User that created the Policy resource.
220
+ def user_sid
221
+ @properties['user_sid']
222
+ end
223
+
224
+ ##
225
+ # @return [String] The type of the policy.
226
+ def type
227
+ @properties['type']
228
+ end
229
+
230
+ ##
231
+ # @return [Hash] The details of the policy based on the type.
232
+ def policy_details
233
+ @properties['policy_details']
234
+ end
235
+
236
+ ##
237
+ # @return [Time] The date and time in GMT when the Policy was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
238
+ def date_created
239
+ @properties['date_created']
240
+ end
241
+
242
+ ##
243
+ # @return [Time] The date and time in GMT when the Policy was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
244
+ def date_updated
245
+ @properties['date_updated']
246
+ end
247
+
248
+ ##
249
+ # Provide a user friendly representation
250
+ def to_s
251
+ "<Twilio.Assistants.V1.PolicyInstance>"
252
+ end
253
+
254
+ ##
255
+ # Provide a detailed, user friendly representation
256
+ def inspect
257
+ "<Twilio.Assistants.V1.PolicyInstance>"
258
+ end
259
+ end
260
+
261
+ end
262
+ end
263
+ end
264
+ end
@@ -0,0 +1,264 @@
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 Session < InstanceContext
21
+
22
+ class MessageList < ListResource
23
+
24
+ ##
25
+ # Initialize the MessageList
26
+ # @param [Version] version Version that contains the resource
27
+ # @return [MessageList] MessageList
28
+ def initialize(version, session_id: nil)
29
+ super(version)
30
+ # Path Solution
31
+ @solution = { session_id: session_id }
32
+ @uri = "/Sessions/#{@solution[:session_id]}/Messages"
33
+
34
+ end
35
+
36
+ ##
37
+ # Lists MessageInstance 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 MessageInstance 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 MessageInstance 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 MessageInstance
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
+ MessagePage.new(@version, response, @solution)
105
+ end
106
+
107
+ ##
108
+ # Retrieve a single page of MessageInstance 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 MessageInstance
112
+ def get_page(target_url)
113
+ response = @version.domain.request(
114
+ 'GET',
115
+ target_url
116
+ )
117
+ MessagePage.new(@version, response, @solution)
118
+ end
119
+
120
+
121
+
122
+ # Provide a user friendly representation
123
+ def to_s
124
+ '#<Twilio.Assistants.V1.MessageList>'
125
+ end
126
+ end
127
+
128
+ class MessagePage < Page
129
+ ##
130
+ # Initialize the MessagePage
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 [MessagePage] MessagePage
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 MessageInstance
144
+ # @param [Hash] payload Payload response from the API
145
+ # @return [MessageInstance] MessageInstance
146
+ def get_instance(payload)
147
+ MessageInstance.new(@version, payload, session_id: @solution[:session_id])
148
+ end
149
+
150
+ ##
151
+ # Provide a user friendly representation
152
+ def to_s
153
+ '<Twilio.Assistants.V1.MessagePage>'
154
+ end
155
+ end
156
+ class MessageInstance < InstanceResource
157
+ ##
158
+ # Initialize the MessageInstance
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 Message
163
+ # resource.
164
+ # @param [String] sid The SID of the Call resource to fetch.
165
+ # @return [MessageInstance] MessageInstance
166
+ def initialize(version, payload , session_id: nil)
167
+ super(version)
168
+
169
+ # Marshaled Properties
170
+ @properties = {
171
+ 'id' => payload['id'],
172
+ 'account_sid' => payload['account_sid'],
173
+ 'assistant_id' => payload['assistant_id'],
174
+ 'session_id' => payload['session_id'],
175
+ 'identity' => payload['identity'],
176
+ 'role' => payload['role'],
177
+ 'content' => payload['content'],
178
+ 'meta' => payload['meta'],
179
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
180
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
181
+ }
182
+ end
183
+
184
+
185
+ ##
186
+ # @return [String] The message ID.
187
+ def id
188
+ @properties['id']
189
+ end
190
+
191
+ ##
192
+ # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Message resource.
193
+ def account_sid
194
+ @properties['account_sid']
195
+ end
196
+
197
+ ##
198
+ # @return [String] The Assistant ID.
199
+ def assistant_id
200
+ @properties['assistant_id']
201
+ end
202
+
203
+ ##
204
+ # @return [String] The Session ID.
205
+ def session_id
206
+ @properties['session_id']
207
+ end
208
+
209
+ ##
210
+ # @return [String] The identity of the user.
211
+ def identity
212
+ @properties['identity']
213
+ end
214
+
215
+ ##
216
+ # @return [String] The role of the user associated with the message.
217
+ def role
218
+ @properties['role']
219
+ end
220
+
221
+ ##
222
+ # @return [Hash] The content of the message.
223
+ def content
224
+ @properties['content']
225
+ end
226
+
227
+ ##
228
+ # @return [Hash] The metadata of the message.
229
+ def meta
230
+ @properties['meta']
231
+ end
232
+
233
+ ##
234
+ # @return [Time] The date and time in GMT when the Message was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
235
+ def date_created
236
+ @properties['date_created']
237
+ end
238
+
239
+ ##
240
+ # @return [Time] The date and time in GMT when the Message was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
241
+ def date_updated
242
+ @properties['date_updated']
243
+ end
244
+
245
+ ##
246
+ # Provide a user friendly representation
247
+ def to_s
248
+ "<Twilio.Assistants.V1.MessageInstance>"
249
+ end
250
+
251
+ ##
252
+ # Provide a detailed, user friendly representation
253
+ def inspect
254
+ "<Twilio.Assistants.V1.MessageInstance>"
255
+ end
256
+ end
257
+
258
+ end
259
+ end
260
+ end
261
+ end
262
+ end
263
+
264
+