twilio-ruby 5.0.0.rc16 → 5.0.0.rc17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHORS.md +1 -0
  3. data/CHANGES.md +1 -1
  4. data/README.md +2 -2
  5. data/lib/twilio-ruby/jwt/access_token.rb +23 -1
  6. data/lib/twilio-ruby/rest/api.rb +2 -2
  7. data/lib/twilio-ruby/rest/api/v2010.rb +2 -2
  8. data/lib/twilio-ruby/rest/api/v2010/account.rb +19 -11
  9. data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +29 -5
  10. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +5 -5
  11. data/lib/twilio-ruby/rest/api/v2010/account/recording.rb +25 -0
  12. data/lib/twilio-ruby/rest/api/v2010/account/short_code.rb +406 -0
  13. data/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list/credential.rb +2 -6
  14. data/lib/twilio-ruby/rest/{notifications.rb → chat.rb} +6 -6
  15. data/lib/twilio-ruby/rest/{notifications → chat}/v1.rb +3 -3
  16. data/lib/twilio-ruby/rest/{notifications → chat}/v1/credential.rb +5 -5
  17. data/lib/twilio-ruby/rest/chat/v1/service.rb +501 -0
  18. data/lib/twilio-ruby/rest/chat/v1/service/channel.rb +468 -0
  19. data/lib/twilio-ruby/rest/chat/v1/service/channel/member.rb +351 -0
  20. data/lib/twilio-ruby/rest/{api/v2010/account/sms/sms_message.rb → chat/v1/service/channel/message.rb} +120 -168
  21. data/lib/twilio-ruby/rest/chat/v1/service/role.rb +373 -0
  22. data/lib/twilio-ruby/rest/chat/v1/service/user.rb +378 -0
  23. data/lib/twilio-ruby/rest/client.rb +19 -8
  24. data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb +3 -1
  25. data/lib/twilio-ruby/rest/ip_messaging/v1/service/role.rb +2 -6
  26. data/lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb +5 -1
  27. data/lib/twilio-ruby/rest/lookups/v1/phone_number.rb +5 -0
  28. data/lib/twilio-ruby/rest/notify.rb +44 -0
  29. data/lib/twilio-ruby/rest/notify/v1.rb +44 -0
  30. data/lib/twilio-ruby/rest/notify/v1/credential.rb +375 -0
  31. data/lib/twilio-ruby/rest/{notifications → notify}/v1/service.rb +5 -5
  32. data/lib/twilio-ruby/rest/{notifications → notify}/v1/service/binding.rb +5 -5
  33. data/lib/twilio-ruby/rest/{notifications → notify}/v1/service/notification.rb +4 -4
  34. data/lib/twilio-ruby/rest/preview.rb +11 -0
  35. data/lib/twilio-ruby/rest/preview/sync.rb +35 -0
  36. data/lib/twilio-ruby/rest/preview/sync/service.rb +458 -0
  37. data/lib/twilio-ruby/rest/preview/sync/service/document.rb +376 -0
  38. data/lib/twilio-ruby/rest/preview/sync/service/sync_list.rb +375 -0
  39. data/lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_item.rb +409 -0
  40. data/lib/twilio-ruby/rest/preview/sync/service/sync_map.rb +375 -0
  41. data/lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_item.rb +411 -0
  42. data/lib/twilio-ruby/rest/preview/wireless/device.rb +6 -2
  43. data/lib/twilio-ruby/rest/taskrouter/v1/workspace.rb +55 -3
  44. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb +29 -6
  45. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb +294 -0
  46. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +32 -0
  47. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb +374 -0
  48. data/lib/twilio-ruby/version.rb +1 -1
  49. data/spec/integration/api/v2010/account/conference/participant_spec.rb +6 -6
  50. data/spec/integration/api/v2010/account/recording_spec.rb +10 -1
  51. data/spec/integration/api/v2010/account/{sms/short_code_spec.rb → short_code_spec.rb} +0 -7
  52. data/spec/integration/api/v2010/account/sip/credential_list/credential_spec.rb +3 -7
  53. data/spec/integration/chat/v1/credential_spec.rb +223 -0
  54. data/spec/integration/chat/v1/service/channel/member_spec.rb +213 -0
  55. data/spec/integration/chat/v1/service/channel/message_spec.rb +100 -0
  56. data/spec/integration/chat/v1/service/channel_spec.rb +259 -0
  57. data/spec/integration/chat/v1/service/role_spec.rb +263 -0
  58. data/spec/integration/chat/v1/service/user_spec.rb +242 -0
  59. data/spec/integration/chat/v1/service_spec.rb +263 -0
  60. data/spec/integration/ip_messaging/v1/service/role_spec.rb +2 -3
  61. data/spec/integration/ip_messaging/v1/service/user_spec.rb +2 -3
  62. data/spec/integration/lookups/v1/phone_number_spec.rb +5 -0
  63. data/spec/integration/{notifications → notify}/v1/credential_spec.rb +24 -24
  64. data/spec/integration/{notifications → notify}/v1/service/binding_spec.rb +29 -29
  65. data/spec/integration/{notifications → notify}/v1/service/notification_spec.rb +5 -5
  66. data/spec/integration/{notifications → notify}/v1/service_spec.rb +32 -32
  67. data/spec/integration/preview/sync/service/document_spec.rb +92 -0
  68. data/spec/integration/preview/sync/service/sync_list/sync_list_item_spec.rb +100 -0
  69. data/spec/integration/preview/sync/service/sync_list_spec.rb +73 -0
  70. data/spec/integration/preview/sync/service/sync_map/sync_map_item_spec.rb +101 -0
  71. data/spec/integration/preview/sync/service/sync_map_spec.rb +73 -0
  72. data/spec/integration/preview/sync/service_spec.rb +84 -0
  73. data/spec/integration/taskrouter/v1/workspace/task_channel_spec.rb +127 -0
  74. data/spec/integration/taskrouter/v1/workspace/task_spec.rb +8 -0
  75. data/spec/integration/taskrouter/v1/workspace/worker/worker_channel_spec.rb +201 -0
  76. data/spec/integration/taskrouter/v1/workspace/workflow_spec.rb +2 -3
  77. data/spec/integration/taskrouter/v1/workspace_spec.rb +8 -0
  78. data/spec/jwt/access_token_spec.rb +27 -0
  79. metadata +84 -42
  80. data/lib/twilio-ruby/rest/api/v2010/account/sms.rb +0 -134
  81. data/lib/twilio-ruby/rest/api/v2010/account/sms/short_code.rb +0 -408
  82. data/spec/integration/api/v2010/account/sms/sms_message_spec.rb +0 -275
  83. data/spec/integration/api/v2010/account/sms_spec.rb +0 -10
