twilio-ruby 5.0.0.rc20 → 5.0.0.rc21
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 +9 -3
- data/README.md +2 -2
- data/lib/twilio-ruby/http/http_client.rb +0 -1
- data/lib/twilio-ruby/rest/preview/bulk_exports/export/day.rb +196 -0
- data/lib/twilio-ruby/rest/preview/bulk_exports/export.rb +197 -0
- data/lib/twilio-ruby/rest/preview/bulk_exports/export_configuration.rb +232 -0
- data/lib/twilio-ruby/rest/preview/bulk_exports.rb +44 -0
- data/lib/twilio-ruby/rest/preview/hosted_numbers/hosted_number_order.rb +517 -0
- data/lib/twilio-ruby/rest/preview/hosted_numbers.rb +35 -0
- data/lib/twilio-ruby/rest/preview/proxy/service/phone_number.rb +336 -0
- data/lib/twilio-ruby/rest/preview/proxy/service/session/interaction.rb +393 -0
- data/lib/twilio-ruby/rest/preview/proxy/service/session/participant/message_interaction.rb +409 -0
- data/lib/twilio-ruby/rest/preview/proxy/service/session/participant.rb +479 -0
- data/lib/twilio-ruby/rest/preview/proxy/service/session.rb +506 -0
- data/lib/twilio-ruby/rest/preview/proxy/service/short_code.rb +336 -0
- data/lib/twilio-ruby/rest/preview/proxy/service.rb +467 -0
- data/lib/twilio-ruby/rest/preview/proxy.rb +35 -0
- data/lib/twilio-ruby/rest/preview.rb +34 -1
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/integration/preview/bulk_exports/export/day_spec.rb +56 -0
- data/spec/integration/preview/bulk_exports/export_configuration_spec.rb +79 -0
- data/spec/integration/preview/bulk_exports/export_spec.rb +43 -0
- data/spec/integration/preview/hosted_numbers/hosted_number_order_spec.rb +277 -0
- data/spec/integration/preview/proxy/service/phone_number_spec.rb +173 -0
- data/spec/integration/preview/proxy/service/session/interaction_spec.rb +104 -0
- data/spec/integration/preview/proxy/service/session/participant/message_interaction_spec.rb +164 -0
- data/spec/integration/preview/proxy/service/session/participant_spec.rb +226 -0
- data/spec/integration/preview/proxy/service/session_spec.rb +216 -0
- data/spec/integration/preview/proxy/service/short_code_spec.rb +173 -0
- data/spec/integration/preview/proxy/service_spec.rb +200 -0
- metadata +38 -2
@@ -0,0 +1,336 @@
|
|
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 Proxy < Version
|
11
|
+
class ServiceContext < InstanceContext
|
12
|
+
class ShortCodeList < ListResource
|
13
|
+
##
|
14
|
+
# Initialize the ShortCodeList
|
15
|
+
# @param [Version] version Version that contains the resource
|
16
|
+
# @param [String] service_sid The unique SID identifier of the Service.
|
17
|
+
# @return [ShortCodeList] ShortCodeList
|
18
|
+
def initialize(version, service_sid: nil)
|
19
|
+
super(version)
|
20
|
+
|
21
|
+
# Path Solution
|
22
|
+
@solution = {
|
23
|
+
service_sid: service_sid
|
24
|
+
}
|
25
|
+
@uri = "/Services/#{@solution[:service_sid]}/ShortCodes"
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Retrieve a single page of ShortCodeInstance records from the API.
|
30
|
+
# Request is executed immediately.
|
31
|
+
# @param [String] sid The shortcode Sid that uniquely identifies this resource
|
32
|
+
# @return [ShortCodeInstance] Newly created ShortCodeInstance
|
33
|
+
def create(sid: nil)
|
34
|
+
data = {
|
35
|
+
'Sid' => sid,
|
36
|
+
}
|
37
|
+
|
38
|
+
payload = @version.create(
|
39
|
+
'POST',
|
40
|
+
@uri,
|
41
|
+
data: data
|
42
|
+
)
|
43
|
+
|
44
|
+
return ShortCodeInstance.new(
|
45
|
+
@version,
|
46
|
+
payload,
|
47
|
+
service_sid: @solution[:service_sid],
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
##
|
52
|
+
# Lists ShortCodeInstance records from the API as a list.
|
53
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
54
|
+
# memory before returning.
|
55
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
56
|
+
# guarantees to never return more than limit. Default is no limit
|
57
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
58
|
+
# the default value of 50 records. If no page_size is defined
|
59
|
+
# but a limit is defined, stream() will attempt to read the
|
60
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
61
|
+
# @return [Array] Array of up to limit results
|
62
|
+
def list(limit: nil, page_size: nil)
|
63
|
+
self.stream(
|
64
|
+
limit: limit,
|
65
|
+
page_size: page_size
|
66
|
+
).entries
|
67
|
+
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# Streams ShortCodeInstance records from the API as an Enumerable.
|
71
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
72
|
+
# is reached.
|
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 not set will use
|
76
|
+
# the default value of 50 records. If no page_size is defined
|
77
|
+
# but a limit is defined, stream() will attempt to read the
|
78
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
79
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
80
|
+
def stream(limit: nil, page_size: nil)
|
81
|
+
limits = @version.read_limits(limit, page_size)
|
82
|
+
|
83
|
+
page = self.page(
|
84
|
+
page_size: limits[:page_size],
|
85
|
+
)
|
86
|
+
|
87
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
88
|
+
end
|
89
|
+
|
90
|
+
##
|
91
|
+
# When passed a block, yields ShortCodeInstance records from the API.
|
92
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
93
|
+
# is reached.
|
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 not set will use
|
97
|
+
# the default value of 50 records. If no page_size is defined
|
98
|
+
# but a limit is defined, stream() will attempt to read the
|
99
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
100
|
+
def each
|
101
|
+
limits = @version.read_limits
|
102
|
+
|
103
|
+
page = self.page(
|
104
|
+
page_size: limits[:page_size],
|
105
|
+
)
|
106
|
+
|
107
|
+
@version.stream(page,
|
108
|
+
limit: limits[:limit],
|
109
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
110
|
+
end
|
111
|
+
|
112
|
+
##
|
113
|
+
# Retrieve a single page of ShortCodeInstance records from the API.
|
114
|
+
# Request is executed immediately.
|
115
|
+
# @param [String] page_token PageToken provided by the API
|
116
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
117
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
118
|
+
# @return [Page] Page of ShortCodeInstance
|
119
|
+
def page(page_token: nil, page_number: nil, page_size: nil)
|
120
|
+
params = {
|
121
|
+
'PageToken' => page_token,
|
122
|
+
'Page' => page_number,
|
123
|
+
'PageSize' => page_size,
|
124
|
+
}
|
125
|
+
response = @version.page(
|
126
|
+
'GET',
|
127
|
+
@uri,
|
128
|
+
params
|
129
|
+
)
|
130
|
+
return ShortCodePage.new(@version, response, @solution)
|
131
|
+
end
|
132
|
+
|
133
|
+
##
|
134
|
+
# Provide a user friendly representation
|
135
|
+
def to_s
|
136
|
+
'#<Twilio.Preview.Proxy.ShortCodeList>'
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
class ShortCodePage < Page
|
141
|
+
##
|
142
|
+
# Initialize the ShortCodePage
|
143
|
+
# @param [Version] version Version that contains the resource
|
144
|
+
# @param [Response] response Response from the API
|
145
|
+
# @param [Hash] solution Path solution for the resource
|
146
|
+
# @param [String] service_sid The unique SID identifier of the Service.
|
147
|
+
# @return [ShortCodePage] ShortCodePage
|
148
|
+
def initialize(version, response, solution)
|
149
|
+
super(version, response)
|
150
|
+
|
151
|
+
# Path Solution
|
152
|
+
@solution = solution
|
153
|
+
end
|
154
|
+
|
155
|
+
##
|
156
|
+
# Build an instance of ShortCodeInstance
|
157
|
+
# @param [Hash] payload Payload response from the API
|
158
|
+
# @return [ShortCodeInstance] ShortCodeInstance
|
159
|
+
def get_instance(payload)
|
160
|
+
return ShortCodeInstance.new(
|
161
|
+
@version,
|
162
|
+
payload,
|
163
|
+
service_sid: @solution[:service_sid],
|
164
|
+
)
|
165
|
+
end
|
166
|
+
|
167
|
+
##
|
168
|
+
# Provide a user friendly representation
|
169
|
+
def to_s
|
170
|
+
'<Twilio.Preview.Proxy.ShortCodePage>'
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
class ShortCodeContext < InstanceContext
|
175
|
+
##
|
176
|
+
# Initialize the ShortCodeContext
|
177
|
+
# @param [Version] version Version that contains the resource
|
178
|
+
# @param [String] service_sid The service_sid
|
179
|
+
# @param [String] sid The shortcode Sid that uniquely identifies this resource
|
180
|
+
# @return [ShortCodeContext] ShortCodeContext
|
181
|
+
def initialize(version, service_sid, sid)
|
182
|
+
super(version)
|
183
|
+
|
184
|
+
# Path Solution
|
185
|
+
@solution = {
|
186
|
+
service_sid: service_sid,
|
187
|
+
sid: sid,
|
188
|
+
}
|
189
|
+
@uri = "/Services/#{@solution[:service_sid]}/ShortCodes/#{@solution[:sid]}"
|
190
|
+
end
|
191
|
+
|
192
|
+
##
|
193
|
+
# Deletes the ShortCodeInstance
|
194
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
195
|
+
def delete
|
196
|
+
return @version.delete('delete', @uri)
|
197
|
+
end
|
198
|
+
|
199
|
+
##
|
200
|
+
# Fetch a ShortCodeInstance
|
201
|
+
# @return [ShortCodeInstance] Fetched ShortCodeInstance
|
202
|
+
def fetch
|
203
|
+
params = {}
|
204
|
+
|
205
|
+
payload = @version.fetch(
|
206
|
+
'GET',
|
207
|
+
@uri,
|
208
|
+
params,
|
209
|
+
)
|
210
|
+
|
211
|
+
return ShortCodeInstance.new(
|
212
|
+
@version,
|
213
|
+
payload,
|
214
|
+
service_sid: @solution[:service_sid],
|
215
|
+
sid: @solution[:sid],
|
216
|
+
)
|
217
|
+
end
|
218
|
+
|
219
|
+
##
|
220
|
+
# Provide a user friendly representation
|
221
|
+
def to_s
|
222
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
223
|
+
"#<Twilio.Preview.Proxy.ShortCodeContext #{context}>"
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
class ShortCodeInstance < InstanceResource
|
228
|
+
##
|
229
|
+
# Initialize the ShortCodeInstance
|
230
|
+
# @param [Version] version Version that contains the resource
|
231
|
+
# @param [Hash] payload payload that contains response from Twilio
|
232
|
+
# @param [String] service_sid The unique SID identifier of the Service.
|
233
|
+
# @param [String] sid The shortcode Sid that uniquely identifies this resource
|
234
|
+
# @return [ShortCodeInstance] ShortCodeInstance
|
235
|
+
def initialize(version, payload, service_sid: nil, sid: nil)
|
236
|
+
super(version)
|
237
|
+
|
238
|
+
# Marshaled Properties
|
239
|
+
@properties = {
|
240
|
+
'sid' => payload['sid'],
|
241
|
+
'account_sid' => payload['account_sid'],
|
242
|
+
'service_sid' => payload['service_sid'],
|
243
|
+
'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
|
244
|
+
'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
|
245
|
+
'short_code' => payload['short_code'],
|
246
|
+
'country_code' => payload['country_code'],
|
247
|
+
'capabilities' => payload['capabilities'],
|
248
|
+
'url' => payload['url'],
|
249
|
+
}
|
250
|
+
|
251
|
+
# Context
|
252
|
+
@instance_context = nil
|
253
|
+
@params = {
|
254
|
+
'service_sid' => service_sid,
|
255
|
+
'sid' => sid || @properties['sid'],
|
256
|
+
}
|
257
|
+
end
|
258
|
+
|
259
|
+
##
|
260
|
+
# Generate an instance context for the instance, the context is capable of
|
261
|
+
# performing various actions. All instance actions are proxied to the context
|
262
|
+
# @param [Version] version Version that contains the resource
|
263
|
+
# @return [ShortCodeContext] ShortCodeContext for this ShortCodeInstance
|
264
|
+
def context
|
265
|
+
unless @instance_context
|
266
|
+
@instance_context = ShortCodeContext.new(
|
267
|
+
@version,
|
268
|
+
@params['service_sid'],
|
269
|
+
@params['sid'],
|
270
|
+
)
|
271
|
+
end
|
272
|
+
@instance_context
|
273
|
+
end
|
274
|
+
|
275
|
+
def sid
|
276
|
+
@properties['sid']
|
277
|
+
end
|
278
|
+
|
279
|
+
def account_sid
|
280
|
+
@properties['account_sid']
|
281
|
+
end
|
282
|
+
|
283
|
+
def service_sid
|
284
|
+
@properties['service_sid']
|
285
|
+
end
|
286
|
+
|
287
|
+
def date_created
|
288
|
+
@properties['date_created']
|
289
|
+
end
|
290
|
+
|
291
|
+
def date_updated
|
292
|
+
@properties['date_updated']
|
293
|
+
end
|
294
|
+
|
295
|
+
def short_code
|
296
|
+
@properties['short_code']
|
297
|
+
end
|
298
|
+
|
299
|
+
def country_code
|
300
|
+
@properties['country_code']
|
301
|
+
end
|
302
|
+
|
303
|
+
def capabilities
|
304
|
+
@properties['capabilities']
|
305
|
+
end
|
306
|
+
|
307
|
+
def url
|
308
|
+
@properties['url']
|
309
|
+
end
|
310
|
+
|
311
|
+
##
|
312
|
+
# Deletes the ShortCodeInstance
|
313
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
314
|
+
def delete
|
315
|
+
context.delete
|
316
|
+
end
|
317
|
+
|
318
|
+
##
|
319
|
+
# Fetch a ShortCodeInstance
|
320
|
+
# @return [ShortCodeInstance] Fetched ShortCodeInstance
|
321
|
+
def fetch
|
322
|
+
context.fetch
|
323
|
+
end
|
324
|
+
|
325
|
+
##
|
326
|
+
# Provide a user friendly representation
|
327
|
+
def to_s
|
328
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
329
|
+
"<Twilio.Preview.Proxy.ShortCodeInstance #{values}>"
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
@@ -0,0 +1,467 @@
|
|
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 Proxy < Version
|
11
|
+
class ServiceList < ListResource
|
12
|
+
##
|
13
|
+
# Initialize the ServiceList
|
14
|
+
# @param [Version] version Version that contains the resource
|
15
|
+
# @return [ServiceList] ServiceList
|
16
|
+
def initialize(version)
|
17
|
+
super(version)
|
18
|
+
|
19
|
+
# Path Solution
|
20
|
+
@solution = {}
|
21
|
+
@uri = "/Services"
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Lists ServiceInstance records from the API as a list.
|
26
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
27
|
+
# memory before returning.
|
28
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
29
|
+
# guarantees to never return more than limit. Default is no limit
|
30
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
31
|
+
# the default value of 50 records. If no page_size is defined
|
32
|
+
# but a limit is defined, stream() will attempt to read the
|
33
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
34
|
+
# @return [Array] Array of up to limit results
|
35
|
+
def list(limit: nil, page_size: nil)
|
36
|
+
self.stream(
|
37
|
+
limit: limit,
|
38
|
+
page_size: page_size
|
39
|
+
).entries
|
40
|
+
end
|
41
|
+
|
42
|
+
##
|
43
|
+
# Streams ServiceInstance records from the API as an Enumerable.
|
44
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
45
|
+
# is reached.
|
46
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
47
|
+
# guarantees to never return more than limit. Default is no limit
|
48
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
49
|
+
# the default value of 50 records. If no page_size is defined
|
50
|
+
# but a limit is defined, stream() will attempt to read the
|
51
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
52
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
53
|
+
def stream(limit: nil, page_size: nil)
|
54
|
+
limits = @version.read_limits(limit, page_size)
|
55
|
+
|
56
|
+
page = self.page(
|
57
|
+
page_size: limits[:page_size],
|
58
|
+
)
|
59
|
+
|
60
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# When passed a block, yields ServiceInstance records from the API.
|
65
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
66
|
+
# is reached.
|
67
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
68
|
+
# guarantees to never return more than limit. Default is no limit
|
69
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
70
|
+
# the default value of 50 records. If no page_size is defined
|
71
|
+
# but a limit is defined, stream() will attempt to read the
|
72
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
73
|
+
def each
|
74
|
+
limits = @version.read_limits
|
75
|
+
|
76
|
+
page = self.page(
|
77
|
+
page_size: limits[:page_size],
|
78
|
+
)
|
79
|
+
|
80
|
+
@version.stream(page,
|
81
|
+
limit: limits[:limit],
|
82
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
83
|
+
end
|
84
|
+
|
85
|
+
##
|
86
|
+
# Retrieve a single page of ServiceInstance records from the API.
|
87
|
+
# Request is executed immediately.
|
88
|
+
# @param [String] page_token PageToken provided by the API
|
89
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
90
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
91
|
+
# @return [Page] Page of ServiceInstance
|
92
|
+
def page(page_token: nil, page_number: nil, page_size: nil)
|
93
|
+
params = {
|
94
|
+
'PageToken' => page_token,
|
95
|
+
'Page' => page_number,
|
96
|
+
'PageSize' => page_size,
|
97
|
+
}
|
98
|
+
response = @version.page(
|
99
|
+
'GET',
|
100
|
+
@uri,
|
101
|
+
params
|
102
|
+
)
|
103
|
+
return ServicePage.new(@version, response, @solution)
|
104
|
+
end
|
105
|
+
|
106
|
+
##
|
107
|
+
# Retrieve a single page of ServiceInstance records from the API.
|
108
|
+
# Request is executed immediately.
|
109
|
+
# @param [String] friendly_name A human readable description of this resource, up
|
110
|
+
# to 64 characters.
|
111
|
+
# @param [Boolean] auto_create Boolean flag specifying whether to create threads
|
112
|
+
# when a user communticates out of band.
|
113
|
+
# @param [String] callback_url The URL Twilio will request for callback
|
114
|
+
# notifications.
|
115
|
+
# @return [ServiceInstance] Newly created ServiceInstance
|
116
|
+
def create(friendly_name: nil, auto_create: nil, callback_url: nil)
|
117
|
+
data = {
|
118
|
+
'FriendlyName' => friendly_name,
|
119
|
+
'AutoCreate' => auto_create,
|
120
|
+
'CallbackUrl' => callback_url,
|
121
|
+
}
|
122
|
+
|
123
|
+
payload = @version.create(
|
124
|
+
'POST',
|
125
|
+
@uri,
|
126
|
+
data: data
|
127
|
+
)
|
128
|
+
|
129
|
+
return ServiceInstance.new(
|
130
|
+
@version,
|
131
|
+
payload,
|
132
|
+
)
|
133
|
+
end
|
134
|
+
|
135
|
+
##
|
136
|
+
# Provide a user friendly representation
|
137
|
+
def to_s
|
138
|
+
'#<Twilio.Preview.Proxy.ServiceList>'
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
class ServicePage < Page
|
143
|
+
##
|
144
|
+
# Initialize the ServicePage
|
145
|
+
# @param [Version] version Version that contains the resource
|
146
|
+
# @param [Response] response Response from the API
|
147
|
+
# @param [Hash] solution Path solution for the resource
|
148
|
+
# @return [ServicePage] ServicePage
|
149
|
+
def initialize(version, response, solution)
|
150
|
+
super(version, response)
|
151
|
+
|
152
|
+
# Path Solution
|
153
|
+
@solution = solution
|
154
|
+
end
|
155
|
+
|
156
|
+
##
|
157
|
+
# Build an instance of ServiceInstance
|
158
|
+
# @param [Hash] payload Payload response from the API
|
159
|
+
# @return [ServiceInstance] ServiceInstance
|
160
|
+
def get_instance(payload)
|
161
|
+
return ServiceInstance.new(
|
162
|
+
@version,
|
163
|
+
payload,
|
164
|
+
)
|
165
|
+
end
|
166
|
+
|
167
|
+
##
|
168
|
+
# Provide a user friendly representation
|
169
|
+
def to_s
|
170
|
+
'<Twilio.Preview.Proxy.ServicePage>'
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
class ServiceContext < InstanceContext
|
175
|
+
##
|
176
|
+
# Initialize the ServiceContext
|
177
|
+
# @param [Version] version Version that contains the resource
|
178
|
+
# @param [String] sid A 34 character string that uniquely identifies this Service.
|
179
|
+
# @return [ServiceContext] ServiceContext
|
180
|
+
def initialize(version, sid)
|
181
|
+
super(version)
|
182
|
+
|
183
|
+
# Path Solution
|
184
|
+
@solution = {
|
185
|
+
sid: sid,
|
186
|
+
}
|
187
|
+
@uri = "/Services/#{@solution[:sid]}"
|
188
|
+
|
189
|
+
# Dependents
|
190
|
+
@sessions = nil
|
191
|
+
@phone_numbers = nil
|
192
|
+
@short_codes = nil
|
193
|
+
end
|
194
|
+
|
195
|
+
##
|
196
|
+
# Fetch a ServiceInstance
|
197
|
+
# @return [ServiceInstance] Fetched ServiceInstance
|
198
|
+
def fetch
|
199
|
+
params = {}
|
200
|
+
|
201
|
+
payload = @version.fetch(
|
202
|
+
'GET',
|
203
|
+
@uri,
|
204
|
+
params,
|
205
|
+
)
|
206
|
+
|
207
|
+
return ServiceInstance.new(
|
208
|
+
@version,
|
209
|
+
payload,
|
210
|
+
sid: @solution[:sid],
|
211
|
+
)
|
212
|
+
end
|
213
|
+
|
214
|
+
##
|
215
|
+
# Deletes the ServiceInstance
|
216
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
217
|
+
def delete
|
218
|
+
return @version.delete('delete', @uri)
|
219
|
+
end
|
220
|
+
|
221
|
+
##
|
222
|
+
# Update the ServiceInstance
|
223
|
+
# @param [String] friendly_name A human readable description of this resource, up
|
224
|
+
# to 64 characters.
|
225
|
+
# @param [Boolean] auto_create Boolean flag specifying whether to create threads
|
226
|
+
# when a user communticates out of band.
|
227
|
+
# @param [String] callback_url The URL Twilio will request for callback
|
228
|
+
# notifications.
|
229
|
+
# @return [ServiceInstance] Updated ServiceInstance
|
230
|
+
def update(friendly_name: nil, auto_create: nil, callback_url: nil)
|
231
|
+
data = {
|
232
|
+
'FriendlyName' => friendly_name,
|
233
|
+
'AutoCreate' => auto_create,
|
234
|
+
'CallbackUrl' => callback_url,
|
235
|
+
}
|
236
|
+
|
237
|
+
payload = @version.update(
|
238
|
+
'POST',
|
239
|
+
@uri,
|
240
|
+
data: data,
|
241
|
+
)
|
242
|
+
|
243
|
+
return ServiceInstance.new(
|
244
|
+
@version,
|
245
|
+
payload,
|
246
|
+
sid: @solution[:sid],
|
247
|
+
)
|
248
|
+
end
|
249
|
+
|
250
|
+
##
|
251
|
+
# Access the sessions
|
252
|
+
# @return [SessionList] SessionList
|
253
|
+
def sessions(sid=:unset)
|
254
|
+
if sid != :unset
|
255
|
+
return SessionContext.new(
|
256
|
+
@version,
|
257
|
+
@solution[:sid],
|
258
|
+
sid,
|
259
|
+
)
|
260
|
+
end
|
261
|
+
|
262
|
+
unless @sessions
|
263
|
+
@sessions = SessionList.new(
|
264
|
+
@version,
|
265
|
+
service_sid: @solution[:sid],
|
266
|
+
)
|
267
|
+
end
|
268
|
+
|
269
|
+
@sessions
|
270
|
+
end
|
271
|
+
|
272
|
+
##
|
273
|
+
# Access the phone_numbers
|
274
|
+
# @return [PhoneNumberList] PhoneNumberList
|
275
|
+
def phone_numbers(sid=:unset)
|
276
|
+
if sid != :unset
|
277
|
+
return PhoneNumberContext.new(
|
278
|
+
@version,
|
279
|
+
@solution[:sid],
|
280
|
+
sid,
|
281
|
+
)
|
282
|
+
end
|
283
|
+
|
284
|
+
unless @phone_numbers
|
285
|
+
@phone_numbers = PhoneNumberList.new(
|
286
|
+
@version,
|
287
|
+
service_sid: @solution[:sid],
|
288
|
+
)
|
289
|
+
end
|
290
|
+
|
291
|
+
@phone_numbers
|
292
|
+
end
|
293
|
+
|
294
|
+
##
|
295
|
+
# Access the short_codes
|
296
|
+
# @return [ShortCodeList] ShortCodeList
|
297
|
+
def short_codes(sid=:unset)
|
298
|
+
if sid != :unset
|
299
|
+
return ShortCodeContext.new(
|
300
|
+
@version,
|
301
|
+
@solution[:sid],
|
302
|
+
sid,
|
303
|
+
)
|
304
|
+
end
|
305
|
+
|
306
|
+
unless @short_codes
|
307
|
+
@short_codes = ShortCodeList.new(
|
308
|
+
@version,
|
309
|
+
service_sid: @solution[:sid],
|
310
|
+
)
|
311
|
+
end
|
312
|
+
|
313
|
+
@short_codes
|
314
|
+
end
|
315
|
+
|
316
|
+
##
|
317
|
+
# Provide a user friendly representation
|
318
|
+
def to_s
|
319
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
320
|
+
"#<Twilio.Preview.Proxy.ServiceContext #{context}>"
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
class ServiceInstance < InstanceResource
|
325
|
+
##
|
326
|
+
# Initialize the ServiceInstance
|
327
|
+
# @param [Version] version Version that contains the resource
|
328
|
+
# @param [Hash] payload payload that contains response from Twilio
|
329
|
+
# @param [String] sid A 34 character string that uniquely identifies this Service.
|
330
|
+
# @return [ServiceInstance] ServiceInstance
|
331
|
+
def initialize(version, payload, sid: nil)
|
332
|
+
super(version)
|
333
|
+
|
334
|
+
# Marshaled Properties
|
335
|
+
@properties = {
|
336
|
+
'sid' => payload['sid'],
|
337
|
+
'friendly_name' => payload['friendly_name'],
|
338
|
+
'account_sid' => payload['account_sid'],
|
339
|
+
'auto_create' => payload['auto_create'],
|
340
|
+
'callback_url' => payload['callback_url'],
|
341
|
+
'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
|
342
|
+
'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
|
343
|
+
'url' => payload['url'],
|
344
|
+
'links' => payload['links'],
|
345
|
+
}
|
346
|
+
|
347
|
+
# Context
|
348
|
+
@instance_context = nil
|
349
|
+
@params = {
|
350
|
+
'sid' => sid || @properties['sid'],
|
351
|
+
}
|
352
|
+
end
|
353
|
+
|
354
|
+
##
|
355
|
+
# Generate an instance context for the instance, the context is capable of
|
356
|
+
# performing various actions. All instance actions are proxied to the context
|
357
|
+
# @param [Version] version Version that contains the resource
|
358
|
+
# @return [ServiceContext] ServiceContext for this ServiceInstance
|
359
|
+
def context
|
360
|
+
unless @instance_context
|
361
|
+
@instance_context = ServiceContext.new(
|
362
|
+
@version,
|
363
|
+
@params['sid'],
|
364
|
+
)
|
365
|
+
end
|
366
|
+
@instance_context
|
367
|
+
end
|
368
|
+
|
369
|
+
def sid
|
370
|
+
@properties['sid']
|
371
|
+
end
|
372
|
+
|
373
|
+
def friendly_name
|
374
|
+
@properties['friendly_name']
|
375
|
+
end
|
376
|
+
|
377
|
+
def account_sid
|
378
|
+
@properties['account_sid']
|
379
|
+
end
|
380
|
+
|
381
|
+
def auto_create
|
382
|
+
@properties['auto_create']
|
383
|
+
end
|
384
|
+
|
385
|
+
def callback_url
|
386
|
+
@properties['callback_url']
|
387
|
+
end
|
388
|
+
|
389
|
+
def date_created
|
390
|
+
@properties['date_created']
|
391
|
+
end
|
392
|
+
|
393
|
+
def date_updated
|
394
|
+
@properties['date_updated']
|
395
|
+
end
|
396
|
+
|
397
|
+
def url
|
398
|
+
@properties['url']
|
399
|
+
end
|
400
|
+
|
401
|
+
def links
|
402
|
+
@properties['links']
|
403
|
+
end
|
404
|
+
|
405
|
+
##
|
406
|
+
# Fetch a ServiceInstance
|
407
|
+
# @return [ServiceInstance] Fetched ServiceInstance
|
408
|
+
def fetch
|
409
|
+
context.fetch
|
410
|
+
end
|
411
|
+
|
412
|
+
##
|
413
|
+
# Deletes the ServiceInstance
|
414
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
415
|
+
def delete
|
416
|
+
context.delete
|
417
|
+
end
|
418
|
+
|
419
|
+
##
|
420
|
+
# Update the ServiceInstance
|
421
|
+
# @param [String] friendly_name A human readable description of this resource, up
|
422
|
+
# to 64 characters.
|
423
|
+
# @param [Boolean] auto_create Boolean flag specifying whether to create threads
|
424
|
+
# when a user communticates out of band.
|
425
|
+
# @param [String] callback_url The URL Twilio will request for callback
|
426
|
+
# notifications.
|
427
|
+
# @return [ServiceInstance] Updated ServiceInstance
|
428
|
+
def update(friendly_name: nil, auto_create: nil, callback_url: nil)
|
429
|
+
context.update(
|
430
|
+
friendly_name: friendly_name,
|
431
|
+
auto_create: auto_create,
|
432
|
+
callback_url: callback_url,
|
433
|
+
)
|
434
|
+
end
|
435
|
+
|
436
|
+
##
|
437
|
+
# Access the sessions
|
438
|
+
# @return [sessions] sessions
|
439
|
+
def sessions
|
440
|
+
context.sessions
|
441
|
+
end
|
442
|
+
|
443
|
+
##
|
444
|
+
# Access the phone_numbers
|
445
|
+
# @return [phone_numbers] phone_numbers
|
446
|
+
def phone_numbers
|
447
|
+
context.phone_numbers
|
448
|
+
end
|
449
|
+
|
450
|
+
##
|
451
|
+
# Access the short_codes
|
452
|
+
# @return [short_codes] short_codes
|
453
|
+
def short_codes
|
454
|
+
context.short_codes
|
455
|
+
end
|
456
|
+
|
457
|
+
##
|
458
|
+
# Provide a user friendly representation
|
459
|
+
def to_s
|
460
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
461
|
+
"<Twilio.Preview.Proxy.ServiceInstance #{values}>"
|
462
|
+
end
|
463
|
+
end
|
464
|
+
end
|
465
|
+
end
|
466
|
+
end
|
467
|
+
end
|