twilio-ruby 5.1.1 → 5.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +17 -0
- data/README.md +2 -2
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb +8 -2
- data/lib/twilio-ruby/rest/chat/v2/service.rb +13 -2
- data/lib/twilio-ruby/rest/chat/v2/service/channel/message.rb +14 -0
- data/lib/twilio-ruby/rest/ip_messaging/v2/service.rb +13 -2
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb +14 -0
- data/lib/twilio-ruby/rest/preview.rb +16 -0
- data/lib/twilio-ruby/rest/preview/bulk_exports/export_configuration.rb +2 -13
- data/lib/twilio-ruby/rest/preview/deployed_devices.rb +42 -0
- data/lib/twilio-ruby/rest/preview/deployed_devices/fleet.rb +531 -0
- data/lib/twilio-ruby/rest/preview/deployed_devices/fleet/certificate.rb +428 -0
- data/lib/twilio-ruby/rest/preview/deployed_devices/fleet/deployment.rb +412 -0
- data/lib/twilio-ruby/rest/preview/deployed_devices/fleet/device.rb +465 -0
- data/lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb +425 -0
- data/lib/twilio-ruby/rest/sync/v1/service.rb +7 -0
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/integration/chat/v2/service/channel/message_spec.rb +68 -0
- data/spec/integration/chat/v2/service_spec.rb +20 -4
- data/spec/integration/ip_messaging/v2/service/channel/message_spec.rb +68 -0
- data/spec/integration/ip_messaging/v2/service_spec.rb +20 -4
- data/spec/integration/preview/bulk_exports/export_configuration_spec.rb +1 -3
- data/spec/integration/preview/deployed_devices/fleet/certificate_spec.rb +238 -0
- data/spec/integration/preview/deployed_devices/fleet/deployment_spec.rb +231 -0
- data/spec/integration/preview/deployed_devices/fleet/device_spec.rb +247 -0
- data/spec/integration/preview/deployed_devices/fleet/key_spec.rb +235 -0
- data/spec/integration/preview/deployed_devices/fleet_spec.rb +244 -0
- data/spec/integration/sync/v1/service_spec.rb +4 -0
- metadata +19 -3
@@ -0,0 +1,465 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
|
7
|
+
module Twilio
|
8
|
+
module REST
|
9
|
+
class Preview < Domain
|
10
|
+
class DeployedDevices < Version
|
11
|
+
class FleetContext < InstanceContext
|
12
|
+
##
|
13
|
+
# 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.
|
14
|
+
class DeviceList < ListResource
|
15
|
+
##
|
16
|
+
# Initialize the DeviceList
|
17
|
+
# @param [Version] version Version that contains the resource
|
18
|
+
# @param [String] fleet_sid Specifies the unique string identifier of the Fleet
|
19
|
+
# that the given Device belongs to.
|
20
|
+
# @return [DeviceList] DeviceList
|
21
|
+
def initialize(version, fleet_sid: nil)
|
22
|
+
super(version)
|
23
|
+
|
24
|
+
# Path Solution
|
25
|
+
@solution = {
|
26
|
+
fleet_sid: fleet_sid
|
27
|
+
}
|
28
|
+
@uri = "/Fleets/#{@solution[:fleet_sid]}/Devices"
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# Retrieve a single page of DeviceInstance records from the API.
|
33
|
+
# Request is executed immediately.
|
34
|
+
# @param [String] unique_name Provides a unique and addressable name to be
|
35
|
+
# assigned to this Device, to be used in addition to SID, up to 128 characters
|
36
|
+
# long.
|
37
|
+
# @param [String] friendly_name Provides a human readable descriptive text to be
|
38
|
+
# assigned to this Device, up to 256 characters long.
|
39
|
+
# @param [String] identity Provides an arbitrary string identifier representing a
|
40
|
+
# human user to be associated with this Device, up to 256 characters long.
|
41
|
+
# @param [String] deployment_sid Specifies the unique string identifier of the
|
42
|
+
# Deployment group that this Device is going to be associated with.
|
43
|
+
# @param [Boolean] enabled The enabled
|
44
|
+
# @return [DeviceInstance] Newly created DeviceInstance
|
45
|
+
def create(unique_name: :unset, friendly_name: :unset, identity: :unset, deployment_sid: :unset, enabled: :unset)
|
46
|
+
data = Twilio::Values.of({
|
47
|
+
'UniqueName' => unique_name,
|
48
|
+
'FriendlyName' => friendly_name,
|
49
|
+
'Identity' => identity,
|
50
|
+
'DeploymentSid' => deployment_sid,
|
51
|
+
'Enabled' => enabled,
|
52
|
+
})
|
53
|
+
|
54
|
+
payload = @version.create(
|
55
|
+
'POST',
|
56
|
+
@uri,
|
57
|
+
data: data
|
58
|
+
)
|
59
|
+
|
60
|
+
DeviceInstance.new(
|
61
|
+
@version,
|
62
|
+
payload,
|
63
|
+
fleet_sid: @solution[:fleet_sid],
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
##
|
68
|
+
# Lists DeviceInstance records from the API as a list.
|
69
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
70
|
+
# memory before returning.
|
71
|
+
# @param [String] deployment_sid Filters the resulting list of Devices by a unique
|
72
|
+
# string identifier of the Deployment they are associated with.
|
73
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
74
|
+
# guarantees to never return more than limit. Default is no limit
|
75
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
76
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
77
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
78
|
+
# efficient page size, i.e. min(limit, 1000)
|
79
|
+
# @return [Array] Array of up to limit results
|
80
|
+
def list(deployment_sid: :unset, limit: nil, page_size: nil)
|
81
|
+
self.stream(
|
82
|
+
deployment_sid: deployment_sid,
|
83
|
+
limit: limit,
|
84
|
+
page_size: page_size
|
85
|
+
).entries
|
86
|
+
end
|
87
|
+
|
88
|
+
##
|
89
|
+
# Streams DeviceInstance records from the API as an Enumerable.
|
90
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
91
|
+
# is reached.
|
92
|
+
# @param [String] deployment_sid Filters the resulting list of Devices by a unique
|
93
|
+
# string identifier of the Deployment they are associated with.
|
94
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
95
|
+
# guarantees to never return more than limit. Default is no limit.
|
96
|
+
# @param [Integer] page_size Number of records to fetch per request, when
|
97
|
+
# not set will use the default value of 50 records. If no page_size is defined
|
98
|
+
# but a limit is defined, stream() will attempt to read the limit with the most
|
99
|
+
# efficient page size, i.e. min(limit, 1000)
|
100
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
101
|
+
def stream(deployment_sid: :unset, limit: nil, page_size: nil)
|
102
|
+
limits = @version.read_limits(limit, page_size)
|
103
|
+
|
104
|
+
page = self.page(
|
105
|
+
deployment_sid: deployment_sid,
|
106
|
+
page_size: limits[:page_size],
|
107
|
+
)
|
108
|
+
|
109
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
110
|
+
end
|
111
|
+
|
112
|
+
##
|
113
|
+
# When passed a block, yields DeviceInstance records from the API.
|
114
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
115
|
+
# is reached.
|
116
|
+
def each
|
117
|
+
limits = @version.read_limits
|
118
|
+
|
119
|
+
page = self.page(
|
120
|
+
page_size: limits[:page_size],
|
121
|
+
)
|
122
|
+
|
123
|
+
@version.stream(page,
|
124
|
+
limit: limits[:limit],
|
125
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
126
|
+
end
|
127
|
+
|
128
|
+
##
|
129
|
+
# Retrieve a single page of DeviceInstance records from the API.
|
130
|
+
# Request is executed immediately.
|
131
|
+
# @param [String] deployment_sid Filters the resulting list of Devices by a unique
|
132
|
+
# string identifier of the Deployment they are associated with.
|
133
|
+
# @param [String] page_token PageToken provided by the API
|
134
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
135
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
136
|
+
# @return [Page] Page of DeviceInstance
|
137
|
+
def page(deployment_sid: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
|
138
|
+
params = Twilio::Values.of({
|
139
|
+
'DeploymentSid' => deployment_sid,
|
140
|
+
'PageToken' => page_token,
|
141
|
+
'Page' => page_number,
|
142
|
+
'PageSize' => page_size,
|
143
|
+
})
|
144
|
+
response = @version.page(
|
145
|
+
'GET',
|
146
|
+
@uri,
|
147
|
+
params
|
148
|
+
)
|
149
|
+
DevicePage.new(@version, response, @solution)
|
150
|
+
end
|
151
|
+
|
152
|
+
##
|
153
|
+
# Retrieve a single page of DeviceInstance records from the API.
|
154
|
+
# Request is executed immediately.
|
155
|
+
# @param [String] target_url API-generated URL for the requested results page
|
156
|
+
# @return [Page] Page of DeviceInstance
|
157
|
+
def get_page(target_url)
|
158
|
+
response = @version.domain.request(
|
159
|
+
'GET',
|
160
|
+
target_url
|
161
|
+
)
|
162
|
+
DevicePage.new(@version, response, @solution)
|
163
|
+
end
|
164
|
+
|
165
|
+
##
|
166
|
+
# Provide a user friendly representation
|
167
|
+
def to_s
|
168
|
+
'#<Twilio.Preview.DeployedDevices.DeviceList>'
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
##
|
173
|
+
# 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.
|
174
|
+
class DevicePage < Page
|
175
|
+
##
|
176
|
+
# Initialize the DevicePage
|
177
|
+
# @param [Version] version Version that contains the resource
|
178
|
+
# @param [Response] response Response from the API
|
179
|
+
# @param [Hash] solution Path solution for the resource
|
180
|
+
# @return [DevicePage] DevicePage
|
181
|
+
def initialize(version, response, solution)
|
182
|
+
super(version, response)
|
183
|
+
|
184
|
+
# Path Solution
|
185
|
+
@solution = solution
|
186
|
+
end
|
187
|
+
|
188
|
+
##
|
189
|
+
# Build an instance of DeviceInstance
|
190
|
+
# @param [Hash] payload Payload response from the API
|
191
|
+
# @return [DeviceInstance] DeviceInstance
|
192
|
+
def get_instance(payload)
|
193
|
+
DeviceInstance.new(
|
194
|
+
@version,
|
195
|
+
payload,
|
196
|
+
fleet_sid: @solution[:fleet_sid],
|
197
|
+
)
|
198
|
+
end
|
199
|
+
|
200
|
+
##
|
201
|
+
# Provide a user friendly representation
|
202
|
+
def to_s
|
203
|
+
'<Twilio.Preview.DeployedDevices.DevicePage>'
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
##
|
208
|
+
# 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.
|
209
|
+
class DeviceContext < InstanceContext
|
210
|
+
##
|
211
|
+
# Initialize the DeviceContext
|
212
|
+
# @param [Version] version Version that contains the resource
|
213
|
+
# @param [String] fleet_sid The fleet_sid
|
214
|
+
# @param [String] sid Provides a 34 character string that uniquely identifies the
|
215
|
+
# requested Device resource.
|
216
|
+
# @return [DeviceContext] DeviceContext
|
217
|
+
def initialize(version, fleet_sid, sid)
|
218
|
+
super(version)
|
219
|
+
|
220
|
+
# Path Solution
|
221
|
+
@solution = {
|
222
|
+
fleet_sid: fleet_sid,
|
223
|
+
sid: sid,
|
224
|
+
}
|
225
|
+
@uri = "/Fleets/#{@solution[:fleet_sid]}/Devices/#{@solution[:sid]}"
|
226
|
+
end
|
227
|
+
|
228
|
+
##
|
229
|
+
# Fetch a DeviceInstance
|
230
|
+
# @return [DeviceInstance] Fetched DeviceInstance
|
231
|
+
def fetch
|
232
|
+
params = Twilio::Values.of({})
|
233
|
+
|
234
|
+
payload = @version.fetch(
|
235
|
+
'GET',
|
236
|
+
@uri,
|
237
|
+
params,
|
238
|
+
)
|
239
|
+
|
240
|
+
DeviceInstance.new(
|
241
|
+
@version,
|
242
|
+
payload,
|
243
|
+
fleet_sid: @solution[:fleet_sid],
|
244
|
+
sid: @solution[:sid],
|
245
|
+
)
|
246
|
+
end
|
247
|
+
|
248
|
+
##
|
249
|
+
# Deletes the DeviceInstance
|
250
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
251
|
+
def delete
|
252
|
+
@version.delete('delete', @uri)
|
253
|
+
end
|
254
|
+
|
255
|
+
##
|
256
|
+
# Update the DeviceInstance
|
257
|
+
# @param [String] friendly_name Provides a human readable descriptive text to be
|
258
|
+
# assigned to this Device, up to 256 characters long.
|
259
|
+
# @param [String] identity Provides an arbitrary string identifier representing a
|
260
|
+
# human user to be associated with this Device, up to 256 characters long.
|
261
|
+
# @param [String] deployment_sid Specifies the unique string identifier of the
|
262
|
+
# Deployment group that this Device is going to be associated with.
|
263
|
+
# @param [Boolean] enabled The enabled
|
264
|
+
# @return [DeviceInstance] Updated DeviceInstance
|
265
|
+
def update(friendly_name: :unset, identity: :unset, deployment_sid: :unset, enabled: :unset)
|
266
|
+
data = Twilio::Values.of({
|
267
|
+
'FriendlyName' => friendly_name,
|
268
|
+
'Identity' => identity,
|
269
|
+
'DeploymentSid' => deployment_sid,
|
270
|
+
'Enabled' => enabled,
|
271
|
+
})
|
272
|
+
|
273
|
+
payload = @version.update(
|
274
|
+
'POST',
|
275
|
+
@uri,
|
276
|
+
data: data,
|
277
|
+
)
|
278
|
+
|
279
|
+
DeviceInstance.new(
|
280
|
+
@version,
|
281
|
+
payload,
|
282
|
+
fleet_sid: @solution[:fleet_sid],
|
283
|
+
sid: @solution[:sid],
|
284
|
+
)
|
285
|
+
end
|
286
|
+
|
287
|
+
##
|
288
|
+
# Provide a user friendly representation
|
289
|
+
def to_s
|
290
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
291
|
+
"#<Twilio.Preview.DeployedDevices.DeviceContext #{context}>"
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
##
|
296
|
+
# 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.
|
297
|
+
class DeviceInstance < InstanceResource
|
298
|
+
##
|
299
|
+
# Initialize the DeviceInstance
|
300
|
+
# @param [Version] version Version that contains the resource
|
301
|
+
# @param [Hash] payload payload that contains response from Twilio
|
302
|
+
# @param [String] fleet_sid Specifies the unique string identifier of the Fleet
|
303
|
+
# that the given Device belongs to.
|
304
|
+
# @param [String] sid Provides a 34 character string that uniquely identifies the
|
305
|
+
# requested Device resource.
|
306
|
+
# @return [DeviceInstance] DeviceInstance
|
307
|
+
def initialize(version, payload, fleet_sid: nil, sid: nil)
|
308
|
+
super(version)
|
309
|
+
|
310
|
+
# Marshaled Properties
|
311
|
+
@properties = {
|
312
|
+
'sid' => payload['sid'],
|
313
|
+
'url' => payload['url'],
|
314
|
+
'unique_name' => payload['unique_name'],
|
315
|
+
'friendly_name' => payload['friendly_name'],
|
316
|
+
'fleet_sid' => payload['fleet_sid'],
|
317
|
+
'enabled' => payload['enabled'],
|
318
|
+
'account_sid' => payload['account_sid'],
|
319
|
+
'identity' => payload['identity'],
|
320
|
+
'deployment_sid' => payload['deployment_sid'],
|
321
|
+
'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
|
322
|
+
'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
|
323
|
+
'date_authenticated' => Twilio.deserialize_iso8601_datetime(payload['date_authenticated']),
|
324
|
+
}
|
325
|
+
|
326
|
+
# Context
|
327
|
+
@instance_context = nil
|
328
|
+
@params = {
|
329
|
+
'fleet_sid' => fleet_sid,
|
330
|
+
'sid' => sid || @properties['sid'],
|
331
|
+
}
|
332
|
+
end
|
333
|
+
|
334
|
+
##
|
335
|
+
# Generate an instance context for the instance, the context is capable of
|
336
|
+
# performing various actions. All instance actions are proxied to the context
|
337
|
+
# @return [DeviceContext] DeviceContext for this DeviceInstance
|
338
|
+
def context
|
339
|
+
unless @instance_context
|
340
|
+
@instance_context = DeviceContext.new(
|
341
|
+
@version,
|
342
|
+
@params['fleet_sid'],
|
343
|
+
@params['sid'],
|
344
|
+
)
|
345
|
+
end
|
346
|
+
@instance_context
|
347
|
+
end
|
348
|
+
|
349
|
+
##
|
350
|
+
# @return [String] A string that uniquely identifies this Device.
|
351
|
+
def sid
|
352
|
+
@properties['sid']
|
353
|
+
end
|
354
|
+
|
355
|
+
##
|
356
|
+
# @return [String] URL of this Device.
|
357
|
+
def url
|
358
|
+
@properties['url']
|
359
|
+
end
|
360
|
+
|
361
|
+
##
|
362
|
+
# @return [String] A unique, addressable name of this Device.
|
363
|
+
def unique_name
|
364
|
+
@properties['unique_name']
|
365
|
+
end
|
366
|
+
|
367
|
+
##
|
368
|
+
# @return [String] A human readable description for this Device
|
369
|
+
def friendly_name
|
370
|
+
@properties['friendly_name']
|
371
|
+
end
|
372
|
+
|
373
|
+
##
|
374
|
+
# @return [String] The unique identifier of the Fleet.
|
375
|
+
def fleet_sid
|
376
|
+
@properties['fleet_sid']
|
377
|
+
end
|
378
|
+
|
379
|
+
##
|
380
|
+
# @return [Boolean] Device enabled flag.
|
381
|
+
def enabled
|
382
|
+
@properties['enabled']
|
383
|
+
end
|
384
|
+
|
385
|
+
##
|
386
|
+
# @return [String] The unique SID that identifies this Account.
|
387
|
+
def account_sid
|
388
|
+
@properties['account_sid']
|
389
|
+
end
|
390
|
+
|
391
|
+
##
|
392
|
+
# @return [String] An identifier of the Device user.
|
393
|
+
def identity
|
394
|
+
@properties['identity']
|
395
|
+
end
|
396
|
+
|
397
|
+
##
|
398
|
+
# @return [String] The unique SID of the Deployment group.
|
399
|
+
def deployment_sid
|
400
|
+
@properties['deployment_sid']
|
401
|
+
end
|
402
|
+
|
403
|
+
##
|
404
|
+
# @return [Time] The date this Device was created.
|
405
|
+
def date_created
|
406
|
+
@properties['date_created']
|
407
|
+
end
|
408
|
+
|
409
|
+
##
|
410
|
+
# @return [Time] The date this Device was updated.
|
411
|
+
def date_updated
|
412
|
+
@properties['date_updated']
|
413
|
+
end
|
414
|
+
|
415
|
+
##
|
416
|
+
# @return [Time] The date this Device was authenticated.
|
417
|
+
def date_authenticated
|
418
|
+
@properties['date_authenticated']
|
419
|
+
end
|
420
|
+
|
421
|
+
##
|
422
|
+
# Fetch a DeviceInstance
|
423
|
+
# @return [DeviceInstance] Fetched DeviceInstance
|
424
|
+
def fetch
|
425
|
+
context.fetch
|
426
|
+
end
|
427
|
+
|
428
|
+
##
|
429
|
+
# Deletes the DeviceInstance
|
430
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
431
|
+
def delete
|
432
|
+
context.delete
|
433
|
+
end
|
434
|
+
|
435
|
+
##
|
436
|
+
# Update the DeviceInstance
|
437
|
+
# @param [String] friendly_name Provides a human readable descriptive text to be
|
438
|
+
# assigned to this Device, up to 256 characters long.
|
439
|
+
# @param [String] identity Provides an arbitrary string identifier representing a
|
440
|
+
# human user to be associated with this Device, up to 256 characters long.
|
441
|
+
# @param [String] deployment_sid Specifies the unique string identifier of the
|
442
|
+
# Deployment group that this Device is going to be associated with.
|
443
|
+
# @param [Boolean] enabled The enabled
|
444
|
+
# @return [DeviceInstance] Updated DeviceInstance
|
445
|
+
def update(friendly_name: :unset, identity: :unset, deployment_sid: :unset, enabled: :unset)
|
446
|
+
context.update(
|
447
|
+
friendly_name: friendly_name,
|
448
|
+
identity: identity,
|
449
|
+
deployment_sid: deployment_sid,
|
450
|
+
enabled: enabled,
|
451
|
+
)
|
452
|
+
end
|
453
|
+
|
454
|
+
##
|
455
|
+
# Provide a user friendly representation
|
456
|
+
def to_s
|
457
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
458
|
+
"<Twilio.Preview.DeployedDevices.DeviceInstance #{values}>"
|
459
|
+
end
|
460
|
+
end
|
461
|
+
end
|
462
|
+
end
|
463
|
+
end
|
464
|
+
end
|
465
|
+
end
|