@@ -0,0 +1,351 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Chat < Domain
10
+ class V1 < Version
11
+ class ServiceContext < InstanceContext
12
+ class ChannelContext < InstanceContext
13
+ class MemberList < ListResource
14
+ ##
15
+ # Initialize the MemberList
16
+ # @param [Version] version Version that contains the resource
17
+ # @param [String] service_sid The service_sid
18
+ # @param [String] channel_sid The channel_sid
19
+ # @return [MemberList] MemberList
20
+ def initialize(version, service_sid: nil, channel_sid: nil)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {
25
+ service_sid: service_sid,
26
+ channel_sid: channel_sid
27
+ }
28
+ @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:channel_sid]}/Members"
29
+ end
30
+
31
+ ##
32
+ # Retrieve a single page of MemberInstance records from the API.
33
+ # Request is executed immediately.
34
+ # @param [String] identity The identity
35
+ # @param [String] role_sid The role_sid
36
+ # @return [MemberInstance] Newly created MemberInstance
37
+ def create(identity: nil, role_sid: nil)
38
+ data = {
39
+ 'Identity' => identity,
40
+ 'RoleSid' => role_sid,
41
+ }
42
+
43
+ payload = @version.create(
44
+ 'POST',
45
+ @uri,
46
+ data: data
47
+ )
48
+
49
+ return MemberInstance.new(
50
+ @version,
51
+ payload,
52
+ service_sid: @solution[:service_sid],
53
+ channel_sid: @solution[:channel_sid],
54
+ )
55
+ end
56
+
57
+ ##
58
+ # Lists MemberInstance records from the API as a list.
59
+ # Unlike stream(), this operation is eager and will load `limit` records into
60
+ # memory before returning.
61
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
62
+ # guarantees to never return more than limit. Default is no limit
63
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
64
+ # the default value of 50 records. If no page_size is defined
65
+ # but a limit is defined, stream() will attempt to read the
66
+ # limit with the most efficient page size, i.e. min(limit, 1000)
67
+ # @return [Array] Array of up to limit results
68
+ def list(limit: nil, page_size: nil)
69
+ self.stream(
70
+ limit: limit,
71
+ page_size: page_size
72
+ ).entries
73
+ end
74
+
75
+ ##
76
+ # Streams MemberInstance records from the API as an Enumerable.
77
+ # This operation lazily loads records as efficiently as possible until the limit
78
+ # is reached.
79
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
80
+ # guarantees to never return more than limit. Default is no limit
81
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
82
+ # the default value of 50 records. If no page_size is defined
83
+ # but a limit is defined, stream() will attempt to read the
84
+ # limit with the most efficient page size, i.e. min(limit, 1000)
85
+ # @return [Enumerable] Enumerable that will yield up to limit results
86
+ def stream(limit: nil, page_size: nil)
87
+ limits = @version.read_limits(limit, page_size)
88
+
89
+ page = self.page(
90
+ page_size: limits[:page_size],
91
+ )
92
+
93
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
94
+ end
95
+
96
+ ##
97
+ # When passed a block, yields MemberInstance records from the API.
98
+ # This operation lazily loads records as efficiently as possible until the limit
99
+ # is reached.
100
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
101
+ # guarantees to never return more than limit. Default is no limit
102
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
103
+ # the default value of 50 records. If no page_size is defined
104
+ # but a limit is defined, stream() will attempt to read the
105
+ # limit with the most efficient page size, i.e. min(limit, 1000)
106
+ def each
107
+ limits = @version.read_limits
108
+
109
+ page = self.page(
110
+ page_size: limits[:page_size],
111
+ )
112
+
113
+ @version.stream(page,
114
+ limit: limits[:limit],
115
+ page_limit: limits[:page_limit]).each {|x| yield x}
116
+ end
117
+
118
+ ##
119
+ # Retrieve a single page of MemberInstance records from the API.
120
+ # Request is executed immediately.
121
+ # @param [String] page_token PageToken provided by the API
122
+ # @param [Integer] page_number Page Number, this value is simply for client state
123
+ # @param [Integer] page_size Number of records to return, defaults to 50
124
+ # @return [Page] Page of MemberInstance
125
+ def page(page_token: nil, page_number: nil, page_size: nil)
126
+ params = {
127
+ 'PageToken' => page_token,
128
+ 'Page' => page_number,
129
+ 'PageSize' => page_size,
130
+ }
131
+ response = @version.page(
132
+ 'GET',
133
+ @uri,
134
+ params
135
+ )
136
+ return MemberPage.new(@version, response, @solution)
137
+ end
138
+
139
+ ##
140
+ # Provide a user friendly representation
141
+ def to_s
142
+ '#<Twilio.Chat.V1.MemberList>'
143
+ end
144
+ end
145
+
146
+ class MemberPage < Page
147
+ ##
148
+ # Initialize the MemberPage
149
+ # @param [Version] version Version that contains the resource
150
+ # @param [Response] response Response from the API
151
+ # @param [Hash] solution Path solution for the resource
152
+ # @param [String] service_sid The service_sid
153
+ # @param [String] channel_sid The channel_sid
154
+ # @return [MemberPage] MemberPage
155
+ def initialize(version, response, solution)
156
+ super(version, response)
157
+
158
+ # Path Solution
159
+ @solution = solution
160
+ end
161
+
162
+ ##
163
+ # Build an instance of MemberInstance
164
+ # @param [Hash] payload Payload response from the API
165
+ # @return [MemberInstance] MemberInstance
166
+ def get_instance(payload)
167
+ return MemberInstance.new(
168
+ @version,
169
+ payload,
170
+ service_sid: @solution[:service_sid],
171
+ channel_sid: @solution[:channel_sid],
172
+ )
173
+ end
174
+
175
+ ##
176
+ # Provide a user friendly representation
177
+ def to_s
178
+ '<Twilio.Chat.V1.MemberPage>'
179
+ end
180
+ end
181
+
182
+ class MemberContext < InstanceContext
183
+ ##
184
+ # Initialize the MemberContext
185
+ # @param [Version] version Version that contains the resource
186
+ # @param [String] service_sid The service_sid
187
+ # @param [String] channel_sid The channel_sid
188
+ # @param [String] sid The sid
189
+ # @return [MemberContext] MemberContext
190
+ def initialize(version, service_sid, channel_sid, sid)
191
+ super(version)
192
+
193
+ # Path Solution
194
+ @solution = {
195
+ service_sid: service_sid,
196
+ channel_sid: channel_sid,
197
+ sid: sid,
198
+ }
199
+ @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:channel_sid]}/Members/#{@solution[:sid]}"
200
+ end
201
+
202
+ ##
203
+ # Fetch a MemberInstance
204
+ # @return [MemberInstance] Fetched MemberInstance
205
+ def fetch
206
+ params = {}
207
+
208
+ payload = @version.fetch(
209
+ 'GET',
210
+ @uri,
211
+ params,
212
+ )
213
+
214
+ return MemberInstance.new(
215
+ @version,
216
+ payload,
217
+ service_sid: @solution[:service_sid],
218
+ channel_sid: @solution[:channel_sid],
219
+ sid: @solution[:sid],
220
+ )
221
+ end
222
+
223
+ ##
224
+ # Deletes the MemberInstance
225
+ # @return [Boolean] true if delete succeeds, true otherwise
226
+ def delete
227
+ return @version.delete('delete', @uri)
228
+ end
229
+
230
+ ##
231
+ # Provide a user friendly representation
232
+ def to_s
233
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
234
+ "#<Twilio.Chat.V1.MemberContext #{context}>"
235
+ end
236
+ end
237
+
238
+ class MemberInstance < InstanceResource
239
+ ##
240
+ # Initialize the MemberInstance
241
+ # @param [Version] version Version that contains the resource
242
+ # @param [Hash] payload payload that contains response from Twilio
243
+ # @param [String] service_sid The service_sid
244
+ # @param [String] channel_sid The channel_sid
245
+ # @param [String] sid The sid
246
+ # @return [MemberInstance] MemberInstance
247
+ def initialize(version, payload, service_sid: nil, channel_sid: nil, sid: nil)
248
+ super(version)
249
+
250
+ # Marshaled Properties
251
+ @properties = {
252
+ 'sid' => payload['sid'],
253
+ 'account_sid' => payload['account_sid'],
254
+ 'channel_sid' => payload['channel_sid'],
255
+ 'service_sid' => payload['service_sid'],
256
+ 'identity' => payload['identity'],
257
+ 'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
258
+ 'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
259
+ 'role_sid' => payload['role_sid'],
260
+ 'url' => payload['url'],
261
+ }
262
+
263
+ # Context
264
+ @instance_context = nil
265
+ @params = {
266
+ 'service_sid' => service_sid,
267
+ 'channel_sid' => channel_sid,
268
+ 'sid' => sid || @properties['sid'],
269
+ }
270
+ end
271
+
272
+ ##
273
+ # Generate an instance context for the instance, the context is capable of
274
+ # performing various actions. All instance actions are proxied to the context
275
+ # @param [Version] version Version that contains the resource
276
+ # @return [MemberContext] MemberContext for this MemberInstance
277
+ def context
278
+ unless @instance_context
279
+ @instance_context = MemberContext.new(
280
+ @version,
281
+ @params['service_sid'],
282
+ @params['channel_sid'],
283
+ @params['sid'],
284
+ )
285
+ end
286
+ @instance_context
287
+ end
288
+
289
+ def sid
290
+ @properties['sid']
291
+ end
292
+
293
+ def account_sid
294
+ @properties['account_sid']
295
+ end
296
+
297
+ def channel_sid
298
+ @properties['channel_sid']
299
+ end
300
+
301
+ def service_sid
302
+ @properties['service_sid']
303
+ end
304
+
305
+ def identity
306
+ @properties['identity']
307
+ end
308
+
309
+ def date_created
310
+ @properties['date_created']
311
+ end
312
+
313
+ def date_updated
314
+ @properties['date_updated']
315
+ end
316
+
317
+ def role_sid
318
+ @properties['role_sid']
319
+ end
320
+
321
+ def url
322
+ @properties['url']
323
+ end
324
+
325
+ ##
326
+ # Fetch a MemberInstance
327
+ # @return [MemberInstance] Fetched MemberInstance
328
+ def fetch
329
+ context.fetch
330
+ end
331
+
332
+ ##
333
+ # Deletes the MemberInstance
334
+ # @return [Boolean] true if delete succeeds, true otherwise
335
+ def delete
336
+ context.delete
337
+ end
338
+
339
+ ##
340
+ # Provide a user friendly representation
341
+ def to_s
342
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
343
+ "<Twilio.Chat.V1.MemberInstance #{values}>"
344
+ end
345
+ end
346
+ end
347
+ end
348
+ end
349
+ end
350
+ end
351
+ end
@@ -6,45 +6,40 @@
6
6
 
