twilio-ruby 5.0.0.rc3 → 5.0.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +9 -0
  3. data/lib/twilio-ruby/rest/client.rb +7 -4
  4. data/lib/twilio-ruby/rest/conversations/v1/conversation/completed.rb +0 -7
  5. data/lib/twilio-ruby/rest/conversations/v1/conversation/in_progress.rb +0 -7
  6. data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel.rb +1 -1
  7. data/lib/twilio-ruby/rest/ip_messaging/v1/service/role.rb +1 -1
  8. data/lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb +1 -1
  9. data/lib/twilio-ruby/rest/ip_messaging/v1/service.rb +1 -1
  10. data/lib/twilio-ruby/rest/notifications/v1/service/binding.rb +440 -0
  11. data/lib/twilio-ruby/rest/notifications/v1/service/notification.rb +217 -0
  12. data/lib/twilio-ruby/rest/notifications/v1/service.rb +478 -0
  13. data/lib/twilio-ruby/rest/notifications/v1.rb +35 -0
  14. data/lib/twilio-ruby/rest/notifications.rb +40 -0
  15. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb +96 -5
  16. data/lib/twilio-ruby/version.rb +1 -1
  17. data/spec/integration/ip_messaging/v1/credential_spec.rb +136 -0
  18. data/spec/integration/ip_messaging/v1/service/channel/member_spec.rb +133 -0
  19. data/spec/integration/ip_messaging/v1/service/channel_spec.rb +171 -1
  20. data/spec/integration/ip_messaging/v1/service/role_spec.rb +167 -1
  21. data/spec/integration/ip_messaging/v1/service/user_spec.rb +151 -1
  22. data/spec/integration/ip_messaging/v1/service_spec.rb +177 -1
  23. data/spec/integration/notifications/v1/service/binding_spec.rb +210 -0
  24. data/spec/integration/notifications/v1/service/notification_spec.rb +57 -0
  25. data/spec/integration/notifications/v1/service_spec.rb +244 -0
  26. metadata +14 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 486d5d886f8cc875362ba4b5e52ecdb877f35e91
4
- data.tar.gz: b65531444aa68c9754213eb0ad58523099a9fc82
3
+ metadata.gz: 86a56e3dcf9678b81d0342449417bb1687c58c30
4
+ data.tar.gz: dd26092bbfe3626d900f6ac2a8bfdcc9aaef7db1
5
5
  SHA512:
6
- metadata.gz: 5540cd5060ad208b4889473622a926aa701b7c079c9d8cfa9285f6971244fb6afc61295d09fb319b8a9e833be996df7cb469078b31006de637fea80554d43d22
7
- data.tar.gz: 1e5d8223a889d0bb9d9f330615c4d6793c296a3ebad19cbef50788a8da5116b9062b73945ace84c0022a32611f5186b1ea64c162d98a56f0655795c36eb4e411
6
+ metadata.gz: bf1a054d9c4d52b33198ab15fc430f6bcf2dd70dbcb83ff294e4dc3ab438787d2d8e6637a1a83014f5794c06a320fea18719de8198da7fc7eade26fca02fe496
7
+ data.tar.gz: d134a0bd236791b400e7b1e26f3dfe6983e7dcb8b2e558f4e90cc15995887093a942f6710a02899ee2a1f55d81d031e3cf9785df3f0470d79342f7a29f067716
data/CHANGES.md CHANGED
@@ -4,6 +4,15 @@ twilio-ruby changelog
4
4
  Version 5.0.0
5
5
  -------------
6
6
 
7
+ Release March 28, 2016
8
+
9
+ - Add notifications.twilio.com subdomain
10
+
11
+ Version 5.0.0
12
+ -------------
13
+
14
+ Release January 29, 2016
15
+
7
16
  - First class paging support
8
17
  - Streaming auto-paging functionality
9
18
  - Separation between strict paging and streaming, with network-efficient defaults
@@ -25,6 +25,7 @@ module Twilio
25
25
  @ip_messaging = nil
26
26
  @lookups = nil
27
27
  @monitor = nil
28
+ @notifications = nil
28
29
  @pricing = nil
29
30
  @taskrouter = nil
30
31
  @trunking = nil
@@ -92,6 +93,12 @@ module Twilio
92
93
  @monitor ||= Monitor.new self
93
94
  end
94
95
 
