twilio-ruby 5.11.2 → 5.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +20 -0
  3. data/Makefile +2 -0
  4. data/README.md +2 -2
  5. data/lib/twilio-ruby/rest/chat/v2/service/channel.rb +13 -6
  6. data/lib/twilio-ruby/rest/chat/v2/service/channel/member.rb +10 -4
  7. data/lib/twilio-ruby/rest/chat/v2/service/channel/message.rb +18 -6
  8. data/lib/twilio-ruby/rest/chat/v2/service/user.rb +7 -3
  9. data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb +13 -6
  10. data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/member.rb +10 -4
  11. data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb +18 -6
  12. data/lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb +7 -3
  13. data/lib/twilio-ruby/rest/notify/v1/service.rb +0 -46
  14. data/lib/twilio-ruby/rest/preview.rb +13 -20
  15. data/lib/twilio-ruby/rest/preview/marketplace.rb +13 -13
  16. data/lib/twilio-ruby/rest/preview/understand/assistant/intent.rb +16 -0
  17. data/lib/twilio-ruby/rest/preview/understand/assistant/intent/intent_statistics.rb +226 -0
  18. data/lib/twilio-ruby/rest/studio/v1/flow/execution.rb +1 -1
  19. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb +102 -50
  20. data/lib/twilio-ruby/rest/video.rb +9 -9
  21. data/lib/twilio-ruby/rest/video/v1.rb +16 -16
  22. data/lib/twilio-ruby/twiml/voice_response.rb +42 -0
  23. data/lib/twilio-ruby/version.rb +1 -1
  24. data/spec/integration/chat/v2/service/channel/message_spec.rb +1 -1
  25. data/spec/integration/ip_messaging/v2/service/channel/message_spec.rb +1 -1
  26. data/spec/integration/preview/understand/assistant/intent/intent_statistics_spec.rb +50 -0
  27. data/spec/integration/preview/understand/assistant/intent_spec.rb +8 -4
  28. data/spec/integration/taskrouter/v1/workspace/task/reservation_spec.rb +31 -0
  29. metadata +6 -37
  30. data/lib/twilio-ruby/rest/notify/v1/service/segment.rb +0 -225
  31. data/lib/twilio-ruby/rest/notify/v1/service/user.rb +0 -438
  32. data/lib/twilio-ruby/rest/notify/v1/service/user/segment_memberships.rb +0 -262
  33. data/lib/twilio-ruby/rest/notify/v1/service/user/user_binding.rb +0 -438
  34. data/lib/twilio-ruby/rest/preview/proxy.rb +0 -43
  35. data/lib/twilio-ruby/rest/preview/proxy/service.rb +0 -464
  36. data/lib/twilio-ruby/rest/preview/proxy/service/phone_number.rb +0 -347
  37. data/lib/twilio-ruby/rest/preview/proxy/service/session.rb +0 -497
  38. data/lib/twilio-ruby/rest/preview/proxy/service/session/interaction.rb +0 -437
  39. data/lib/twilio-ruby/rest/preview/proxy/service/session/participant.rb +0 -514
  40. data/lib/twilio-ruby/rest/preview/proxy/service/session/participant/message_interaction.rb +0 -455
  41. data/lib/twilio-ruby/rest/preview/proxy/service/short_code.rb +0 -342
  42. data/spec/integration/notify/v1/service/segment_spec.rb +0 -86
  43. data/spec/integration/notify/v1/service/user/segment_memberships_spec.rb +0 -118
  44. data/spec/integration/notify/v1/service/user/user_binding_spec.rb +0 -268
  45. data/spec/integration/notify/v1/service/user_spec.rb +0 -213
  46. data/spec/integration/preview/proxy/service/phone_number_spec.rb +0 -173
  47. data/spec/integration/preview/proxy/service/session/interaction_spec.rb +0 -106
  48. data/spec/integration/preview/proxy/service/session/participant/message_interaction_spec.rb +0 -166
  49. data/spec/integration/preview/proxy/service/session/participant_spec.rb +0 -226
  50. data/spec/integration/preview/proxy/service/session_spec.rb +0 -218
  51. data/spec/integration/preview/proxy/service/short_code_spec.rb +0 -173
  52. data/spec/integration/preview/proxy/service_spec.rb +0 -202