7
7
  module Twilio
8
8
  module REST
9
- class Api < Domain
10
- class V2010 < Version
11
- class AccountContext < InstanceContext
12
- class SmsList < ListResource
13
- class SmsMessageList < ListResource
9
+ class Chat < Domain
10
+ class V1 < Version
11
+ class ServiceContext < InstanceContext
12
+ class ChannelContext < InstanceContext
13
+ class MessageList < ListResource
14
14
  ##
15
- # Initialize the SmsMessageList
15
+ # Initialize the MessageList
16
16
  # @param [Version] version Version that contains the resource
17
- # @param [String] account_sid A 34 character string that uniquely identifies this
18
- # resource.
19
- # @return [SmsMessageList] SmsMessageList
20
- def initialize(version, account_sid: nil)
17
+ # @param [String] service_sid The service_sid
18
+ # @param [String] channel_sid The sid
19
+ # @return [MessageList] MessageList
20
+ def initialize(version, service_sid: nil, channel_sid: nil)
21
21
  super(version)
22
22
 
23
23
  # Path Solution
24
24
  @solution = {
25
- account_sid: account_sid
25
+ service_sid: service_sid,
26
+ channel_sid: channel_sid
26
27
  }
27
- @uri = "/Accounts/#{@solution[:account_sid]}/SMS/Messages.json"
28
+ @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:channel_sid]}/Messages"
28
29
  end