96
+ ##
97
+ # Access the Notifications Twilio Domain
98
+ def notifications
99
+ @notifications ||= Notifications.new self
100
+ end
101
+
95
102
  ##
96
103
  # Access the Pricing Twilio Domain
97
104
  def pricing
@@ -154,10 +161,6 @@ module Twilio
154
161
  return self.account.messages
155
162
  end
156
163
 
157
- def notifications
158
- return self.account.notifications
159
- end
160
-
161
164
  def outgoing_caller_ids
162
165
  return self.account.outgoing_caller_ids
163
166
  end
@@ -204,13 +204,6 @@ module Twilio
204
204
  @properties['url']
205
205
  end
206
206
 
207
- ##
208
- # Access the participants
209
- # @return [participants] participants
210
- def participants
211
- @context.participants
212
- end
213
-
214
207
  ##
215
208
  # Provide a user friendly representation
216
209
  def to_s
@@ -204,13 +204,6 @@ module Twilio
204
204
  @properties['url']
205
205
  end
206
206
 
207
- ##
208
- # Access the participants
209
- # @return [participants] participants
210
- def participants
211
- @context.participants
212
- end
213
-
214
207
  ##
215
208
  # Provide a user friendly representation
216
209
  def to_s
@@ -244,7 +244,7 @@ module Twilio
244
244
  # Deletes the ChannelInstance
245
245
  # @return [Boolean] true if delete succeeds, true otherwise
246
246
  def delete
247
- return @version.delete('get', @uri)
247
+ return @version.delete('delete', @uri)
248
248
  end
249
249
 
250
250
  ##
@@ -238,7 +238,7 @@ module Twilio
238
238
  # Deletes the RoleInstance
239
239
  # @return [Boolean] true if delete succeeds, true otherwise
240
240
  def delete
241
- return @version.delete('get', @uri)
241
+ return @version.delete('delete', @uri)
242
242
  end
243
243
 
244
244
  ##
@@ -236,7 +236,7 @@ module Twilio
236
236
  # Deletes the UserInstance
237
237
  # @return [Boolean] true if delete succeeds, true otherwise
238
238
  def delete
239
- return @version.delete('get', @uri)
239
+ return @version.delete('delete', @uri)
240
240
  end
241
241
 
242
242
  ##
@@ -228,7 +228,7 @@ module Twilio
228
228
  # Deletes the ServiceInstance
229
229
  # @return [Boolean] true if delete succeeds, true otherwise
230
230
  def delete
231
- return @version.delete('get', @uri)
231
+ return @version.delete('delete', @uri)
232
232
  end
233
233
 
234
234
  ##
