twilio-ruby 7.13.1 → 7.14.0
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.
- checksums.yaml +4 -4
- data/CHANGES.md +143 -0
- data/Gemfile.lock +2 -2
- data/README.md +2 -2
- data/lib/twilio-ruby/rest/accounts/v1/messaging_sms_pumping_protection.rb +253 -0
- data/lib/twilio-ruby/rest/accounts/v1.rb +6 -0
- data/lib/twilio-ruby/rest/api/v2010/account/call.rb +6 -0
- data/lib/twilio-ruby/rest/content/v1/content.rb +50 -2
- data/lib/twilio-ruby/rest/conversations/v2/context.rb +629 -0
- data/lib/twilio-ruby/rest/conversations/v2.rb +22 -0
- data/lib/twilio-ruby/rest/insights/v3/query.rb +17 -1
- data/lib/twilio-ruby/rest/insights/v3/query_job.rb +62 -1
- data/lib/twilio-ruby/rest/messaging/v1/service.rb +20 -4
- data/lib/twilio-ruby/rest/serverless/v1/service/build/build_status_detail.rb +316 -0
- data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +19 -0
- data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +15 -2
- data/lib/twilio-ruby/twiml/voice_response.rb +43 -4
- data/lib/twilio-ruby/version.rb +1 -1
- metadata +5 -2
|
@@ -0,0 +1,629 @@
|
|
|
1
|
+
##
|
|
2
|
+
# This code was generated by
|
|
3
|
+
# ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
|
|
4
|
+
# | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
|
|
5
|
+
# | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
|
|
6
|
+
#
|
|
7
|
+
# Conversation Orchestrator
|
|
8
|
+
# Manage configurations, conversations, participants, and communications. Create configurations to define capture rules and channel settings, then use conversations to group related communications.
|
|
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 Conversations < ConversationsBase
|
|
19
|
+
class V2 < Version
|
|
20
|
+
class ContextList < ListResource
|
|
21
|
+
|
|
22
|
+
class CreateContextInConversationRequest
|
|
23
|
+
# @param [data]: [Hash<String, Object>] Any JSON object, with no schema enforcement. Limited to 32 KB serialized. Clients interpret their own data.
|
|
24
|
+
attr_accessor :data
|
|
25
|
+
def initialize(payload)
|
|
26
|
+
@data = payload["data"]
|
|
27
|
+
end
|
|
28
|
+
def to_json(options = {})
|
|
29
|
+
{
|
|
30
|
+
"data": @data,
|
|
31
|
+
}.to_json(options)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
##
|
|
37
|
+
# Initialize the ContextList
|
|
38
|
+
# @param [Version] version Version that contains the resource
|
|
39
|
+
# @return [ContextList] ContextList
|
|
40
|
+
def initialize(version, conversation_id: nil)
|
|
41
|
+
|
|
42
|
+
apiV1Version = ApiV1Version.new version.domain, version
|
|
43
|
+
super(apiV1Version)
|
|
44
|
+
# Path Solution
|
|
45
|
+
@solution = { conversation_id: conversation_id }
|
|
46
|
+
@uri = "/Conversations/#{@solution[:conversation_id]}/Contexts"
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
##
|
|
50
|
+
# Create the ContextInstance
|
|
51
|
+
# @param [String] idempotency_key Client-generated UUID key to ensure idempotent behavior. Submitting the same key returns the original response without creating a duplicate operation. Keys are scoped to account + region with a 24-hour TTL.
|
|
52
|
+
# @param [CreateContextInConversationRequest] create_context_in_conversation_request
|
|
53
|
+
# @return [ContextInstance] Created ContextInstance
|
|
54
|
+
def create(
|
|
55
|
+
idempotency_key: :unset,
|
|
56
|
+
create_context_in_conversation_request: :unset
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Idempotency-Key' => idempotency_key, })
|
|
60
|
+
headers['Content-Type'] = 'application/json'
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
payload = @version.create('POST', @uri, headers: headers, data: create_context_in_conversation_request.to_json)
|
|
66
|
+
ContextInstance.new(
|
|
67
|
+
@version,
|
|
68
|
+
payload,
|
|
69
|
+
conversation_id: @solution[:conversation_id],
|
|
70
|
+
)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
##
|
|
74
|
+
# Create the ContextInstanceMetadata
|
|
75
|
+
# @param [String] idempotency_key Client-generated UUID key to ensure idempotent behavior. Submitting the same key returns the original response without creating a duplicate operation. Keys are scoped to account + region with a 24-hour TTL.
|
|
76
|
+
# @param [CreateContextInConversationRequest] create_context_in_conversation_request
|
|
77
|
+
# @return [ContextInstance] Created ContextInstance
|
|
78
|
+
def create_with_metadata(
|
|
79
|
+
idempotency_key: :unset,
|
|
80
|
+
create_context_in_conversation_request: :unset
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Idempotency-Key' => idempotency_key, })
|
|
84
|
+
headers['Content-Type'] = 'application/json'
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
response = @version.create_with_metadata('POST', @uri, headers: headers, data: create_context_in_conversation_request.to_json)
|
|
90
|
+
context_instance = ContextInstance.new(
|
|
91
|
+
@version,
|
|
92
|
+
response.body,
|
|
93
|
+
conversation_id: @solution[:conversation_id],
|
|
94
|
+
)
|
|
95
|
+
ContextInstanceMetadata.new(
|
|
96
|
+
@version,
|
|
97
|
+
context_instance,
|
|
98
|
+
response.headers,
|
|
99
|
+
response.status_code
|
|
100
|
+
)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
##
|
|
105
|
+
# Lists ContextInstance records from the API as a list.
|
|
106
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
|
107
|
+
# memory before returning.
|
|
108
|
+
# @param [String] order Sort order by creation time: `DESC` (newest first) or `ASC` (oldest first). Ignored when `pageToken` is set; the page continues in the order of the request that issued it.
|
|
109
|
+
# @param [String] page_token Page token for pagination. Pages continue in the order of the request that issued the token.
|
|
110
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
|
111
|
+
# guarantees to never return more than limit. Default is no limit
|
|
112
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
|
113
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
|
114
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
|
115
|
+
# efficient page size, i.e. min(limit, 1000)
|
|
116
|
+
# @return [Array] Array of up to limit results
|
|
117
|
+
def list(order: :unset, page_token: :unset, limit: nil, page_size: nil)
|
|
118
|
+
self.stream(
|
|
119
|
+
order: order,
|
|
120
|
+
page_token: page_token,
|
|
121
|
+
limit: limit,
|
|
122
|
+
page_size: page_size
|
|
123
|
+
).entries
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
##
|
|
127
|
+
# Streams Instance records from the API as an Enumerable.
|
|
128
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
|
129
|
+
# is reached.
|
|
130
|
+
# @param [String] order Sort order by creation time: `DESC` (newest first) or `ASC` (oldest first). Ignored when `pageToken` is set; the page continues in the order of the request that issued it.
|
|
131
|
+
# @param [String] page_token Page token for pagination. Pages continue in the order of the request that issued the token.
|
|
132
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
|
133
|
+
# guarantees to never return more than limit. Default is no limit
|
|
134
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
|
135
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
|
136
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
|
137
|
+
# efficient page size, i.e. min(limit, 1000)
|
|
138
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
|
139
|
+
def stream(order: :unset, page_token: :unset, limit: nil, page_size: nil)
|
|
140
|
+
limits = @version.read_limits(limit, page_size)
|
|
141
|
+
|
|
142
|
+
page = self.page(
|
|
143
|
+
order: order,
|
|
144
|
+
page_token: page_token,
|
|
145
|
+
page_size: limits[:page_size], )
|
|
146
|
+
|
|
147
|
+
return [].each if page.nil?
|
|
148
|
+
|
|
149
|
+
result = @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
|
150
|
+
return [].each if result.nil?
|
|
151
|
+
result
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
##
|
|
155
|
+
# Lists ContextPageMetadata records from the API as a list.
|
|
156
|
+
# @param [String] order Sort order by creation time: `DESC` (newest first) or `ASC` (oldest first). Ignored when `pageToken` is set; the page continues in the order of the request that issued it.
|
|
157
|
+
# @param [String] page_token Page token for pagination. Pages continue in the order of the request that issued the token.
|
|
158
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
|
159
|
+
# guarantees to never return more than limit. Default is no limit
|
|
160
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
|
161
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
|
162
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
|
163
|
+
# efficient page size, i.e. min(limit, 1000)
|
|
164
|
+
# @return [Array] Array of up to limit results
|
|
165
|
+
def list_with_metadata(order: :unset, page_token: :unset, limit: nil, page_size: nil)
|
|
166
|
+
limits = @version.read_limits(limit, page_size)
|
|
167
|
+
params = Twilio::Values.of({
|
|
168
|
+
'order' => order,
|
|
169
|
+
'pageToken' => page_token,
|
|
170
|
+
|
|
171
|
+
'PageSize' => limits[:page_size],
|
|
172
|
+
});
|
|
173
|
+
headers = Twilio::Values.of({})
|
|
174
|
+
|
|
175
|
+
response = @version.page('GET', @uri, params: params, headers: headers)
|
|
176
|
+
|
|
177
|
+
ContextPageMetadata.new(@version, response, @solution, limits[:limit])
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
##
|
|
181
|
+
# When passed a block, yields ContextInstance records from the API.
|
|
182
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
|
183
|
+
# is reached.
|
|
184
|
+
def each
|
|
185
|
+
limits = @version.read_limits
|
|
186
|
+
|
|
187
|
+
page = self.page(page_size: limits[:page_size], )
|
|
188
|
+
|
|
189
|
+
return [].each if page.nil?
|
|
190
|
+
|
|
191
|
+
result = @version.stream(page,
|
|
192
|
+
limit: limits[:limit],
|
|
193
|
+
page_limit: limits[:page_limit])
|
|
194
|
+
return [].each if result.nil?
|
|
195
|
+
result.each {|x| yield x}
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
##
|
|
199
|
+
# Retrieve a single page of ContextInstance records from the API.
|
|
200
|
+
# Request is executed immediately.
|
|
201
|
+
# @param [String] order Sort order by creation time: `DESC` (newest first) or `ASC` (oldest first). Ignored when `pageToken` is set; the page continues in the order of the request that issued it.
|
|
202
|
+
# @param [String] page_token Page token for pagination. Pages continue in the order of the request that issued the token.
|
|
203
|
+
|
|
204
|
+
# @return [Page] Page of ContextInstance
|
|
205
|
+
def page(order: :unset, page_token: :unset, page_size: :unset)
|
|
206
|
+
params = Twilio::Values.of({
|
|
207
|
+
'order' => order,
|
|
208
|
+
'pageToken' => page_token,
|
|
209
|
+
'PageSize' => page_size,
|
|
210
|
+
})
|
|
211
|
+
headers = Twilio::Values.of({})
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
response = @version.page('GET', @uri, params: params, headers: headers)
|
|
216
|
+
|
|
217
|
+
ContextPage.new(@version, response, @solution)
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
##
|
|
221
|
+
# Retrieve a single page of ContextInstance records from the API.
|
|
222
|
+
# Request is executed immediately.
|
|
223
|
+
# @param [String] target_url API-generated URL for the requested results page
|
|
224
|
+
# @return [Page] Page of ContextInstance
|
|
225
|
+
def get_page(target_url)
|
|
226
|
+
response = @version.domain.request(
|
|
227
|
+
'GET',
|
|
228
|
+
target_url
|
|
229
|
+
)
|
|
230
|
+
ContextPage.new(@version, response, @solution)
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
# Provide a user friendly representation
|
|
236
|
+
def to_s
|
|
237
|
+
'#<Twilio.Conversations.V2.ContextList>'
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
class ContextContext < InstanceContext
|
|
243
|
+
##
|
|
244
|
+
# Initialize the ContextContext
|
|
245
|
+
# @param [Version] version Version that contains the resource
|
|
246
|
+
# @param [String] conversation_id
|
|
247
|
+
# @param [String] context_id
|
|
248
|
+
# @return [ContextContext] ContextContext
|
|
249
|
+
def initialize(version, conversation_id, context_id)
|
|
250
|
+
|
|
251
|
+
apiV1Version = ApiV1Version.new version.domain, version
|
|
252
|
+
super(apiV1Version)
|
|
253
|
+
|
|
254
|
+
# Path Solution
|
|
255
|
+
@solution = { conversation_id: conversation_id, context_id: context_id, }
|
|
256
|
+
@uri = "/Conversations/#{@solution[:conversation_id]}/Contexts/#{@solution[:context_id]}"
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
end
|
|
260
|
+
##
|
|
261
|
+
# Delete the ContextInstance
|
|
262
|
+
# @return [Boolean] True if delete succeeds, false otherwise
|
|
263
|
+
def delete
|
|
264
|
+
|
|
265
|
+
headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
response = @version.delete_with_metadata('DELETE', @uri, headers: headers)
|
|
270
|
+
ContextInstance.new(
|
|
271
|
+
@version,
|
|
272
|
+
response.body,
|
|
273
|
+
conversation_id: @solution[:conversation_id],
|
|
274
|
+
context_id: @solution[:context_id],
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
##
|
|
280
|
+
# Delete the ContextInstanceMetadata
|
|
281
|
+
# @return [Boolean] True if delete succeeds, false otherwise
|
|
282
|
+
def delete_with_metadata
|
|
283
|
+
|
|
284
|
+
headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
response = @version.delete_with_metadata('DELETE', @uri, headers: headers)
|
|
289
|
+
context_instance = ContextInstance.new(
|
|
290
|
+
@version,
|
|
291
|
+
response.body,
|
|
292
|
+
account_sid: @solution[:account_sid],
|
|
293
|
+
sid: @solution[:sid],
|
|
294
|
+
)
|
|
295
|
+
ContextInstanceMetadata.new(@version, context_instance, response.headers, response.status_code)
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
##
|
|
299
|
+
# Fetch the ContextInstance
|
|
300
|
+
# @return [ContextInstance] Fetched ContextInstance
|
|
301
|
+
def fetch
|
|
302
|
+
|
|
303
|
+
headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
payload = @version.fetch('GET', @uri, headers: headers)
|
|
310
|
+
ContextInstance.new(
|
|
311
|
+
@version,
|
|
312
|
+
payload,
|
|
313
|
+
conversation_id: @solution[:conversation_id],
|
|
314
|
+
context_id: @solution[:context_id],
|
|
315
|
+
)
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
##
|
|
319
|
+
# Fetch the ContextInstanceMetadata
|
|
320
|
+
# @return [ContextInstance] Fetched ContextInstance
|
|
321
|
+
def fetch_with_metadata
|
|
322
|
+
|
|
323
|
+
headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
response = @version.fetch_with_metadata('GET', @uri, headers: headers)
|
|
330
|
+
context_instance = ContextInstance.new(
|
|
331
|
+
@version,
|
|
332
|
+
response.body,
|
|
333
|
+
conversation_id: @solution[:conversation_id],
|
|
334
|
+
context_id: @solution[:context_id],
|
|
335
|
+
)
|
|
336
|
+
ContextInstanceMetadata.new(
|
|
337
|
+
@version,
|
|
338
|
+
context_instance,
|
|
339
|
+
response.headers,
|
|
340
|
+
response.status_code
|
|
341
|
+
)
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
##
|
|
346
|
+
# Provide a user friendly representation
|
|
347
|
+
def to_s
|
|
348
|
+
context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
|
|
349
|
+
"#<Twilio.Conversations.V2.ContextContext #{context}>"
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
##
|
|
353
|
+
# Provide a detailed, user friendly representation
|
|
354
|
+
def inspect
|
|
355
|
+
context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
|
|
356
|
+
"#<Twilio.Conversations.V2.ContextContext #{context}>"
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
class ContextInstanceMetadata < InstanceResourceMetadata
|
|
361
|
+
##
|
|
362
|
+
# Initializes a new ContextInstanceMetadata.
|
|
363
|
+
# @param [Version] version Version that contains the resource
|
|
364
|
+
# @param [}ContextInstance] context_instance The instance associated with the metadata.
|
|
365
|
+
# @param [Hash] headers Header object with response headers.
|
|
366
|
+
# @param [Integer] status_code The HTTP status code of the response.
|
|
367
|
+
# @return [ContextInstanceMetadata] The initialized instance with metadata.
|
|
368
|
+
def initialize(version, context_instance, headers, status_code)
|
|
369
|
+
super(version, headers, status_code)
|
|
370
|
+
@context_instance = context_instance
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
def context
|
|
374
|
+
@context_instance
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
def headers
|
|
378
|
+
@headers
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
def status_code
|
|
382
|
+
@status_code
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
def to_s
|
|
386
|
+
"<Twilio.Api.V2010.ContextInstanceMetadata status=#{@status_code}>"
|
|
387
|
+
end
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
class ContextListResponse < InstanceListResource
|
|
391
|
+
# @param [Array<ContextInstance>] instance
|
|
392
|
+
# @param [Hash{String => Object}] headers
|
|
393
|
+
# @param [Integer] status_code
|
|
394
|
+
def initialize(version, payload, key)
|
|
395
|
+
@context_instance = payload.body[key].map do |data|
|
|
396
|
+
ContextInstance.new(version, data)
|
|
397
|
+
end
|
|
398
|
+
@headers = payload.headers
|
|
399
|
+
@status_code = payload.status_code
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
def context_instance
|
|
403
|
+
@instance
|
|
404
|
+
end
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
class ContextPage < TokenPage
|
|
408
|
+
##
|
|
409
|
+
# Initialize the ContextPage
|
|
410
|
+
# @param [Version] version Version that contains the resource
|
|
411
|
+
# @param [Response] response Response from the API
|
|
412
|
+
# @param [Hash] solution Path solution for the resource
|
|
413
|
+
# @return [ContextPage] ContextPage
|
|
414
|
+
def initialize(version, response, solution)
|
|
415
|
+
|
|
416
|
+
apiV1Version = ApiV1Version.new version.domain, version
|
|
417
|
+
super(apiV1Version, response)
|
|
418
|
+
|
|
419
|
+
# Path Solution
|
|
420
|
+
@solution = solution
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
##
|
|
424
|
+
# Build an instance of ContextInstance
|
|
425
|
+
# @param [Hash] payload Payload response from the API
|
|
426
|
+
# @return [ContextInstance] ContextInstance
|
|
427
|
+
def get_instance(payload)
|
|
428
|
+
ContextInstance.new(@version, payload, conversation_id: @solution[:conversation_id])
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
##
|
|
432
|
+
# Provide a user friendly representation
|
|
433
|
+
def to_s
|
|
434
|
+
'<Twilio.Conversations.V2.ContextPage>'
|
|
435
|
+
end
|
|
436
|
+
end
|
|
437
|
+
|
|
438
|
+
class ContextPageMetadata < PageMetadata
|
|
439
|
+
attr_reader :context_page
|
|
440
|
+
|
|
441
|
+
def initialize(version, response, solution, limit)
|
|
442
|
+
super(version, response)
|
|
443
|
+
@context_page = []
|
|
444
|
+
@limit = limit
|
|
445
|
+
key = get_key(response.body)
|
|
446
|
+
records = 0
|
|
447
|
+
while( limit != :unset && records < limit )
|
|
448
|
+
@context_page << ContextListResponse.new(version, @payload, key, limit - records)
|
|
449
|
+
@payload = self.next_page
|
|
450
|
+
break unless @payload
|
|
451
|
+
records += (@payload.body[key] || []).size
|
|
452
|
+
end
|
|
453
|
+
# Path Solution
|
|
454
|
+
@solution = solution
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
def each
|
|
458
|
+
@context_page.each do |record|
|
|
459
|
+
yield record
|
|
460
|
+
end
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
def to_s
|
|
464
|
+
'<Twilio::REST::Conversations::V2PageMetadata>';
|
|
465
|
+
end
|
|
466
|
+
end
|
|
467
|
+
class ContextListResponse < InstanceListResource
|
|
468
|
+
|
|
469
|
+
# @param [Array<ContextInstance>] instance
|
|
470
|
+
# @param [Hash{String => Object}] headers
|
|
471
|
+
# @param [Integer] status_code
|
|
472
|
+
def initialize(version, payload, key, limit = :unset)
|
|
473
|
+
data_list = payload.body[key] || []
|
|
474
|
+
if limit != :unset
|
|
475
|
+
data_list = data_list[0, limit]
|
|
476
|
+
end
|
|
477
|
+
@context = data_list.map do |data|
|
|
478
|
+
ContextInstance.new(version, data)
|
|
479
|
+
end
|
|
480
|
+
@headers = payload.headers
|
|
481
|
+
@status_code = payload.status_code
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
def context
|
|
485
|
+
@context
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
def headers
|
|
489
|
+
@headers
|
|
490
|
+
end
|
|
491
|
+
|
|
492
|
+
def status_code
|
|
493
|
+
@status_code
|
|
494
|
+
end
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
class ContextInstance < InstanceResource
|
|
498
|
+
##
|
|
499
|
+
# Initialize the ContextInstance
|
|
500
|
+
# @param [Version] version Version that contains the resource
|
|
501
|
+
# @param [Hash] payload payload that contains response from Twilio
|
|
502
|
+
# @param [String] account_sid The SID of the
|
|
503
|
+
# {Account}[https://www.twilio.com/docs/iam/api/account] that created this Context
|
|
504
|
+
# resource.
|
|
505
|
+
# @param [String] sid The SID of the Call resource to fetch.
|
|
506
|
+
# @return [ContextInstance] ContextInstance
|
|
507
|
+
def initialize(version, payload , conversation_id: nil, context_id: nil)
|
|
508
|
+
|
|
509
|
+
apiV1Version = ApiV1Version.new version.domain, version
|
|
510
|
+
super(apiV1Version)
|
|
511
|
+
|
|
512
|
+
# Marshaled Properties
|
|
513
|
+
@properties = {
|
|
514
|
+
'id' => payload['id'],
|
|
515
|
+
'conversation_id' => payload['conversation_id'],
|
|
516
|
+
'account_id' => payload['account_id'],
|
|
517
|
+
'created_at' => Twilio.deserialize_iso8601_datetime(payload['created_at']),
|
|
518
|
+
'data' => payload['data'],
|
|
519
|
+
'code' => payload['code'],
|
|
520
|
+
'message' => payload['message'],
|
|
521
|
+
'more_info' => payload['more_info'],
|
|
522
|
+
'status' => payload['status'],
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
# Context
|
|
526
|
+
@instance_context = nil
|
|
527
|
+
@params = { 'conversation_id' => conversation_id || @properties['conversation_id'] ,'context_id' => context_id || @properties['context_id'] , }
|
|
528
|
+
end
|
|
529
|
+
|
|
530
|
+
##
|
|
531
|
+
# Generate an instance context for the instance, the context is capable of
|
|
532
|
+
# performing various actions. All instance actions are proxied to the context
|
|
533
|
+
# @return [ContextContext] CallContext for this CallInstance
|
|
534
|
+
def context
|
|
535
|
+
unless @instance_context
|
|
536
|
+
@instance_context = ContextContext.new(@version , @params['conversation_id'], @params['context_id'])
|
|
537
|
+
end
|
|
538
|
+
@instance_context
|
|
539
|
+
end
|
|
540
|
+
|
|
541
|
+
##
|
|
542
|
+
# @return [String] Context ID.
|
|
543
|
+
def id
|
|
544
|
+
@properties['id']
|
|
545
|
+
end
|
|
546
|
+
|
|
547
|
+
##
|
|
548
|
+
# @return [String] Conversation ID.
|
|
549
|
+
def conversation_id
|
|
550
|
+
@properties['conversation_id']
|
|
551
|
+
end
|
|
552
|
+
|
|
553
|
+
##
|
|
554
|
+
# @return [String] Account ID.
|
|
555
|
+
def account_id
|
|
556
|
+
@properties['account_id']
|
|
557
|
+
end
|
|
558
|
+
|
|
559
|
+
##
|
|
560
|
+
# @return [Time] Timestamp when this Context was created.
|
|
561
|
+
def created_at
|
|
562
|
+
@properties['created_at']
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
##
|
|
566
|
+
# @return [Hash<String, Object>] Any JSON object, with no schema enforcement. Limited to 32 KB serialized. Clients interpret their own data.
|
|
567
|
+
def data
|
|
568
|
+
@properties['data']
|
|
569
|
+
end
|
|
570
|
+
|
|
571
|
+
##
|
|
572
|
+
# @return [String] Twilio-specific error code
|
|
573
|
+
def code
|
|
574
|
+
@properties['code']
|
|
575
|
+
end
|
|
576
|
+
|
|
577
|
+
##
|
|
578
|
+
# @return [String] Error message
|
|
579
|
+
def message
|
|
580
|
+
@properties['message']
|
|
581
|
+
end
|
|
582
|
+
|
|
583
|
+
##
|
|
584
|
+
# @return [String] Link to Error Code References
|
|
585
|
+
def more_info
|
|
586
|
+
@properties['more_info']
|
|
587
|
+
end
|
|
588
|
+
|
|
589
|
+
##
|
|
590
|
+
# @return [String] HTTP response status code
|
|
591
|
+
def status
|
|
592
|
+
@properties['status']
|
|
593
|
+
end
|
|
594
|
+
|
|
595
|
+
##
|
|
596
|
+
# Delete the ContextInstance
|
|
597
|
+
# @return [Boolean] True if delete succeeds, false otherwise
|
|
598
|
+
def delete
|
|
599
|
+
|
|
600
|
+
context.delete
|
|
601
|
+
end
|
|
602
|
+
|
|
603
|
+
##
|
|
604
|
+
# Fetch the ContextInstance
|
|
605
|
+
# @return [ContextInstance] Fetched ContextInstance
|
|
606
|
+
def fetch
|
|
607
|
+
|
|
608
|
+
context.fetch
|
|
609
|
+
end
|
|
610
|
+
|
|
611
|
+
##
|
|
612
|
+
# Provide a user friendly representation
|
|
613
|
+
def to_s
|
|
614
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
|
615
|
+
"<Twilio.Conversations.V2.ContextInstance #{values}>"
|
|
616
|
+
end
|
|
617
|
+
|
|
618
|
+
##
|
|
619
|
+
# Provide a detailed, user friendly representation
|
|
620
|
+
def inspect
|
|
621
|
+
values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
|
|
622
|
+
"<Twilio.Conversations.V2.ContextInstance #{values}>"
|
|
623
|
+
end
|
|
624
|
+
end
|
|
625
|
+
|
|
626
|
+
end
|
|
627
|
+
end
|
|
628
|
+
end
|
|
629
|
+
end
|
|
@@ -24,6 +24,7 @@ module Twilio
|
|
|
24
24
|
@actions = nil
|
|
25
25
|
@communications = nil
|
|
26
26
|
@configurations = nil
|
|
27
|
+
@contexts = nil
|
|
27
28
|
@conversations = nil
|
|
28
29
|
@operations = nil
|
|
29
30
|
@participants = nil
|
|
@@ -87,6 +88,27 @@ module Twilio
|
|
|
87
88
|
end
|
|
88
89
|
end
|
|
89
90
|
##
|
|
91
|
+
# @param [String] conversation_id
|
|
92
|
+
# @param [String] context_id
|
|
93
|
+
# @return [Twilio::REST::Conversations::V2::ContextContext] if context_id was passed.
|
|
94
|
+
# @return [Twilio::REST::Conversations::V2::ContextList]
|
|
95
|
+
def contexts(conversation_id=:unset, context_id=:unset)
|
|
96
|
+
if conversation_id.nil?
|
|
97
|
+
raise ArgumentError, 'conversation_id cannot be nil'
|
|
98
|
+
end
|
|
99
|
+
if context_id.nil?
|
|
100
|
+
raise ArgumentError, 'context_id cannot be nil'
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
if conversation_id == :unset && context_id == :unset
|
|
104
|
+
@contexts ||= ContextList.new self
|
|
105
|
+
elsif conversation_id != :unset && context_id == :unset
|
|
106
|
+
ContextList.new(self, conversation_id: conversation_id)
|
|
107
|
+
else
|
|
108
|
+
ContextContext.new(self, conversation_id, context_id)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
##
|
|
90
112
|
# @param [String] id
|
|
91
113
|
# @return [Twilio::REST::Conversations::V2::ConversationContext] if id was passed.
|
|
92
114
|
# @return [Twilio::REST::Conversations::V2::ConversationList]
|