@@ -1,347 +0,0 @@
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 Preview < Domain
12
- class Proxy < Version
13
- class ServiceContext < InstanceContext
14
- ##
15
- # 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.
16
- class PhoneNumberList < ListResource
17
- ##
18
- # Initialize the PhoneNumberList
19
- # @param [Version] version Version that contains the resource
20
- # @param [String] service_sid The unique SID identifier of the Service.
21
- # @return [PhoneNumberList] PhoneNumberList
22
- def initialize(version, service_sid: nil)
23
- super(version)
24
-
25
- # Path Solution
26
- @solution = {service_sid: service_sid}
27
- @uri = "/Services/#{@solution[:service_sid]}/PhoneNumbers"
28
- end
29
-
30
- ##
31
- # Retrieve a single page of PhoneNumberInstance records from the API.
32
- # Request is executed immediately.
33
- # @param [String] sid The phone-number Sid that uniquely identifies this resource
34
- # @return [PhoneNumberInstance] Newly created PhoneNumberInstance
35
- def create(sid: nil)
36
- data = Twilio::Values.of({'Sid' => sid, })
37
-
38
- payload = @version.create(
39
- 'POST',
40
- @uri,
41
- data: data
42
- )
43
-
44
- PhoneNumberInstance.new(@version, payload, service_sid: @solution[:service_sid], )
45
- end
46
-
47
- ##
48
- # Lists PhoneNumberInstance records from the API as a list.
49
- # Unlike stream(), this operation is eager and will load `limit` records into
50
- # memory before returning.
51
- # @param [Integer] limit Upper limit for the number of records to return. stream()
52
- # guarantees to never return more than limit. Default is no limit
53
- # @param [Integer] page_size Number of records to fetch per request, when
54
- # not set will use the default value of 50 records. If no page_size is defined
55
- # but a limit is defined, stream() will attempt to read the limit with the most
56
- # efficient page size, i.e. min(limit, 1000)
57
- # @return [Array] Array of up to limit results
58
- def list(limit: nil, page_size: nil)
59
- self.stream(limit: limit, page_size: page_size).entries
60
- end
61
-
62
- ##
63
- # Streams PhoneNumberInstance records from the API as an Enumerable.
64
- # This operation lazily loads records as efficiently as possible until the limit
65
- # is reached.
66
- # @param [Integer] limit Upper limit for the number of records to return. stream()
67
- # guarantees to never return more than limit. Default is no limit.
68
- # @param [Integer] page_size Number of records to fetch per request, when
69
- # not set will use the default value of 50 records. If no page_size is defined
70
- # but a limit is defined, stream() will attempt to read the limit with the most
71
- # efficient page size, i.e. min(limit, 1000)
72
- # @return [Enumerable] Enumerable that will yield up to limit results
73
- def stream(limit: nil, page_size: nil)
74
- limits = @version.read_limits(limit, page_size)
75
-
76
- page = self.page(page_size: limits[:page_size], )
77
-
78
- @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
79
- end
80
-
81
- ##
82
- # When passed a block, yields PhoneNumberInstance records from the API.
83
- # This operation lazily loads records as efficiently as possible until the limit
84
- # is reached.
85
- def each
86
- limits = @version.read_limits
87
-
88
- page = self.page(page_size: limits[:page_size], )
89
-
90
- @version.stream(page,
91
- limit: limits[:limit],
92
- page_limit: limits[:page_limit]).each {|x| yield x}
93
- end
94
-
95
- ##
96
- # Retrieve a single page of PhoneNumberInstance records from the API.
97
- # Request is executed immediately.
98
- # @param [String] page_token PageToken provided by the API
99
- # @param [Integer] page_number Page Number, this value is simply for client state
100
- # @param [Integer] page_size Number of records to return, defaults to 50
101
- # @return [Page] Page of PhoneNumberInstance
102
- def page(page_token: :unset, page_number: :unset, page_size: :unset)
103
- params = Twilio::Values.of({
104
- 'PageToken' => page_token,
105
- 'Page' => page_number,
106
- 'PageSize' => page_size,
107
- })
108
- response = @version.page(
109
- 'GET',
110
- @uri,
111
- params
112
- )
113
- PhoneNumberPage.new(@version, response, @solution)
114
- end
115
-
116
- ##
117
- # Retrieve a single page of PhoneNumberInstance records from the API.
118
- # Request is executed immediately.
119
- # @param [String] target_url API-generated URL for the requested results page
120
- # @return [Page] Page of PhoneNumberInstance
121
- def get_page(target_url)
122
- response = @version.domain.request(
123
- 'GET',
124
- target_url
125
- )
126
- PhoneNumberPage.new(@version, response, @solution)
127
- end
128
-
129
- ##
130
- # Provide a user friendly representation
131
- def to_s
132
- '#<Twilio.Preview.Proxy.PhoneNumberList>'
133
- end
134
- end
135
-
136
- ##
137
- # 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.
138
- class PhoneNumberPage < Page
139
- ##
140
- # Initialize the PhoneNumberPage
141
- # @param [Version] version Version that contains the resource
142
- # @param [Response] response Response from the API
143
- # @param [Hash] solution Path solution for the resource
144
- # @return [PhoneNumberPage] PhoneNumberPage
145
- def initialize(version, response, solution)
146
- super(version, response)
147
-
148
- # Path Solution
149
- @solution = solution
150
- end
151
-
152
- ##
153
- # Build an instance of PhoneNumberInstance
154
- # @param [Hash] payload Payload response from the API
155
- # @return [PhoneNumberInstance] PhoneNumberInstance
156
- def get_instance(payload)
157
- PhoneNumberInstance.new(@version, payload, service_sid: @solution[:service_sid], )
158
- end
159
-
160
- ##
161
- # Provide a user friendly representation
162
- def to_s
163
- '<Twilio.Preview.Proxy.PhoneNumberPage>'
164
- end
165
- end
166
-
167
- ##
168
- # 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.
169
- class PhoneNumberContext < InstanceContext
170
- ##
171
- # Initialize the PhoneNumberContext
172
- # @param [Version] version Version that contains the resource
173
- # @param [String] service_sid The service_sid
174
- # @param [String] sid The phone-number Sid that uniquely identifies this resource
175
- # @return [PhoneNumberContext] PhoneNumberContext
176
- def initialize(version, service_sid, sid)
177
- super(version)
178
-
179
- # Path Solution
180
- @solution = {service_sid: service_sid, sid: sid, }
181
- @uri = "/Services/#{@solution[:service_sid]}/PhoneNumbers/#{@solution[:sid]}"
182
- end
183
-
184
- ##
185
- # Deletes the PhoneNumberInstance
186
- # @return [Boolean] true if delete succeeds, true otherwise
187
- def delete
188
- @version.delete('delete', @uri)
189
- end
190
-
191
- ##
192
- # Fetch a PhoneNumberInstance
193
- # @return [PhoneNumberInstance] Fetched PhoneNumberInstance
194
- def fetch
195
- params = Twilio::Values.of({})
196
-
197
- payload = @version.fetch(
198
- 'GET',
199
- @uri,
200
- params,
201
- )
202
-
203
- PhoneNumberInstance.new(
204
- @version,
205
- payload,
206
- service_sid: @solution[:service_sid],
207
- sid: @solution[:sid],
208
- )
209
- end
210
-
211
- ##
212
- # Provide a user friendly representation
213
- def to_s
214
- context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
215
- "#<Twilio.Preview.Proxy.PhoneNumberContext #{context}>"
216
- end
217
- end
218
-
219
- ##
220
- # 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.
221
- class PhoneNumberInstance < InstanceResource
222
- ##
223
- # Initialize the PhoneNumberInstance
224
- # @param [Version] version Version that contains the resource
225
- # @param [Hash] payload payload that contains response from Twilio
226
- # @param [String] service_sid The unique SID identifier of the Service.
227
- # @param [String] sid The phone-number Sid that uniquely identifies this resource
228
- # @return [PhoneNumberInstance] PhoneNumberInstance
229
- def initialize(version, payload, service_sid: nil, sid: nil)
230
- super(version)
231
-
232
- # Marshaled Properties
233
- @properties = {
234
- 'sid' => payload['sid'],
235
- 'account_sid' => payload['account_sid'],
236
- 'service_sid' => payload['service_sid'],
237
- 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
238
- 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
239
- 'phone_number' => payload['phone_number'],
240
- 'country_code' => payload['country_code'],
241
- 'capabilities' => payload['capabilities'],
242
- 'url' => payload['url'],
243
- }
244
-
245
- # Context
246
- @instance_context = nil
247
- @params = {'service_sid' => service_sid, 'sid' => sid || @properties['sid'], }
248
- end
249
-
250
- ##
251
- # Generate an instance context for the instance, the context is capable of
252
- # performing various actions. All instance actions are proxied to the context
253
- # @return [PhoneNumberContext] PhoneNumberContext for this PhoneNumberInstance
254
- def context
255
- unless @instance_context
256
- @instance_context = PhoneNumberContext.new(@version, @params['service_sid'], @params['sid'], )
257
- end
258
- @instance_context
259
- end
260
-
261
- ##
262
- # @return [String] A string that uniquely identifies this resource
263
- def sid
264
- @properties['sid']
265
- end
266
-
267
- ##
268
- # @return [String] Account Sid.
269
- def account_sid
270
- @properties['account_sid']
271
- end
272
-
273
- ##
274
- # @return [String] Service Sid.
275
- def service_sid
276
- @properties['service_sid']
277
- end
278
-
279
- ##
280
- # @return [Time] The date this resource was created
281
- def date_created
282
- @properties['date_created']
283
- end
284
-
285
- ##
286
- # @return [Time] The date this resource was last updated
287
- def date_updated
288
- @properties['date_updated']
289
- end
290
-
291
- ##
292
- # @return [String] The phone number
293
- def phone_number
294
- @properties['phone_number']
295
- end
296
-
297
- ##
298
- # @return [String] The ISO 3166-1 alpha-2 country code
299
- def country_code
300
- @properties['country_code']
301
- end
302
-
303
- ##
304
- # @return [String] Indicate if a phone can receive calls or messages
305
- def capabilities
306
- @properties['capabilities']
307
- end
308
-
309
- ##
310
- # @return [String] The URL of this resource.
311
- def url
312
- @properties['url']
313
- end
314
-
315
- ##
316
- # Deletes the PhoneNumberInstance
317
- # @return [Boolean] true if delete succeeds, true otherwise
318
- def delete
319
- context.delete
320
- end
321
-
322
- ##
323
- # Fetch a PhoneNumberInstance
324
- # @return [PhoneNumberInstance] Fetched PhoneNumberInstance
325
- def fetch
326
- context.fetch
327
- end
328
-
329
- ##
330
- # Provide a user friendly representation
331
- def to_s
332
- values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
333
- "<Twilio.Preview.Proxy.PhoneNumberInstance #{values}>"
334
- end
335
-
336
- ##
337
- # Provide a detailed, user friendly representation
338
- def inspect
339
- values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
340
- "<Twilio.Preview.Proxy.PhoneNumberInstance #{values}>"
341
- end
342
- end
343
- end
344
- end
345
- end
346
- end
347
- end
@@ -1,497 +0,0 @@
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 Preview < Domain
12
- class Proxy < Version
13
- class ServiceContext < InstanceContext
14
- ##
15
- # 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.
16
- class SessionList < ListResource
17
- ##
18
- # Initialize the SessionList
19
- # @param [Version] version Version that contains the resource
20
- # @param [String] service_sid The unique SID identifier of the Service.
21
- # @return [SessionList] SessionList
22
- def initialize(version, service_sid: nil)
23
- super(version)
24
-
25
- # Path Solution
26
- @solution = {service_sid: service_sid}
27
- @uri = "/Services/#{@solution[:service_sid]}/Sessions"
28
- end
29
-
30
- ##
31
- # Lists SessionInstance records from the API as a list.
32
- # Unlike stream(), this operation is eager and will load `limit` records into
33
- # memory before returning.
34
- # @param [String] unique_name Provides a unique and addressable name to be
35
- # assigned to this Session, assigned by the developer, to be optionally used in
36
- # addition to SID.
37
- # @param [session.Status] status The Status of this Session. One of `in-progess`
38
- # or `completed`.
39
- # @param [Integer] limit Upper limit for the number of records to return. stream()
40
- # guarantees to never return more than limit. Default is no limit
41
- # @param [Integer] page_size Number of records to fetch per request, when
42
- # not set will use the default value of 50 records. If no page_size is defined
43
- # but a limit is defined, stream() will attempt to read the limit with the most
44
- # efficient page size, i.e. min(limit, 1000)
45
- # @return [Array] Array of up to limit results
46
- def list(unique_name: :unset, status: :unset, limit: nil, page_size: nil)
47
- self.stream(unique_name: unique_name, status: status, limit: limit, page_size: page_size).entries
48
- end
49
-
50
- ##
51
- # Streams SessionInstance records from the API as an Enumerable.
52
- # This operation lazily loads records as efficiently as possible until the limit
53
- # is reached.
54
- # @param [String] unique_name Provides a unique and addressable name to be
55
- # assigned to this Session, assigned by the developer, to be optionally used in
56
- # addition to SID.
57
- # @param [session.Status] status The Status of this Session. One of `in-progess`
58
- # or `completed`.
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 [Enumerable] Enumerable that will yield up to limit results
66
- def stream(unique_name: :unset, status: :unset, limit: nil, page_size: nil)
67
- limits = @version.read_limits(limit, page_size)
68
-
69
- page = self.page(unique_name: unique_name, status: status, page_size: limits[:page_size], )
70
-
71
- @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
72
- end
73
-
74
- ##
75
- # When passed a block, yields SessionInstance records from the API.
76
- # This operation lazily loads records as efficiently as possible until the limit
77
- # is reached.
78
- def each
79
- limits = @version.read_limits
80
-
81
- page = self.page(page_size: limits[:page_size], )
82
-
83
- @version.stream(page,
84
- limit: limits[:limit],
85
- page_limit: limits[:page_limit]).each {|x| yield x}
86
- end
87
-
88
- ##
89
- # Retrieve a single page of SessionInstance records from the API.
90
- # Request is executed immediately.
91
- # @param [String] unique_name Provides a unique and addressable name to be
92
- # assigned to this Session, assigned by the developer, to be optionally used in
93
- # addition to SID.
94
- # @param [session.Status] status The Status of this Session. One of `in-progess`
95
- # or `completed`.
96
- # @param [String] page_token PageToken provided by the API
97
- # @param [Integer] page_number Page Number, this value is simply for client state
98
- # @param [Integer] page_size Number of records to return, defaults to 50
99
- # @return [Page] Page of SessionInstance
100
- def page(unique_name: :unset, status: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
101
- params = Twilio::Values.of({
102
- 'UniqueName' => unique_name,
103
- 'Status' => status,
104
- 'PageToken' => page_token,
105
- 'Page' => page_number,
106
- 'PageSize' => page_size,
107
- })
108
- response = @version.page(
109
- 'GET',
110
- @uri,
111
- params
112
- )
113
- SessionPage.new(@version, response, @solution)
114
- end
115
-
116
- ##
117
- # Retrieve a single page of SessionInstance records from the API.
118
- # Request is executed immediately.
119
- # @param [String] target_url API-generated URL for the requested results page
120
- # @return [Page] Page of SessionInstance
121
- def get_page(target_url)
122
- response = @version.domain.request(
123
- 'GET',
124
- target_url
125
- )
126
- SessionPage.new(@version, response, @solution)
127
- end
128
-
129
- ##
130
- # Retrieve a single page of SessionInstance records from the API.
131
- # Request is executed immediately.
132
- # @param [String] unique_name Provides a unique and addressable name to be
133
- # assigned to this Session, assigned by the developer, to be optionally used in
134
- # addition to SID.
135
- # @param [String] ttl How long will this session stay open, in seconds. Each new
136
- # interaction resets this timer.
137
- # @param [session.Status] status The Status of this Session. One of `in-progess`
138
- # or `completed`.
139
- # @param [String] participants The participants
140
- # @return [SessionInstance] Newly created SessionInstance
141
- def create(unique_name: :unset, ttl: :unset, status: :unset, participants: :unset)
142
- data = Twilio::Values.of({
143
- 'UniqueName' => unique_name,
144
- 'Ttl' => ttl,
145
- 'Status' => status,
146
- 'Participants' => Twilio.serialize_list(participants) { |e| e },
147
- })
148
-
149
- payload = @version.create(
150
- 'POST',
151
- @uri,
152
- data: data
153
- )
154
-
155
- SessionInstance.new(@version, payload, service_sid: @solution[:service_sid], )
156
- end
157
-
158
- ##
159
- # Provide a user friendly representation
160
- def to_s
161
- '#<Twilio.Preview.Proxy.SessionList>'
162
- end
163
- end
164
-
165
- ##
166
- # 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.
167
- class SessionPage < Page
168
- ##
169
- # Initialize the SessionPage
170
- # @param [Version] version Version that contains the resource
171
- # @param [Response] response Response from the API
172
- # @param [Hash] solution Path solution for the resource
173
- # @return [SessionPage] SessionPage
174
- def initialize(version, response, solution)
175
- super(version, response)
176
-
177
- # Path Solution
178
- @solution = solution
179
- end
180
-
181
- ##
182
- # Build an instance of SessionInstance
183
- # @param [Hash] payload Payload response from the API
184
- # @return [SessionInstance] SessionInstance
185
- def get_instance(payload)
186
- SessionInstance.new(@version, payload, service_sid: @solution[:service_sid], )
187
- end
188
-
189
- ##
190
- # Provide a user friendly representation
191
- def to_s
192
- '<Twilio.Preview.Proxy.SessionPage>'
193
- end
194
- end
195
-
196
- ##
197
- # 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.
198
- class SessionContext < InstanceContext
199
- ##
200
- # Initialize the SessionContext
201
- # @param [Version] version Version that contains the resource
202
- # @param [String] service_sid The unique SID identifier of the Service.
203
- # @param [String] sid A 34 character string that uniquely identifies this Session.
204
- # @return [SessionContext] SessionContext
205
- def initialize(version, service_sid, sid)
206
- super(version)
207
-
208
- # Path Solution
209
- @solution = {service_sid: service_sid, sid: sid, }
210
- @uri = "/Services/#{@solution[:service_sid]}/Sessions/#{@solution[:sid]}"
211
-
212
- # Dependents
213
- @interactions = nil
214
- @participants = nil
215
- end
216
-
217
- ##
218
- # Fetch a SessionInstance
219
- # @return [SessionInstance] Fetched SessionInstance
220
- def fetch
221
- params = Twilio::Values.of({})
222
-
223
- payload = @version.fetch(
224
- 'GET',
225
- @uri,
226
- params,
227
- )
228
-
229
- SessionInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
230
- end
231
-
232
- ##
233
- # Deletes the SessionInstance
234
- # @return [Boolean] true if delete succeeds, true otherwise
235
- def delete
236
- @version.delete('delete', @uri)
237
- end
238
-
239
- ##
240
- # Update the SessionInstance
241
- # @param [String] unique_name Provides a unique and addressable name to be
242
- # assigned to this Session, assigned by the developer, to be optionally used in
243
- # addition to SID.
244
- # @param [String] ttl How long will this session stay open, in seconds. Each new
245
- # interaction resets this timer.
246
- # @param [session.Status] status The Status of this Session. One of `in-progess`
247
- # or `completed`.
248
- # @param [String] participants The participants
249
- # @return [SessionInstance] Updated SessionInstance
250
- def update(unique_name: :unset, ttl: :unset, status: :unset, participants: :unset)
251
- data = Twilio::Values.of({
252
- 'UniqueName' => unique_name,
253
- 'Ttl' => ttl,
254
- 'Status' => status,
255
- 'Participants' => Twilio.serialize_list(participants) { |e| e },
256
- })
257
-
258
- payload = @version.update(
259
- 'POST',
260
- @uri,
261
- data: data,
262
- )
263
-
264
- SessionInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
265
- end
266
-
267
- ##
268
- # Access the interactions
269
- # @return [InteractionList]
270
- # @return [InteractionContext] if sid was passed.
271
- def interactions(sid=:unset)
272
- raise ArgumentError, 'sid cannot be nil' if sid.nil?
273
-
274
- if sid != :unset
275
- return InteractionContext.new(@version, @solution[:service_sid], @solution[:sid], sid, )
276
- end
277
-
278
- unless @interactions
279
- @interactions = InteractionList.new(
280
- @version,
281
- service_sid: @solution[:service_sid],
282
- session_sid: @solution[:sid],
283
- )
284
- end
285
-
286
- @interactions
287
- end
288
-
289
- ##
290
- # Access the participants
291
- # @return [ParticipantList]
292
- # @return [ParticipantContext] if sid was passed.
293
- def participants(sid=:unset)
294
- raise ArgumentError, 'sid cannot be nil' if sid.nil?
295
-
296
- if sid != :unset
297
- return ParticipantContext.new(@version, @solution[:service_sid], @solution[:sid], sid, )
298
- end
299
-
300
- unless @participants
301
- @participants = ParticipantList.new(
302
- @version,
303
- service_sid: @solution[:service_sid],
304
- session_sid: @solution[:sid],
305
- )
306
- end
307
-
308
- @participants
309
- end
310
-
311
- ##
312
- # Provide a user friendly representation
313
- def to_s
314
- context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
315
- "#<Twilio.Preview.Proxy.SessionContext #{context}>"
316
- end
317
- end
318
-
319
- ##
320
- # 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.
321
- class SessionInstance < InstanceResource
322
- ##
323
- # Initialize the SessionInstance
324
- # @param [Version] version Version that contains the resource
325
- # @param [Hash] payload payload that contains response from Twilio
326
- # @param [String] service_sid The unique SID identifier of the Service.
327
- # @param [String] sid A 34 character string that uniquely identifies this Session.
328
- # @return [SessionInstance] SessionInstance
329
- def initialize(version, payload, service_sid: nil, sid: nil)
330
- super(version)
331
-
332
- # Marshaled Properties
333
- @properties = {
334
- 'sid' => payload['sid'],
335
- 'service_sid' => payload['service_sid'],
336
- 'account_sid' => payload['account_sid'],
337
- 'unique_name' => payload['unique_name'],
338
- 'ttl' => payload['ttl'].to_i,
339
- 'status' => payload['status'],
340
- 'start_time' => Twilio.deserialize_iso8601_datetime(payload['start_time']),
341
- 'end_time' => Twilio.deserialize_iso8601_datetime(payload['end_time']),
342
- 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
343
- 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
344
- 'url' => payload['url'],
345
- 'links' => payload['links'],
346
- }
347
-
348
- # Context
349
- @instance_context = nil
350
- @params = {'service_sid' => service_sid, 'sid' => sid || @properties['sid'], }
351
- end
352
-
353
- ##
354
- # Generate an instance context for the instance, the context is capable of
355
- # performing various actions. All instance actions are proxied to the context
356
- # @return [SessionContext] SessionContext for this SessionInstance
357
- def context
358
- unless @instance_context
359
- @instance_context = SessionContext.new(@version, @params['service_sid'], @params['sid'], )
360
- end
361
- @instance_context
362
- end
363
-
364
- ##
365
- # @return [String] A string that uniquely identifies this Session.
366
- def sid
367
- @properties['sid']
368
- end
369
-
370
- ##
371
- # @return [String] Service Sid.
372
- def service_sid
373
- @properties['service_sid']
374
- end
375
-
376
- ##
377
- # @return [String] Account Sid.
378
- def account_sid
379
- @properties['account_sid']
380
- end
381
-
382
- ##
383
- # @return [String] A unique, developer assigned name of this Session.
384
- def unique_name
385
- @properties['unique_name']
386
- end
387
-
388
- ##
389
- # @return [String] How long will this session stay open, in seconds.
390
- def ttl
391
- @properties['ttl']
392
- end
393
-
394
- ##
395
- # @return [session.Status] The Status of this Session
396
- def status
397
- @properties['status']
398
- end
399
-
400
- ##
401
- # @return [Time] The date this Session was started
402
- def start_time
403
- @properties['start_time']
404
- end
405
-
406
- ##
407
- # @return [Time] The date this Session was ended
408
- def end_time
409
- @properties['end_time']
410
- end
411
-
412
- ##
413
- # @return [Time] The date this Session was created
414
- def date_created
415
- @properties['date_created']
416
- end
417
-
418
- ##
419
- # @return [Time] The date this Session was updated
420
- def date_updated
421
- @properties['date_updated']
422
- end
423
-
424
- ##
425
- # @return [String] The URL of this Session.
426
- def url
427
- @properties['url']
428
- end
429
-
430
- ##
431
- # @return [String] Nested resource URLs.
432
- def links
433
- @properties['links']
434
- end
435
-
436
- ##
437
- # Fetch a SessionInstance
438
- # @return [SessionInstance] Fetched SessionInstance
439
- def fetch
440
- context.fetch
441
- end
442
-
443
- ##
444
- # Deletes the SessionInstance
445
- # @return [Boolean] true if delete succeeds, true otherwise
446
- def delete
447
- context.delete
448
- end
449
-
450
- ##
451
- # Update the SessionInstance
452
- # @param [String] unique_name Provides a unique and addressable name to be
453
- # assigned to this Session, assigned by the developer, to be optionally used in
454
- # addition to SID.
455
- # @param [String] ttl How long will this session stay open, in seconds. Each new
456
- # interaction resets this timer.
457
- # @param [session.Status] status The Status of this Session. One of `in-progess`
458
- # or `completed`.
459
- # @param [String] participants The participants
460
- # @return [SessionInstance] Updated SessionInstance
461
- def update(unique_name: :unset, ttl: :unset, status: :unset, participants: :unset)
462
- context.update(unique_name: unique_name, ttl: ttl, status: status, participants: participants, )
463
- end
464
-
465
- ##
466
- # Access the interactions
467
- # @return [interactions] interactions
468
- def interactions
469
- context.interactions
470
- end
471
-
472
- ##
473
- # Access the participants
474
- # @return [participants] participants
475
- def participants
476
- context.participants
477
- end
478
-
479
- ##
480
- # Provide a user friendly representation
481
- def to_s
482
- values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
483
- "<Twilio.Preview.Proxy.SessionInstance #{values}>"
484
- end
485
-
486
- ##
487
- # Provide a detailed, user friendly representation
488
- def inspect
489
- values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
490
- "<Twilio.Preview.Proxy.SessionInstance #{values}>"
491
- end
492
- end
493
- end
494
- end
495
- end
496
- end
497
- end