@@ -0,0 +1,440 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Notifications < Domain
10
+ class V1 < Version
11
+ class ServiceContext < InstanceContext
12
+ class BindingList < ListResource
13
+ ##
14
+ # Initialize the BindingList
15
+ # @param [Version] version Version that contains the resource
16
+ # @param [String] service_sid The service_sid
17
+
18
+ # @return [BindingList] BindingList
19
+ def initialize(version, service_sid: nil)
20
+ super(version)
21
+
22
+ # Path Solution
23
+ @solution = {
24
+ service_sid: service_sid
25
+ }
26
+ @uri = "/Services/#{@solution[:service_sid]}/Bindings"
27
+ end
28
+
29
+ ##
30
+ # Retrieve a single page of BindingInstance records from the API.
31
+ # Request is executed immediately.
32
+ # @param [String] endpoint The endpoint
33
+ # @param [String] identity The identity
34
+ # @param [binding.BindingType] binding_type The binding_type
35
+ # @param [String] address The address
36
+ # @param [String] tag The tag
37
+ # @param [String] notification_protocol_version The notification_protocol_version
38
+
39
+ # @return [BindingInstance] Newly created BindingInstance
40
+ def create(endpoint: nil, identity: nil, binding_type: nil, address: nil, tag: nil, notification_protocol_version: nil)
41
+ data = {
42
+ 'Endpoint' => endpoint,
43
+ 'Identity' => identity,
44
+ 'BindingType' => binding_type,
45
+ 'Address' => address,
46
+ 'Tag' => tag,
47
+ 'NotificationProtocolVersion' => notification_protocol_version,
48
+ }
49
+
50
+ payload = @version.create(
51
+ 'POST',
52
+ @uri,
53
+ data: data
54
+ )
55
+
56
+ return BindingInstance.new(
57
+ @version,
58
+ payload,
59
+ service_sid: @solution['service_sid'],
60
+ )
61
+ end
62
+
63
+ ##
64
+ # Lists BindingInstance records from the API as a list.
65
+ # Unlike stream(), this operation is eager and will load `limit` records into
66
+ # memory before returning.
67
+ # @param [Time] start_date_before The start_date
68
+ # @param [Time] start_date The start_date
69
+ # @param [Time] start_date_after: The start_date
70
+ # @param [Time] end_date_before The end_date
71
+ # @param [Time] end_date The end_date
72
+ # @param [Time] end_date_after: The end_date
73
+ # @param [String] identity The identity
74
+ # @param [String] tag The tag
75
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
76
+ # guarantees to never return more than limit. Default is no limit
77
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
78
+ # the default value of 50 records. If no page_size is defined
79
+ # but a limit is defined, stream() will attempt to read the
80
+ # limit with the most efficient page size, i.e. min(limit, 1000)
81
+
82
+ # @return [Array] Array of up to limit results
83
+ def list(start_date_before: nil, start_date: nil, start_date_after: nil, end_date_before: nil, end_date: nil, end_date_after: nil, identity: nil, tag: nil, limit: nil, page_size: nil)
84
+ self.stream(
85
+ start_date_before: start_date_before,
86
+ start_date: start_date,
87
+ start_date_after: start_date_after,
88
+ end_date_before: end_date_before,
89
+ end_date: end_date,
90
+ end_date_after: end_date_after,
91
+ identity: identity,
92
+ tag: tag,
93
+ limit: limit,
94
+ page_size: page_size
95
+ ).entries
96
+ end
97
+
98
+ ##
99
+ # Streams BindingInstance records from the API as an Enumerable.
100
+ # This operation lazily loads records as efficiently as possible until the limit
101
+ # is reached.
102
+ # @param [Time] start_date_before The start_date
103
+ # @param [Time] start_date The start_date
104
+ # @param [Time] start_date_after: The start_date
105
+ # @param [Time] end_date_before The end_date
106
+ # @param [Time] end_date The end_date
107
+ # @param [Time] end_date_after: The end_date
108
+ # @param [String] identity The identity
109
+ # @param [String] tag The tag
110
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
111
+ # guarantees to never return more than limit. Default is no limit
112
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
113
+ # the default value of 50 records. If no page_size is defined
114
+ # but a limit is defined, stream() will attempt to read the
115
+ # limit with the most efficient page size, i.e. min(limit, 1000)
116
+
117
+ # @return [Enumerable] Enumerable that will yield up to limit results
118
+ def stream(start_date_before: nil, start_date: nil, start_date_after: nil, end_date_before: nil, end_date: nil, end_date_after: nil, identity: nil, tag: nil, limit: nil, page_size: nil)
119
+ limits = @version.read_limits(limit, page_size)
120
+
121
+ page = self.page(
122
+ start_date_before: start_date_before,
123
+ start_date: start_date,
124
+ start_date_after: start_date_after,
125
+ end_date_before: end_date_before,
126
+ end_date: end_date,
127
+ end_date_after: end_date_after,
128
+ identity: identity,
129
+ tag: tag,
130
+ page_size: limits['page_size'],
131
+ )
132
+
133
+ @version.stream(page, limit: limits['limit'], page_limit: limits['page_limit'])
134
+ end
135
+
136
+ ##
137
+ # When passed a block, yields BindingInstance records from the API.
138
+ # This operation lazily loads records as efficiently as possible until the limit
139
+ # is reached.
140
+ # @param [Time] start_date_before The start_date
141
+ # @param [Time] start_date The start_date
142
+ # @param [Time] start_date_after: The start_date
143
+ # @param [Time] end_date_before The end_date
144
+ # @param [Time] end_date The end_date
145
+ # @param [Time] end_date_after: The end_date
146
+ # @param [String] identity The identity
147
+ # @param [String] tag The tag
148
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
149
+ # guarantees to never return more than limit. Default is no limit
150
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
151
+ # the default value of 50 records. If no page_size is defined
152
+ # but a limit is defined, stream() will attempt to read the
153
+ # limit with the most efficient page size, i.e. min(limit, 1000)
154
+ def each
155
+ limits = @version.read_limits
156
+
157
+ page = self.page(
158
+ page_size: limits['page_size'],
159
+ )
160
+
161
+ @version.stream(page,
162
+ limit: limits['limit'],
163
+ page_limit: limits['page_limit']).each {|x| yield x}
164
+ end
165
+
166
+ ##
167
+ # Retrieve a single page of BindingInstance records from the API.
168
+ # Request is executed immediately.
169
+ # @param [Time] start_date_before The start_date
170
+ # @param [Time] start_date The start_date
171
+ # @param [Time] start_date_after: The start_date
172
+ # @param [Time] end_date_before The end_date
173
+ # @param [Time] end_date The end_date
174
+ # @param [Time] end_date_after: The end_date
175
+ # @param [String] identity The identity
176
+ # @param [String] tag The tag
177
+ # @param [String] page_token PageToken provided by the API
178
+ # @param [Integer] page_number Page Number, this value is simply for client state
179
+ # @param [Integer] page_size Number of records to return, defaults to 50
180
+
181
+ # @return [Page] Page of BindingInstance
182
+ def page(start_date_before: nil, start_date: nil, start_date_after: nil, end_date_before: nil, end_date: nil, end_date_after: nil, identity: nil, tag: nil, page_token: nil, page_number: nil, page_size: nil)
183
+ params = {
184
+ 'StartDate<' => Twilio.serialize_iso8601(start_date_before),
185
+ 'StartDate' => Twilio.serialize_iso8601(start_date),
186
+ 'StartDate>' => Twilio.serialize_iso8601(start_date_after),
187
+ 'EndDate<' => Twilio.serialize_iso8601(end_date_before),
188
+ 'EndDate' => Twilio.serialize_iso8601(end_date),
189
+ 'EndDate>' => Twilio.serialize_iso8601(end_date_after),
190
+ 'Identity' => identity,
191
+ 'Tag' => tag,
192
+ 'PageToken' => page_token,
193
+ 'Page' => page_number,
194
+ 'PageSize' => page_size,
195
+ }
196
+ response = @version.page(
197
+ 'GET',
198
+ @uri,
199
+ params
200
+ )
201
+ return BindingPage.new(@version, response, @solution)
202
+ end
203
+
204
+ ##
205
+ # Constructs a BindingContext
206
+ # @param [String] sid The sid
207
+
208
+ # @return [BindingContext] BindingContext
209
+ def get(sid)
210
+ BindingContext.new(
211
+ @version,
212
+ service_sid: @solution[:service_sid],
213
+ sid: sid,
214
+ )
215
+ end
216
+
217
+ ##
218
+ # Provide a user friendly representation
219
+ def to_s
220
+ '#<Twilio.Notifications.V1.BindingList>'
221
+ end
222
+ end
223
+
224
+ class BindingPage < Page
225
+ ##
226
+ # Initialize the BindingPage
227
+ # @param [Version] version Version that contains the resource
228
+ # @param [Response] response Response from the API
229
+ # @param [Hash] solution Path solution for the resource
230
+ # @param [String] service_sid The service_sid
231
+
232
+ # @return [BindingPage] BindingPage
233
+ def initialize(version, response, solution)
234
+ super(version, response)
235
+
236
+ # Path Solution
237
+ @solution = solution
238
+ end
239
+
240
+ ##
241
+ # Build an instance of BindingInstance
242
+ # @param [Hash] payload Payload response from the API
243
+
244
+ # @return [BindingInstance] BindingInstance
245
+ def get_instance(payload)
246
+ return BindingInstance.new(
247
+ @version,
248
+ payload,
249
+ service_sid: @solution['service_sid'],
250
+ )
251
+ end
252
+
253
+ ##
254
+ # Provide a user friendly representation
255
+ def to_s
256
+ '<Twilio.Notifications.V1.BindingPage>'
257
+ end
258
+ end
259
+
260
+ class BindingContext < InstanceContext
261
+ ##
262
+ # Initialize the BindingContext
263
+ # @param [Version] version Version that contains the resource
264
+ # @param [String] service_sid The service_sid
265
+ # @param [String] sid The sid
266
+
267
+ # @return [BindingContext] BindingContext
268
+ def initialize(version, service_sid, sid)
269
+ super(version)
270
+
271
+ # Path Solution
272
+ @solution = {
273
+ service_sid: service_sid,
274
+ sid: sid,
275
+ }
276
+ @uri = "/Services/#{@solution[:service_sid]}/Bindings/#{@solution[:sid]}"
277
+ end
278
+
279
+ ##
280
+ # Fetch a BindingInstance
281
+ # @return [BindingInstance] Fetched BindingInstance
282
+ def fetch
283
+ params = {}
284
+
285
+ payload = @version.fetch(
286
+ 'GET',
287
+ @uri,
288
+ params,
289
+ )
290
+
291
+ return BindingInstance.new(
292
+ @version,
293
+ payload,
294
+ service_sid: @solution['service_sid'],
295
+ sid: @solution['sid'],
296
+ )
297
+ end
298
+
299
+ ##
300
+ # Deletes the BindingInstance
301
+ # @return [Boolean] true if delete succeeds, true otherwise
302
+ def delete
303
+ return @version.delete('delete', @uri)
304
+ end
305
+
306
+ ##
307
+ # Provide a user friendly representation
308
+ def to_s
309
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
310
+ "#<Twilio.Notifications.V1.BindingContext #{context}>"
311
+ end
312
+ end
313
+
314
+ class BindingInstance < InstanceResource
315
+ ##
316
+ # Initialize the BindingInstance
317
+ # @param [Version] version Version that contains the resource
318
+ # @param [Hash] payload payload that contains response from Twilio
319
+ # @param [String] service_sid The service_sid
320
+ # @param [String] sid The sid
321
+
322
+ # @return [BindingInstance] BindingInstance
323
+ def initialize(version, payload, service_sid: nil, sid: nil)
324
+ super(version)
325
+
326
+ # Marshaled Properties
327
+ @properties = {
328
+ 'sid' => payload['sid'],
329
+ 'account_sid' => payload['account_sid'],
330
+ 'service_sid' => payload['service_sid'],
331
+ 'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
332
+ 'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
333
+ 'notification_protocol_version' => payload['notification_protocol_version'],
334
+ 'endpoint' => payload['endpoint'],
335
+ 'identity' => payload['identity'],
336
+ 'binding_type' => payload['binding_type'],
337
+ 'address' => payload['address'],
338
+ 'tags' => payload['tags'],
339
+ 'url' => payload['url'],
340
+ }
341
+
342
+ # Context
343
+ @instance_context = nil
344
+ @params = {
345
+ 'service_sid' => service_sid,
346
+ 'sid' => sid || @properties['sid'],
347
+ }
348
+ end
349
+
350
+ ##
351
+ # Generate an instance context for the instance, the context is capable of
352
+ # performing various actions. All instance actions are proxied to the context
353
+ # @param [Version] version Version that contains the resource
354
+
355
+ # @return [BindingContext] BindingContext for this BindingInstance
356
+ def context
357
+ unless @instance_context
358
+ @instance_context = BindingContext.new(
359
+ @version,
360
+ @params['service_sid'],
361
+ @params['sid'],
362
+ )
363
+ end
364
+ @instance_context
365
+ end
366
+
367
+ def sid
368
+ @properties['sid']
369
+ end
370
+
371
+ def account_sid
372
+ @properties['account_sid']
373
+ end
374
+
375
+ def service_sid
376
+ @properties['service_sid']
377
+ end
378
+
379
+ def date_created
380
+ @properties['date_created']
381
+ end
382
+
383
+ def date_updated
384
+ @properties['date_updated']
385
+ end
386
+
387
+ def notification_protocol_version
388
+ @properties['notification_protocol_version']
389
+ end
390
+
391
+ def endpoint
392
+ @properties['endpoint']
393
+ end
394
+
395
+ def identity
396
+ @properties['identity']
397
+ end
398
+
399
+ def binding_type
400
+ @properties['binding_type']
401
+ end
402
+
403
+ def address
404
+ @properties['address']
405
+ end
406
+
407
+ def tags
408
+ @properties['tags']
409
+ end
410
+
411
+ def url
412
+ @properties['url']
413
+ end
414
+
415
+ ##
416
+ # Fetch a BindingInstance
417
+ # @return [BindingInstance] Fetched BindingInstance
418
+ def fetch
419
+ @context.fetch()
420
+ end
421
+
422
+ ##
423
+ # Deletes the BindingInstance
424
+ # @return [Boolean] true if delete succeeds, true otherwise
425
+ def delete
426
+ @context.delete()
427
+ end
428
+
429
+ ##
430
+ # Provide a user friendly representation
431
+ def to_s
432
+ context = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
433
+ "<Twilio.Notifications.V1.BindingInstance #{context}>"
434
+ end
435
+ end
436
+ end
437
+ end
438
+ end
439
+ end
440
+ end