29
30
 
30
31
  ##
31
- # Retrieve a single page of SmsMessageInstance records from the API.
32
+ # Retrieve a single page of MessageInstance records from the API.
32
33
  # Request is executed immediately.
33
- # @param [String] to The to
34
- # @param [String] from The from
35
- # @param [String] status_callback The status_callback
36
- # @param [String] application_sid The application_sid
37
34
  # @param [String] body The body
38
- # @param [String] media_url The media_url
39
- # @return [SmsMessageInstance] Newly created SmsMessageInstance
40
- def create(to: nil, from: nil, status_callback: nil, application_sid: nil, body: nil, media_url: nil)
35
+ # @param [String] from The from
36
+ # @param [String] attributes The attributes
37
+ # @return [MessageInstance] Newly created MessageInstance
38
+ def create(body: nil, from: nil, attributes: nil)
41
39
  data = {
42
- 'To' => to,
43
- 'From' => from,
44
40
  'Body' => body,
45
- 'MediaUrl' => media_url,
46
- 'StatusCallback' => status_callback,
47
- 'ApplicationSid' => application_sid,
41
+ 'From' => from,
42
+ 'Attributes' => attributes,
48
43
  }
49
44
 
50
45
  payload = @version.create(
@@ -53,22 +48,18 @@ module Twilio
53
48
  data: data
54
49
  )
