twilio-ruby 5.40.1 → 5.40.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.
- checksums.yaml +4 -4
- data/CHANGES.md +27 -0
- data/README.md +2 -2
- data/lib/twilio-ruby/framework/version.rb +2 -7
- data/lib/twilio-ruby/rest/conversations.rb +52 -0
- data/lib/twilio-ruby/rest/conversations/v1.rb +88 -1
- data/lib/twilio-ruby/rest/conversations/v1/configuration.rb +258 -0
- data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +15 -4
- data/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb +19 -10
- data/lib/twilio-ruby/rest/conversations/v1/credential.rb +427 -0
- data/lib/twilio-ruby/rest/conversations/v1/notification.rb +310 -0
- data/lib/twilio-ruby/rest/conversations/v1/role.rb +372 -0
- data/lib/twilio-ruby/rest/conversations/v1/service.rb +442 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/binding.rb +385 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb +259 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb +586 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb +546 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb +388 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb +513 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb +454 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/role.rb +393 -0
- data/lib/twilio-ruby/rest/conversations/v1/service/user.rb +419 -0
- data/lib/twilio-ruby/rest/conversations/v1/user.rb +398 -0
- data/lib/twilio-ruby/rest/events.rb +8 -0
- data/lib/twilio-ruby/rest/events/v1.rb +15 -0
- data/lib/twilio-ruby/rest/events/v1/event_type.rb +291 -0
- data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance.rb +2 -2
- data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb +18 -4
- data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +27 -24
- data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +12 -11
- data/lib/twilio-ruby/rest/serverless/v1/service.rb +13 -13
- data/lib/twilio-ruby/rest/serverless/v1/service/asset.rb +6 -6
- data/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb +5 -5
- data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +8 -8
- data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +6 -8
- data/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb +8 -8
- data/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb +14 -14
- data/lib/twilio-ruby/rest/serverless/v1/service/function.rb +4 -4
- data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb +7 -7
- data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb +1 -1
- data/lib/twilio-ruby/rest/supersim/v1/sim.rb +17 -7
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +2 -1
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/framework/version_spec.rb +42 -0
- data/spec/holodeck/holodeck.rb +3 -3
- data/spec/integration/conversations/v1/configuration_spec.rb +85 -0
- data/spec/integration/conversations/v1/conversation/message/delivery_receipt_spec.rb +4 -0
- data/spec/integration/conversations/v1/conversation/participant_spec.rb +6 -6
- data/spec/integration/conversations/v1/conversation_spec.rb +5 -0
- data/spec/integration/conversations/v1/credential_spec.rb +219 -0
- data/spec/integration/conversations/v1/notification_spec.rb +107 -0
- data/spec/integration/conversations/v1/role_spec.rb +249 -0
- data/spec/integration/conversations/v1/service/binding_spec.rb +166 -0
- data/spec/integration/conversations/v1/service/configuration_spec.rb +87 -0
- data/spec/integration/conversations/v1/service/conversation/message/delivery_receipt_spec.rb +144 -0
- data/spec/integration/conversations/v1/service/conversation/message_spec.rb +429 -0
- data/spec/integration/conversations/v1/service/conversation/participant_spec.rb +407 -0
- data/spec/integration/conversations/v1/service/conversation/webhook_spec.rb +299 -0
- data/spec/integration/conversations/v1/service/conversation_spec.rb +289 -0
- data/spec/integration/conversations/v1/service/role_spec.rb +260 -0
- data/spec/integration/conversations/v1/service/user_spec.rb +230 -0
- data/spec/integration/conversations/v1/service_spec.rb +174 -0
- data/spec/integration/conversations/v1/user_spec.rb +220 -0
- data/spec/integration/events/v1/event_type_spec.rb +133 -0
- data/spec/integration/numbers/v2/regulatory_compliance/supporting_document_spec.rb +27 -0
- data/spec/integration/supersim/v1/sim_spec.rb +23 -0
- metadata +50 -2
@@ -0,0 +1,398 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
#
|
7
|
+
# frozen_string_literal: true
|
8
|
+
|
9
|
+
module Twilio
|
10
|
+
module REST
|
11
|
+
class Conversations < Domain
|
12
|
+
class V1 < Version
|
13
|
+
##
|
14
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
15
|
+
class UserList < ListResource
|
16
|
+
##
|
17
|
+
# Initialize the UserList
|
18
|
+
# @param [Version] version Version that contains the resource
|
19
|
+
# @return [UserList] UserList
|
20
|
+
def initialize(version)
|
21
|
+
super(version)
|
22
|
+
|
23
|
+
# Path Solution
|
24
|
+
@solution = {}
|
25
|
+
@uri = "/Users"
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Create the UserInstance
|
30
|
+
# @param [String] identity The application-defined string that uniquely identifies
|
31
|
+
# the resource's User within the
|
32
|
+
# [Service](https://www.twilio.com/docs/chat/rest/service-resource). This value is
|
33
|
+
# often a username or an email address, and is case-sensitive.
|
34
|
+
# @param [String] friendly_name The string that you assigned to describe the
|
35
|
+
# resource.
|
36
|
+
# @param [String] attributes The JSON Object string that stores
|
37
|
+
# application-specific data. If attributes have not been set, `{}` is returned.
|
38
|
+
# @param [String] role_sid The SID of the
|
39
|
+
# [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the
|
40
|
+
# user.
|
41
|
+
# @return [UserInstance] Created UserInstance
|
42
|
+
def create(identity: nil, friendly_name: :unset, attributes: :unset, role_sid: :unset)
|
43
|
+
data = Twilio::Values.of({
|
44
|
+
'Identity' => identity,
|
45
|
+
'FriendlyName' => friendly_name,
|
46
|
+
'Attributes' => attributes,
|
47
|
+
'RoleSid' => role_sid,
|
48
|
+
})
|
49
|
+
|
50
|
+
payload = @version.create('POST', @uri, data: data)
|
51
|
+
|
52
|
+
UserInstance.new(@version, payload, )
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Lists UserInstance records from the API as a list.
|
57
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
58
|
+
# memory before returning.
|
59
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
60
|
+
# guarantees to never return more than limit. Default is no limit
|
61
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
62
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
63
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
64
|
+
# efficient page size, i.e. min(limit, 1000)
|
65
|
+
# @return [Array] Array of up to limit results
|
66
|
+
def list(limit: nil, page_size: nil)
|
67
|
+
self.stream(limit: limit, page_size: page_size).entries
|
68
|
+
end
|
69
|
+
|
70
|
+
##
|
71
|
+
# Streams UserInstance records from the API as an Enumerable.
|
72
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
73
|
+
# is reached.
|
74
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
75
|
+
# guarantees to never return more than limit. Default is no limit.
|
76
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
77
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
78
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
79
|
+
# efficient page size, i.e. min(limit, 1000)
|
80
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
81
|
+
def stream(limit: nil, page_size: nil)
|
82
|
+
limits = @version.read_limits(limit, page_size)
|
83
|
+
|
84
|
+
page = self.page(page_size: limits[:page_size], )
|
85
|
+
|
86
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
87
|
+
end
|
88
|
+
|
89
|
+
##
|
90
|
+
# When passed a block, yields UserInstance records from the API.
|
91
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
92
|
+
# is reached.
|
93
|
+
def each
|
94
|
+
limits = @version.read_limits
|
95
|
+
|
96
|
+
page = self.page(page_size: limits[:page_size], )
|
97
|
+
|
98
|
+
@version.stream(page,
|
99
|
+
limit: limits[:limit],
|
100
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
101
|
+
end
|
102
|
+
|
103
|
+
##
|
104
|
+
# Retrieve a single page of UserInstance records from the API.
|
105
|
+
# Request is executed immediately.
|
106
|
+
# @param [String] page_token PageToken provided by the API
|
107
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
108
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
109
|
+
# @return [Page] Page of UserInstance
|
110
|
+
def page(page_token: :unset, page_number: :unset, page_size: :unset)
|
111
|
+
params = Twilio::Values.of({
|
112
|
+
'PageToken' => page_token,
|
113
|
+
'Page' => page_number,
|
114
|
+
'PageSize' => page_size,
|
115
|
+
})
|
116
|
+
|
117
|
+
response = @version.page('GET', @uri, params: params)
|
118
|
+
|
119
|
+
UserPage.new(@version, response, @solution)
|
120
|
+
end
|
121
|
+
|
122
|
+
##
|
123
|
+
# Retrieve a single page of UserInstance records from the API.
|
124
|
+
# Request is executed immediately.
|
125
|
+
# @param [String] target_url API-generated URL for the requested results page
|
126
|
+
# @return [Page] Page of UserInstance
|
127
|
+
def get_page(target_url)
|
128
|
+
response = @version.domain.request(
|
129
|
+
'GET',
|
130
|
+
target_url
|
131
|
+
)
|
132
|
+
UserPage.new(@version, response, @solution)
|
133
|
+
end
|
134
|
+
|
135
|
+
##
|
136
|
+
# Provide a user friendly representation
|
137
|
+
def to_s
|
138
|
+
'#<Twilio.Conversations.V1.UserList>'
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
##
|
143
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
144
|
+
class UserPage < Page
|
145
|
+
##
|
146
|
+
# Initialize the UserPage
|
147
|
+
# @param [Version] version Version that contains the resource
|
148
|
+
# @param [Response] response Response from the API
|
149
|
+
# @param [Hash] solution Path solution for the resource
|
150
|
+
# @return [UserPage] UserPage
|
151
|
+
def initialize(version, response, solution)
|
152
|
+
super(version, response)
|
153
|
+
|
154
|
+
# Path Solution
|
155
|
+
@solution = solution
|
156
|
+
end
|
157
|
+
|
158
|
+
##
|
159
|
+
# Build an instance of UserInstance
|
160
|
+
# @param [Hash] payload Payload response from the API
|
161
|
+
# @return [UserInstance] UserInstance
|
162
|
+
def get_instance(payload)
|
163
|
+
UserInstance.new(@version, payload, )
|
164
|
+
end
|
165
|
+
|
166
|
+
##
|
167
|
+
# Provide a user friendly representation
|
168
|
+
def to_s
|
169
|
+
'<Twilio.Conversations.V1.UserPage>'
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
##
|
174
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
175
|
+
class UserContext < InstanceContext
|
176
|
+
##
|
177
|
+
# Initialize the UserContext
|
178
|
+
# @param [Version] version Version that contains the resource
|
179
|
+
# @param [String] sid The SID of the User resource to fetch. This value can be
|
180
|
+
# either the `sid` or the `identity` of the User resource to fetch.
|
181
|
+
# @return [UserContext] UserContext
|
182
|
+
def initialize(version, sid)
|
183
|
+
super(version)
|
184
|
+
|
185
|
+
# Path Solution
|
186
|
+
@solution = {sid: sid, }
|
187
|
+
@uri = "/Users/#{@solution[:sid]}"
|
188
|
+
end
|
189
|
+
|
190
|
+
##
|
191
|
+
# Update the UserInstance
|
192
|
+
# @param [String] friendly_name The string that you assigned to describe the
|
193
|
+
# resource.
|
194
|
+
# @param [String] attributes The JSON Object string that stores
|
195
|
+
# application-specific data. If attributes have not been set, `{}` is returned.
|
196
|
+
# @param [String] role_sid The SID of the
|
197
|
+
# [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the
|
198
|
+
# user.
|
199
|
+
# @return [UserInstance] Updated UserInstance
|
200
|
+
def update(friendly_name: :unset, attributes: :unset, role_sid: :unset)
|
201
|
+
data = Twilio::Values.of({
|
202
|
+
'FriendlyName' => friendly_name,
|
203
|
+
'Attributes' => attributes,
|
204
|
+
'RoleSid' => role_sid,
|
205
|
+
})
|
206
|
+
|
207
|
+
payload = @version.update('POST', @uri, data: data)
|
208
|
+
|
209
|
+
UserInstance.new(@version, payload, sid: @solution[:sid], )
|
210
|
+
end
|
211
|
+
|
212
|
+
##
|
213
|
+
# Delete the UserInstance
|
214
|
+
# @return [Boolean] true if delete succeeds, false otherwise
|
215
|
+
def delete
|
216
|
+
@version.delete('DELETE', @uri)
|
217
|
+
end
|
218
|
+
|
219
|
+
##
|
220
|
+
# Fetch the UserInstance
|
221
|
+
# @return [UserInstance] Fetched UserInstance
|
222
|
+
def fetch
|
223
|
+
payload = @version.fetch('GET', @uri)
|
224
|
+
|
225
|
+
UserInstance.new(@version, payload, sid: @solution[:sid], )
|
226
|
+
end
|
227
|
+
|
228
|
+
##
|
229
|
+
# Provide a user friendly representation
|
230
|
+
def to_s
|
231
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
232
|
+
"#<Twilio.Conversations.V1.UserContext #{context}>"
|
233
|
+
end
|
234
|
+
|
235
|
+
##
|
236
|
+
# Provide a detailed, user friendly representation
|
237
|
+
def inspect
|
238
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
239
|
+
"#<Twilio.Conversations.V1.UserContext #{context}>"
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
##
|
244
|
+
# PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
|
245
|
+
class UserInstance < InstanceResource
|
246
|
+
##
|
247
|
+
# Initialize the UserInstance
|
248
|
+
# @param [Version] version Version that contains the resource
|
249
|
+
# @param [Hash] payload payload that contains response from Twilio
|
250
|
+
# @param [String] sid The SID of the User resource to fetch. This value can be
|
251
|
+
# either the `sid` or the `identity` of the User resource to fetch.
|
252
|
+
# @return [UserInstance] UserInstance
|
253
|
+
def initialize(version, payload, sid: nil)
|
254
|
+
super(version)
|
255
|
+
|
256
|
+
# Marshaled Properties
|
257
|
+
@properties = {
|
258
|
+
'sid' => payload['sid'],
|
259
|
+
'account_sid' => payload['account_sid'],
|
260
|
+
'chat_service_sid' => payload['chat_service_sid'],
|
261
|
+
'role_sid' => payload['role_sid'],
|
262
|
+
'identity' => payload['identity'],
|
263
|
+
'friendly_name' => payload['friendly_name'],
|
264
|
+
'attributes' => payload['attributes'],
|
265
|
+
'is_online' => payload['is_online'],
|
266
|
+
'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
|
267
|
+
'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
|
268
|
+
'url' => payload['url'],
|
269
|
+
}
|
270
|
+
|
271
|
+
# Context
|
272
|
+
@instance_context = nil
|
273
|
+
@params = {'sid' => sid || @properties['sid'], }
|
274
|
+
end
|
275
|
+
|
276
|
+
##
|
277
|
+
# Generate an instance context for the instance, the context is capable of
|
278
|
+
# performing various actions. All instance actions are proxied to the context
|
279
|
+
# @return [UserContext] UserContext for this UserInstance
|
280
|
+
def context
|
281
|
+
unless @instance_context
|
282
|
+
@instance_context = UserContext.new(@version, @params['sid'], )
|
283
|
+
end
|
284
|
+
@instance_context
|
285
|
+
end
|
286
|
+
|
287
|
+
##
|
288
|
+
# @return [String] The unique string that identifies the resource
|
289
|
+
def sid
|
290
|
+
@properties['sid']
|
291
|
+
end
|
292
|
+
|
293
|
+
##
|
294
|
+
# @return [String] The SID of the Account that created the resource
|
295
|
+
def account_sid
|
296
|
+
@properties['account_sid']
|
297
|
+
end
|
298
|
+
|
299
|
+
##
|
300
|
+
# @return [String] The SID of the Service that the resource is associated with
|
301
|
+
def chat_service_sid
|
302
|
+
@properties['chat_service_sid']
|
303
|
+
end
|
304
|
+
|
305
|
+
##
|
306
|
+
# @return [String] The SID of the Role assigned to the user
|
307
|
+
def role_sid
|
308
|
+
@properties['role_sid']
|
309
|
+
end
|
310
|
+
|
311
|
+
##
|
312
|
+
# @return [String] The string that identifies the resource's User
|
313
|
+
def identity
|
314
|
+
@properties['identity']
|
315
|
+
end
|
316
|
+
|
317
|
+
##
|
318
|
+
# @return [String] The string that you assigned to describe the resource
|
319
|
+
def friendly_name
|
320
|
+
@properties['friendly_name']
|
321
|
+
end
|
322
|
+
|
323
|
+
##
|
324
|
+
# @return [String] The JSON Object string that stores application-specific data
|
325
|
+
def attributes
|
326
|
+
@properties['attributes']
|
327
|
+
end
|
328
|
+
|
329
|
+
##
|
330
|
+
# @return [Boolean] Whether the User is actively connected to the Service instance and online
|
331
|
+
def is_online
|
332
|
+
@properties['is_online']
|
333
|
+
end
|
334
|
+
|
335
|
+
##
|
336
|
+
# @return [Time] The ISO 8601 date and time in GMT when the resource was created
|
337
|
+
def date_created
|
338
|
+
@properties['date_created']
|
339
|
+
end
|
340
|
+
|
341
|
+
##
|
342
|
+
# @return [Time] The ISO 8601 date and time in GMT when the resource was last updated
|
343
|
+
def date_updated
|
344
|
+
@properties['date_updated']
|
345
|
+
end
|
346
|
+
|
347
|
+
##
|
348
|
+
# @return [String] The absolute URL of the User resource
|
349
|
+
def url
|
350
|
+
@properties['url']
|
351
|
+
end
|
352
|
+
|
353
|
+
##
|
354
|
+
# Update the UserInstance
|
355
|
+
# @param [String] friendly_name The string that you assigned to describe the
|
356
|
+
# resource.
|
357
|
+
# @param [String] attributes The JSON Object string that stores
|
358
|
+
# application-specific data. If attributes have not been set, `{}` is returned.
|
359
|
+
# @param [String] role_sid The SID of the
|
360
|
+
# [Role](https://www.twilio.com/docs/chat/rest/role-resource) to assign to the
|
361
|
+
# user.
|
362
|
+
# @return [UserInstance] Updated UserInstance
|
363
|
+
def update(friendly_name: :unset, attributes: :unset, role_sid: :unset)
|
364
|
+
context.update(friendly_name: friendly_name, attributes: attributes, role_sid: role_sid, )
|
365
|
+
end
|
366
|
+
|
367
|
+
##
|
368
|
+
# Delete the UserInstance
|
369
|
+
# @return [Boolean] true if delete succeeds, false otherwise
|
370
|
+
def delete
|
371
|
+
context.delete
|
372
|
+
end
|
373
|
+
|
374
|
+
##
|
375
|
+
# Fetch the UserInstance
|
376
|
+
# @return [UserInstance] Fetched UserInstance
|
377
|
+
def fetch
|
378
|
+
context.fetch
|
379
|
+
end
|
380
|
+
|
381
|
+
##
|
382
|
+
# Provide a user friendly representation
|
383
|
+
def to_s
|
384
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
385
|
+
"<Twilio.Conversations.V1.UserInstance #{values}>"
|
386
|
+
end
|
387
|
+
|
388
|
+
##
|
389
|
+
# Provide a detailed, user friendly representation
|
390
|
+
def inspect
|
391
|
+
values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
|
392
|
+
"<Twilio.Conversations.V1.UserInstance #{values}>"
|
393
|
+
end
|
394
|
+
end
|
395
|
+
end
|
396
|
+
end
|
397
|
+
end
|
398
|
+
end
|
@@ -28,6 +28,14 @@ module Twilio
|
|
28
28
|
@v1 ||= V1.new self
|
29
29
|
end
|
30
30
|
|
31
|
+
##
|
32
|
+
# @param [String] type The type
|
33
|
+
# @return [Twilio::REST::Events::V1::EventTypeInstance] if type was passed.
|
34
|
+
# @return [Twilio::REST::Events::V1::EventTypeList]
|
35
|
+
def event_types(type=:unset)
|
36
|
+
self.v1.event_types(type)
|
37
|
+
end
|
38
|
+
|
31
39
|
##
|
32
40
|
# @param [String] sid A 34 character string that uniquely identifies this Sink.
|
33
41
|
# @return [Twilio::REST::Events::V1::SinkInstance] if sid was passed.
|
@@ -15,10 +15,25 @@ module Twilio
|
|
15
15
|
def initialize(domain)
|
16
16
|
super
|
17
17
|
@version = 'v1'
|
18
|
+
@event_types = nil
|
18
19
|
@sinks = nil
|
19
20
|
@subscriptions = nil
|
20
21
|
end
|
21
22
|
|
23
|
+
##
|
24
|
+
# @param [String] type The type
|
25
|
+
# @return [Twilio::REST::Events::V1::EventTypeContext] if type was passed.
|
26
|
+
# @return [Twilio::REST::Events::V1::EventTypeList]
|
27
|
+
def event_types(type=:unset)
|
28
|
+
if type.nil?
|
29
|
+
raise ArgumentError, 'type cannot be nil'
|
30
|
+
elsif type == :unset
|
31
|
+
@event_types ||= EventTypeList.new self
|
32
|
+
else
|
33
|
+
EventTypeContext.new(self, type)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
22
37
|
##
|
23
38
|
# @param [String] sid A 34 character string that uniquely identifies this Sink.
|
24
39
|
# @return [Twilio::REST::Events::V1::SinkContext] if sid was passed.
|
@@ -0,0 +1,291 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
#
|
7
|
+
# frozen_string_literal: true
|
8
|
+
|
9
|
+
module Twilio
|
10
|
+
module REST
|
11
|
+
class Events < Domain
|
12
|
+
class V1 < Version
|
13
|
+
##
|
14
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
15
|
+
class EventTypeList < ListResource
|
16
|
+
##
|
17
|
+
# Initialize the EventTypeList
|
18
|
+
# @param [Version] version Version that contains the resource
|
19
|
+
# @return [EventTypeList] EventTypeList
|
20
|
+
def initialize(version)
|
21
|
+
super(version)
|
22
|
+
|
23
|
+
# Path Solution
|
24
|
+
@solution = {}
|
25
|
+
@uri = "/Types"
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Lists EventTypeInstance records from the API as a list.
|
30
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
31
|
+
# memory before returning.
|
32
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
33
|
+
# guarantees to never return more than limit. Default is no limit
|
34
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
35
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
36
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
37
|
+
# efficient page size, i.e. min(limit, 1000)
|
38
|
+
# @return [Array] Array of up to limit results
|
39
|
+
def list(limit: nil, page_size: nil)
|
40
|
+
self.stream(limit: limit, page_size: page_size).entries
|
41
|
+
end
|
42
|
+
|
43
|
+
##
|
44
|
+
# Streams EventTypeInstance records from the API as an Enumerable.
|
45
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
46
|
+
# is reached.
|
47
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
48
|
+
# guarantees to never return more than limit. Default is no limit.
|
49
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
50
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
51
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
52
|
+
# efficient page size, i.e. min(limit, 1000)
|
53
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
54
|
+
def stream(limit: nil, page_size: nil)
|
55
|
+
limits = @version.read_limits(limit, page_size)
|
56
|
+
|
57
|
+
page = self.page(page_size: limits[:page_size], )
|
58
|
+
|
59
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# When passed a block, yields EventTypeInstance records from the API.
|
64
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
65
|
+
# is reached.
|
66
|
+
def each
|
67
|
+
limits = @version.read_limits
|
68
|
+
|
69
|
+
page = self.page(page_size: limits[:page_size], )
|
70
|
+
|
71
|
+
@version.stream(page,
|
72
|
+
limit: limits[:limit],
|
73
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
74
|
+
end
|
75
|
+
|
76
|
+
##
|
77
|
+
# Retrieve a single page of EventTypeInstance records from the API.
|
78
|
+
# Request is executed immediately.
|
79
|
+
# @param [String] page_token PageToken provided by the API
|
80
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
81
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
82
|
+
# @return [Page] Page of EventTypeInstance
|
83
|
+
def page(page_token: :unset, page_number: :unset, page_size: :unset)
|
84
|
+
params = Twilio::Values.of({
|
85
|
+
'PageToken' => page_token,
|
86
|
+
'Page' => page_number,
|
87
|
+
'PageSize' => page_size,
|
88
|
+
})
|
89
|
+
|
90
|
+
response = @version.page('GET', @uri, params: params)
|
91
|
+
|
92
|
+
EventTypePage.new(@version, response, @solution)
|
93
|
+
end
|
94
|
+
|
95
|
+
##
|
96
|
+
# Retrieve a single page of EventTypeInstance records from the API.
|
97
|
+
# Request is executed immediately.
|
98
|
+
# @param [String] target_url API-generated URL for the requested results page
|
99
|
+
# @return [Page] Page of EventTypeInstance
|
100
|
+
def get_page(target_url)
|
101
|
+
response = @version.domain.request(
|
102
|
+
'GET',
|
103
|
+
target_url
|
104
|
+
)
|
105
|
+
EventTypePage.new(@version, response, @solution)
|
106
|
+
end
|
107
|
+
|
108
|
+
##
|
109
|
+
# Provide a user friendly representation
|
110
|
+
def to_s
|
111
|
+
'#<Twilio.Events.V1.EventTypeList>'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
##
|
116
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
117
|
+
class EventTypePage < Page
|
118
|
+
##
|
119
|
+
# Initialize the EventTypePage
|
120
|
+
# @param [Version] version Version that contains the resource
|
121
|
+
# @param [Response] response Response from the API
|
122
|
+
# @param [Hash] solution Path solution for the resource
|
123
|
+
# @return [EventTypePage] EventTypePage
|
124
|
+
def initialize(version, response, solution)
|
125
|
+
super(version, response)
|
126
|
+
|
127
|
+
# Path Solution
|
128
|
+
@solution = solution
|
129
|
+
end
|
130
|
+
|
131
|
+
##
|
132
|
+
# Build an instance of EventTypeInstance
|
133
|
+
# @param [Hash] payload Payload response from the API
|
134
|
+
# @return [EventTypeInstance] EventTypeInstance
|
135
|
+
def get_instance(payload)
|
136
|
+
EventTypeInstance.new(@version, payload, )
|
137
|
+
end
|
138
|
+
|
139
|
+
##
|
140
|
+
# Provide a user friendly representation
|
141
|
+
def to_s
|
142
|
+
'<Twilio.Events.V1.EventTypePage>'
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
##
|
147
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
148
|
+
class EventTypeContext < InstanceContext
|
149
|
+
##
|
150
|
+
# Initialize the EventTypeContext
|
151
|
+
# @param [Version] version Version that contains the resource
|
152
|
+
# @param [String] type The type
|
153
|
+
# @return [EventTypeContext] EventTypeContext
|
154
|
+
def initialize(version, type)
|
155
|
+
super(version)
|
156
|
+
|
157
|
+
# Path Solution
|
158
|
+
@solution = {type: type, }
|
159
|
+
@uri = "/Types/#{@solution[:type]}"
|
160
|
+
end
|
161
|
+
|
162
|
+
##
|
163
|
+
# Fetch the EventTypeInstance
|
164
|
+
# @return [EventTypeInstance] Fetched EventTypeInstance
|
165
|
+
def fetch
|
166
|
+
payload = @version.fetch('GET', @uri)
|
167
|
+
|
168
|
+
EventTypeInstance.new(@version, payload, type: @solution[:type], )
|
169
|
+
end
|
170
|
+
|
171
|
+
##
|
172
|
+
# Provide a user friendly representation
|
173
|
+
def to_s
|
174
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
175
|
+
"#<Twilio.Events.V1.EventTypeContext #{context}>"
|
176
|
+
end
|
177
|
+
|
178
|
+
##
|
179
|
+
# Provide a detailed, user friendly representation
|
180
|
+
def inspect
|
181
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
182
|
+
"#<Twilio.Events.V1.EventTypeContext #{context}>"
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
##
|
187
|
+
# PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
|
188
|
+
class EventTypeInstance < InstanceResource
|
189
|
+
##
|
190
|
+
# Initialize the EventTypeInstance
|
191
|
+
# @param [Version] version Version that contains the resource
|
192
|
+
# @param [Hash] payload payload that contains response from Twilio
|
193
|
+
# @param [String] type The type
|
194
|
+
# @return [EventTypeInstance] EventTypeInstance
|
195
|
+
def initialize(version, payload, type: nil)
|
196
|
+
super(version)
|
197
|
+
|
198
|
+
# Marshaled Properties
|
199
|
+
@properties = {
|
200
|
+
'type' => payload['type'],
|
201
|
+
'schema_id' => payload['schema_id'],
|
202
|
+
'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
|
203
|
+
'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
|
204
|
+
'description' => payload['description'],
|
205
|
+
'url' => payload['url'],
|
206
|
+
'links' => payload['links'],
|
207
|
+
}
|
208
|
+
|
209
|
+
# Context
|
210
|
+
@instance_context = nil
|
211
|
+
@params = {'type' => type || @properties['type'], }
|
212
|
+
end
|
213
|
+
|
214
|
+
##
|
215
|
+
# Generate an instance context for the instance, the context is capable of
|
216
|
+
# performing various actions. All instance actions are proxied to the context
|
217
|
+
# @return [EventTypeContext] EventTypeContext for this EventTypeInstance
|
218
|
+
def context
|
219
|
+
unless @instance_context
|
220
|
+
@instance_context = EventTypeContext.new(@version, @params['type'], )
|
221
|
+
end
|
222
|
+
@instance_context
|
223
|
+
end
|
224
|
+
|
225
|
+
##
|
226
|
+
# @return [String] The type
|
227
|
+
def type
|
228
|
+
@properties['type']
|
229
|
+
end
|
230
|
+
|
231
|
+
##
|
232
|
+
# @return [String] The schema_id
|
233
|
+
def schema_id
|
234
|
+
@properties['schema_id']
|
235
|
+
end
|
236
|
+
|
237
|
+
##
|
238
|
+
# @return [Time] The date_created
|
239
|
+
def date_created
|
240
|
+
@properties['date_created']
|
241
|
+
end
|
242
|
+
|
243
|
+
##
|
244
|
+
# @return [Time] The date_updated
|
245
|
+
def date_updated
|
246
|
+
@properties['date_updated']
|
247
|
+
end
|
248
|
+
|
249
|
+
##
|
250
|
+
# @return [String] The description
|
251
|
+
def description
|
252
|
+
@properties['description']
|
253
|
+
end
|
254
|
+
|
255
|
+
##
|
256
|
+
# @return [String] The url
|
257
|
+
def url
|
258
|
+
@properties['url']
|
259
|
+
end
|
260
|
+
|
261
|
+
##
|
262
|
+
# @return [String] The links
|
263
|
+
def links
|
264
|
+
@properties['links']
|
265
|
+
end
|
266
|
+
|
267
|
+
##
|
268
|
+
# Fetch the EventTypeInstance
|
269
|
+
# @return [EventTypeInstance] Fetched EventTypeInstance
|
270
|
+
def fetch
|
271
|
+
context.fetch
|
272
|
+
end
|
273
|
+
|
274
|
+
##
|
275
|
+
# Provide a user friendly representation
|
276
|
+
def to_s
|
277
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
278
|
+
"<Twilio.Events.V1.EventTypeInstance #{values}>"
|
279
|
+
end
|
280
|
+
|
281
|
+
##
|
282
|
+
# Provide a detailed, user friendly representation
|
283
|
+
def inspect
|
284
|
+
values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
|
285
|
+
"<Twilio.Events.V1.EventTypeInstance #{values}>"
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|