55
50
 
56
- return SmsMessageInstance.new(
51
+ return MessageInstance.new(
57
52
  @version,
58
53
  payload,
59
- account_sid: @solution[:account_sid],
54
+ service_sid: @solution[:service_sid],
55
+ channel_sid: @solution[:channel_sid],
60
56
  )
61
57
  end
62
58
 
63
59
  ##
64
- # Lists SmsMessageInstance records from the API as a list.
60
+ # Lists MessageInstance records from the API as a list.
65
61
  # Unlike stream(), this operation is eager and will load `limit` records into
66
62
  # memory before returning.
67
- # @param [String] to The to
68
- # @param [String] from The from
69
- # @param [Time] date_sent_before The date_sent
70
- # @param [Time] date_sent The date_sent
71
- # @param [Time] date_sent_after: The date_sent
72
63
  # @param [Integer] limit Upper limit for the number of records to return. stream()
73
64
  # guarantees to never return more than limit. Default is no limit
74
65
  # @param [Integer] page_size Number of records to fetch per request, when not set will use
@@ -76,27 +67,17 @@ module Twilio
76
67
  # but a limit is defined, stream() will attempt to read the
77
68
  # limit with the most efficient page size, i.e. min(limit, 1000)
78
69
  # @return [Array] Array of up to limit results
79
- def list(to: nil, from: nil, date_sent_before: nil, date_sent: nil, date_sent_after: nil, limit: nil, page_size: nil)
70
+ def list(limit: nil, page_size: nil)
80
71
  self.stream(
81
- to: to,
82
- from: from,
83
- date_sent_before: date_sent_before,
84
- date_sent: date_sent,
85
- date_sent_after: date_sent_after,
86
72
  limit: limit,
87
73
  page_size: page_size
88
74
  ).entries
89
75
  end
90
76
 
91
77
  ##
92
- # Streams SmsMessageInstance records from the API as an Enumerable.
78
+ # Streams MessageInstance records from the API as an Enumerable.
93
79
  # This operation lazily loads records as efficiently as possible until the limit
94
80
  # is reached.
95
- # @param [String] to The to
96
- # @param [String] from The from
97
- # @param [Time] date_sent_before The date_sent
98
- # @param [Time] date_sent The date_sent
99
- # @param [Time] date_sent_after: The date_sent
100
81
  # @param [Integer] limit Upper limit for the number of records to return. stream()
101
82
  # guarantees to never return more than limit. Default is no limit
102
83
  # @param [Integer] page_size Number of records to fetch per request, when not set will use
@@ -104,15 +85,10 @@ module Twilio
104
85
  # but a limit is defined, stream() will attempt to read the
105
86
  # limit with the most efficient page size, i.e. min(limit, 1000)
106
87
  # @return [Enumerable] Enumerable that will yield up to limit results
107
- def stream(to: nil, from: nil, date_sent_before: nil, date_sent: nil, date_sent_after: nil, limit: nil, page_size: nil)
88
+ def stream(limit: nil, page_size: nil)
108
89
  limits = @version.read_limits(limit, page_size)
109
90
 
110
91
  page = self.page(
111
- to: to,
112
- from: from,
113
- date_sent_before: date_sent_before,
114
- date_sent: date_sent,
115
- date_sent_after: date_sent_after,
116
92
  page_size: limits[:page_size],
117
93
  )
118
94
 
@@ -120,14 +96,9 @@ module Twilio
120
96
  end
121
97
 
122
98
  ##
123
- # When passed a block, yields SmsMessageInstance records from the API.
99
+ # When passed a block, yields MessageInstance records from the API.
124
100
  # This operation lazily loads records as efficiently as possible until the limit
125
101
  # is reached.
126
- # @param [String] to The to
127
- # @param [String] from The from
128
- # @param [Time] date_sent_before The date_sent
129
- # @param [Time] date_sent The date_sent
130
- # @param [Time] date_sent_after: The date_sent
131
102
  # @param [Integer] limit Upper limit for the number of records to return. stream()
132
103
  # guarantees to never return more than limit. Default is no limit
133
104
  # @param [Integer] page_size Number of records to fetch per request, when not set will use
@@ -147,24 +118,14 @@ module Twilio
147
118
  end
148
119
 
149
120
  ##
150
- # Retrieve a single page of SmsMessageInstance records from the API.
121
+ # Retrieve a single page of MessageInstance records from the API.
151
122
  # Request is executed immediately.
152
- # @param [String] to The to
153
- # @param [String] from The from
154
- # @param [Time] date_sent_before The date_sent
155
- # @param [Time] date_sent The date_sent
156
- # @param [Time] date_sent_after: The date_sent
157
123
  # @param [String] page_token PageToken provided by the API
158
124
  # @param [Integer] page_number Page Number, this value is simply for client state
159
125
  # @param [Integer] page_size Number of records to return, defaults to 50
160
- # @return [Page] Page of SmsMessageInstance
161
- def page(to: nil, from: nil, date_sent_before: nil, date_sent: nil, date_sent_after: nil, page_token: nil, page_number: nil, page_size: nil)
126
+ # @return [Page] Page of MessageInstance
127
+ def page(page_token: nil, page_number: nil, page_size: nil)
162
128
  params = {
163
- 'To' => to,
164
- 'From' => from,
165
- 'DateSent<' => Twilio.serialize_iso8601(date_sent_before),
166
- 'DateSent' => Twilio.serialize_iso8601(date_sent),
167
- 'DateSent>' => Twilio.serialize_iso8601(date_sent_after),
168
129
  'PageToken' => page_token,
169
130
  'Page' => page_number,
170
131
  'PageSize' => page_size,
@@ -174,25 +135,25 @@ module Twilio
174
135
  @uri,
175
136
  params
176
137
  )
177
- return SmsMessagePage.new(@version, response, @solution)
138
+ return MessagePage.new(@version, response, @solution)
178
139
  end
179
140
 
180
141
  ##
181
142
  # Provide a user friendly representation
182
143
  def to_s
183
- '#<Twilio.Api.V2010.SmsMessageList>'
144
+ '#<Twilio.Chat.V1.MessageList>'
184
145
  end
185
146
  end
186
147
 
187
- class SmsMessagePage < Page
148
+ class MessagePage < Page
188
149
  ##
189
- # Initialize the SmsMessagePage
150
+ # Initialize the MessagePage
190
151
  # @param [Version] version Version that contains the resource
191
152
  # @param [Response] response Response from the API
192
153
  # @param [Hash] solution Path solution for the resource
193
- # @param [String] account_sid A 34 character string that uniquely identifies this
194
- # resource.
195
- # @return [SmsMessagePage] SmsMessagePage
154
+ # @param [String] service_sid The service_sid
155
+ # @param [String] channel_sid The sid
156
+ # @return [MessagePage] MessagePage
196
157
  def initialize(version, response, solution)
197
158
  super(version, response)
198
159
 
@@ -201,52 +162,48 @@ module Twilio
201
162
  end
202
163
 
203
164
  ##
204
- # Build an instance of SmsMessageInstance
165
+ # Build an instance of MessageInstance
205
166
  # @param [Hash] payload Payload response from the API
206
- # @return [SmsMessageInstance] SmsMessageInstance
167
+ # @return [MessageInstance] MessageInstance
207
168
  def get_instance(payload)
208
- return SmsMessageInstance.new(
169
+ return MessageInstance.new(
209
170
  @version,
210
171
  payload,
211
- account_sid: @solution[:account_sid],
172
+ service_sid: @solution[:service_sid],
173
+ channel_sid: @solution[:channel_sid],
212
174
  )
213
175
  end
214
176
 
215
177
  ##
216
178
  # Provide a user friendly representation
217
179
  def to_s
218
- '<Twilio.Api.V2010.SmsMessagePage>'
180
+ '<Twilio.Chat.V1.MessagePage>'
219
181
  end
220
182
  end
221
183
 
222
- class SmsMessageContext < InstanceContext
184
+ class MessageContext < InstanceContext
223
185
  ##
224
- # Initialize the SmsMessageContext
186
+ # Initialize the MessageContext
225
187
  # @param [Version] version Version that contains the resource
226
- # @param [String] account_sid The account_sid
188
+ # @param [String] service_sid The service_sid
189
+ # @param [String] channel_sid The channel_sid
227
190
  # @param [String] sid The sid
228
- # @return [SmsMessageContext] SmsMessageContext
229
- def initialize(version, account_sid, sid)
191
+ # @return [MessageContext] MessageContext
192
+ def initialize(version, service_sid, channel_sid, sid)
230
193
  super(version)
231
194
 
232
195
  # Path Solution
233
196
  @solution = {
234
- account_sid: account_sid,
197
+ service_sid: service_sid,
198
+ channel_sid: channel_sid,
235
199
  sid: sid,
236
200
  }
237
- @uri = "/Accounts/#{@solution[:account_sid]}/SMS/Messages/#{@solution[:sid]}.json"
238
- end
239
-
240
- ##
241
- # Deletes the SmsMessageInstance
242
- # @return [Boolean] true if delete succeeds, true otherwise
243
- def delete
244
- return @version.delete('delete', @uri)
201
+ @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:channel_sid]}/Messages/#{@solution[:sid]}"
245
202
  end
246
203
 
247
204
  ##
248
- # Fetch a SmsMessageInstance
249
- # @return [SmsMessageInstance] Fetched SmsMessageInstance
205
+ # Fetch a MessageInstance
206
+ # @return [MessageInstance] Fetched MessageInstance
250
207
  def fetch
251
208
  params = {}
252
209
 
@@ -256,21 +213,31 @@ module Twilio
256
213
  params,
257
214
  )
258
215
 
259
- return SmsMessageInstance.new(
216
+ return MessageInstance.new(
260
217
  @version,
261
218
  payload,
262
- account_sid: @solution[:account_sid],
219
+ service_sid: @solution[:service_sid],
220
+ channel_sid: @solution[:channel_sid],
263
221
  sid: @solution[:sid],
264
222
  )
265
223
  end
266
224
 
267
225
  ##
268
- # Update the SmsMessageInstance
226
+ # Deletes the MessageInstance
227
+ # @return [Boolean] true if delete succeeds, true otherwise
228
+ def delete
229
+ return @version.delete('delete', @uri)
230
+ end
231
+
232
+ ##
233
+ # Update the MessageInstance
269
234
  # @param [String] body The body
270
- # @return [SmsMessageInstance] Updated SmsMessageInstance
271
- def update(body: nil)
235
+ # @param [Hash] attributes The attributes
236
+ # @return [MessageInstance] Updated MessageInstance
237
+ def update(body: nil, attributes: nil)
272
238
  data = {
273
239
  'Body' => body,
240
+ 'Attributes' => attributes,
274
241
  }
275
242
 
276
243
  payload = @version.update(
@@ -279,10 +246,11 @@ module Twilio
279
246
  data: data,
280
247
  )
281
248
 
282
- return SmsMessageInstance.new(
249
+ return MessageInstance.new(
283
250
  @version,
284
251
  payload,
285
- account_sid: @solution[:account_sid],
252
+ service_sid: @solution[:service_sid],
253
+ channel_sid: @solution[:channel_sid],
286
254
  sid: @solution[:sid],
287
255
  )
288
256
  end
@@ -291,44 +259,41 @@ module Twilio
291
259
  # Provide a user friendly representation
292
260
  def to_s
293
261
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
294
- "#<Twilio.Api.V2010.SmsMessageContext #{context}>"
262
+ "#<Twilio.Chat.V1.MessageContext #{context}>"
295
263
  end
296
264
  end
297
265
 
298
- class SmsMessageInstance < InstanceResource
266
+ class MessageInstance < InstanceResource
299
267
  ##
300
- # Initialize the SmsMessageInstance
268
+ # Initialize the MessageInstance
301
269
  # @param [Version] version Version that contains the resource
302
270
  # @param [Hash] payload payload that contains response from Twilio
303
- # @param [String] account_sid A 34 character string that uniquely identifies this
304
- # resource.
271
+ # @param [String] service_sid The service_sid
272
+ # @param [String] channel_sid The sid
305
273
  # @param [String] sid The sid
306
- # @return [SmsMessageInstance] SmsMessageInstance
307
- def initialize(version, payload, account_sid: nil, sid: nil)
274
+ # @return [MessageInstance] MessageInstance
275
+ def initialize(version, payload, service_sid: nil, channel_sid: nil, sid: nil)
308
276
  super(version)
309
277
 
310
278
  # Marshaled Properties
311
279
  @properties = {
312
- 'account_sid' => payload['account_sid'],
313
- 'api_version' => payload['api_version'],
314
- 'body' => payload['body'],
315
- 'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
316
- 'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
317
- 'date_sent' => Twilio.deserialize_rfc2822(payload['date_sent']),
318
- 'direction' => payload['direction'],
319
- 'from' => payload['from'],
320
- 'price' => payload['price'].to_f,
321
- 'price_unit' => payload['price_unit'],
322
280
  'sid' => payload['sid'],
323
- 'status' => payload['status'],
281
+ 'account_sid' => payload['account_sid'],
282
+ 'service_sid' => payload['service_sid'],
324
283
  'to' => payload['to'],
325
- 'uri' => payload['uri'],
284
+ 'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
285
+ 'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
286
+ 'was_edited' => payload['was_edited'],
287
+ 'from' => payload['from'],
288
+ 'body' => payload['body'],
289
+ 'url' => payload['url'],
326
290
  }
327
291
 
328
292
  # Context
329
293
  @instance_context = nil
330
294
  @params = {
331
- 'account_sid' => account_sid,
295
+ 'service_sid' => service_sid,
296
+ 'channel_sid' => channel_sid,
332
297
  'sid' => sid || @properties['sid'],
333
298
  }
334
299
  end
@@ -337,28 +302,33 @@ module Twilio
337
302
  # Generate an instance context for the instance, the context is capable of
338
303
  # performing various actions. All instance actions are proxied to the context
339
304
  # @param [Version] version Version that contains the resource
340
- # @return [SmsMessageContext] SmsMessageContext for this SmsMessageInstance
305
+ # @return [MessageContext] MessageContext for this MessageInstance
341
306
  def context
342
307
  unless @instance_context
343
- @instance_context = SmsMessageContext.new(
308
+ @instance_context = MessageContext.new(
344
309
  @version,
345
- @params['account_sid'],
310
+ @params['service_sid'],
311
+ @params['channel_sid'],
346
312
  @params['sid'],
347
313
  )
348
314
  end
349
315
  @instance_context
350
316
  end
351
317
 
318
+ def sid
319
+ @properties['sid']
320
+ end
321
+
352
322
  def account_sid
353
323
  @properties['account_sid']
354
324
  end
355
325
 
356
- def api_version
357
- @properties['api_version']
326
+ def service_sid
327
+ @properties['service_sid']
358
328
  end
359
329
 
360
- def body
361
- @properties['body']
330
+ def to
331
+ @properties['to']
362
332
  end
363
333
 
364
334
  def date_created
@@ -369,63 +339,45 @@ module Twilio
369
339
  @properties['date_updated']
370
340
  end
371
341
 
372
- def date_sent
373
- @properties['date_sent']
374
- end
375
-
376
- def direction
377
- @properties['direction']
342
+ def was_edited
343
+ @properties['was_edited']
378
344
  end
379
345
 
380
346
  def from
381
347
  @properties['from']
382
348
  end
383
349
 
384
- def price
385
- @properties['price']
386
- end
387
-
388
- def price_unit
389
- @properties['price_unit']
390
- end
391
-
392
- def sid
393
- @properties['sid']
394
- end
395
-
396
- def status
397
- @properties['status']
350
+ def body
351
+ @properties['body']
398
352
  end
399
353
 
400
- def to
401
- @properties['to']
354
+ def url
355
+ @properties['url']
402
356
  end
403
357
 
404
- def uri
405
- @properties['uri']
358
+ ##
359
+ # Fetch a MessageInstance
360
+ # @return [MessageInstance] Fetched MessageInstance
361
+ def fetch
362
+ context.fetch
406
363
  end
407
364
 
408
365
  ##
409
- # Deletes the SmsMessageInstance
366
+ # Deletes the MessageInstance
410
367
  # @return [Boolean] true if delete succeeds, true otherwise
411
368
  def delete
412
369
  context.delete
413
370
  end
414
371
 
415
372
  ##
416
- # Fetch a SmsMessageInstance
417
- # @return [SmsMessageInstance] Fetched SmsMessageInstance
418
- def fetch
419
- context.fetch
420
- end
421
-
422
- ##
423
- # Update the SmsMessageInstance
373
+ # Update the MessageInstance
424
374
  # @param [String] body The body
425
- # @return [SmsMessageInstance] Updated SmsMessageInstance
426
- def update(body: nil)
375
+ # @param [Hash] attributes The attributes
376
+ # @return [MessageInstance] Updated MessageInstance
377
+ def update(body: nil, attributes: nil)
427
378
  context.update(
428
379
  body: body,
380
+ attributes: attributes,
429
381
  )
430
382
  end
431
383
 
@@ -433,7 +385,7 @@ module Twilio
433
385
  # Provide a user friendly representation
434
386
  def to_s
435
387
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
436
- "<Twilio.Api.V2010.SmsMessageInstance #{values}>"
388
+ "<Twilio.Chat.V1.MessageInstance #{values}>"
437
389
  end
438
390
  end
439
391
  end