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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da03ff24673303701f74d89492c9e1ffdc5a3eff
4
- data.tar.gz: 8e2208f75608386a60ef6d957f1af7a389c59724
3
+ metadata.gz: 6d05526526414e27419dd6cd3dfda926a98919ba
4
+ data.tar.gz: cc907c8f878a4fec508a99a4f8456e3cf428a4e0
5
5
  SHA512:
6
- metadata.gz: 4d911798207c835effcfe4a23c038e4d85669377819af1e1d1f7fdd164d7763dc10e27cc5ae1a79cfed010e3a7b673fab15477735e204e61860ace36e5c92557
7
- data.tar.gz: 2528777637a50ef1de91d598daf557fd5e9dee9d570c85fadcbf827fd2d91f7b403dd69a0f0e3c44627dcbe73d83219b678b7acfe3a56d8e6b95926e0cb501f8
6
+ metadata.gz: 473a3e9c20d96a6f08187d0b4ad68f97b93d8efbe56a2b5e935b11ed7feb3dead667af3b856b7444481b226fe1d305f02d4f15cc695689dd28040532c36d8a65
7
+ data.tar.gz: 990b523d0131b092beef6cfef2b391a97c8c9878459dc4774a8ca5586de38db0f4517df2d61faf15b136e24fd3b0266464cc79eb33a9cd6d23819885620ac39a
data/AUTHORS.md CHANGED
@@ -7,6 +7,7 @@ A huge thanks to all of our contributors:
7
7
  - Adam Ballai
8
8
  - Alexander Murmann & Ryan Spore
9
9
  - Alexandre Payment
10
+ - Andres Jaan Tack
10
11
  - Andrew Benton
11
12
  - Billy Chia
12
13
  - Brian Levine
data/CHANGES.md CHANGED
@@ -1,7 +1,7 @@
1
1
  twilio-ruby changelog
2
2
  =====================
3
3
 
4
- Version 5.0.0-rc9
4
+ Version 5.0.0-rc16
5
5
  -------------
6
6
 
7
7
  Release September 1, 2016
data/README.md CHANGED
@@ -11,13 +11,13 @@ A module for using the Twilio REST API and generating valid [TwiML](http://www.t
11
11
  To install using [Bundler][bundler] grab the latest stable version:
12
12
 
13
13
  ```ruby
14
- gem 'twilio-ruby', '~> 5.0.0.rc16'
14
+ gem 'twilio-ruby', '~> 5.0.0.rc17'
15
15
  ```
16
16
 
17
17
  To manually install `twilio-ruby` via [Rubygems][rubygems] simply gem install:
18
18
 
19
19
  ```bash
20
- gem install twilio-ruby -v 5.0.0.rc16
20
+ gem install twilio-ruby -v 5.0.0.rc17
21
21
  ```
22
22
 
23
23
  To build and install the development branch yourself from the latest source:
@@ -140,6 +140,28 @@ module Twilio
140
140
  end
141
141
  end
142
142
 
143
+ class SyncGrant
144
+ attr_accessor :service_sid,
145
+ :endpoint_id
146
+
147
+ def key
148
+ 'data_sync'
149
+
150
+ end
151
+
152
+ def payload
153
+ payload = {}
154
+
155
+ if service_sid
156
+ payload['service_sid'] = service_sid
157
+ end
158
+ if endpoint_id
159
+ payload['endpoint_id'] = endpoint_id
160
+ end
161
+
162
+ payload
163
+ end
164
+ end
143
165
  end
144
166
  end
145
- end
167
+ end
@@ -112,8 +112,8 @@ module Twilio
112
112
  self.account.sip()
113
113
  end
114
114
 
115
- def sms
116
- self.account.sms()
115
+ def short_codes(sid=:unset)
116
+ self.account.short_codes(sid)
117
117
  end
118
118
 
119
119
  def tokens
@@ -113,8 +113,8 @@ module Twilio
113
113
  self.account.sip()
114
114
  end
115
115
 
116
- def sms
117
- self.account.sms()
116
+ def short_codes(sid=:unset)
117
+ self.account.short_codes(sid)
118
118
  end
119
119
 
120
120
  def tokens
@@ -219,7 +219,7 @@ module Twilio
219
219
  @sandbox = nil
220
220
  @signing_keys = nil
221
221
  @sip = nil
222
- @sms = nil
222
+ @short_codes = nil
223
223
  @tokens = nil
224
224
  @transcriptions = nil
225
225
  @usage = nil
@@ -654,17 +654,25 @@ module Twilio
654
654
  end
655
655
 
656
656
  ##
657
- # Access the sms
658
- # @return [SmsList] SmsList
659
- def sms
660
- unless @sms
661
- @sms = SmsList.new(
657
+ # Access the short_codes
658
+ # @return [ShortCodeList] ShortCodeList
659
+ def short_codes(sid=:unset)
660
+ if sid != :unset
661
+ return ShortCodeContext.new(
662
+ @version,
663
+ @solution[:sid],
664
+ sid,
665
+ )
666
+ end
667
+
668
+ unless @short_codes
669
+ @short_codes = ShortCodeList.new(
662
670
  @version,
663
671
  account_sid: @solution[:sid],
664
672
  )
665
673
  end
666
674
 
667
- @sms
675
+ @short_codes
668
676
  end
669
677
 
670
678
  ##
@@ -981,10 +989,10 @@ module Twilio
981
989
  end
982
990
 
983
991
  ##
984
- # Access the sms
985
- # @return [sms] sms
986
- def sms
987
- context.sms
992
+ # Access the short_codes
993
+ # @return [short_codes] short_codes
994
+ def short_codes
995
+ context.short_codes
988
996
  end
989
997
 
990
998
  ##
@@ -35,6 +35,7 @@ module Twilio
35
35
  # Unlike stream(), this operation is eager and will load `limit` records into
36
36
  # memory before returning.
37
37
  # @param [Boolean] muted Only show participants that are muted or unmuted
38
+ # @param [Boolean] hold The hold
38
39
  # @param [Integer] limit Upper limit for the number of records to return. stream()
39
40
  # guarantees to never return more than limit. Default is no limit
40
41
  # @param [Integer] page_size Number of records to fetch per request, when not set will use
@@ -42,9 +43,10 @@ module Twilio
42
43
  # but a limit is defined, stream() will attempt to read the
43
44
  # limit with the most efficient page size, i.e. min(limit, 1000)
44
45
  # @return [Array] Array of up to limit results
45
- def list(muted: nil, limit: nil, page_size: nil)
46
+ def list(muted: nil, hold: nil, limit: nil, page_size: nil)
46
47
  self.stream(
47
48
  muted: muted,
49
+ hold: hold,
48
50
  limit: limit,
49
51
  page_size: page_size
50
52
  ).entries
@@ -55,6 +57,7 @@ module Twilio
55
57
  # This operation lazily loads records as efficiently as possible until the limit
56
58
  # is reached.
57
59
  # @param [Boolean] muted Only show participants that are muted or unmuted
60
+ # @param [Boolean] hold The hold
58
61
  # @param [Integer] limit Upper limit for the number of records to return. stream()
59
62
  # guarantees to never return more than limit. Default is no limit
60
63
  # @param [Integer] page_size Number of records to fetch per request, when not set will use
@@ -62,11 +65,12 @@ module Twilio
62
65
  # but a limit is defined, stream() will attempt to read the
63
66
  # limit with the most efficient page size, i.e. min(limit, 1000)
64
67
  # @return [Enumerable] Enumerable that will yield up to limit results
65
- def stream(muted: nil, limit: nil, page_size: nil)
68
+ def stream(muted: nil, hold: nil, limit: nil, page_size: nil)
66
69
  limits = @version.read_limits(limit, page_size)
67
70
 
68
71
  page = self.page(
69
72
  muted: muted,
73
+ hold: hold,
70
74
  page_size: limits[:page_size],
71
75
  )
72
76
 
@@ -78,6 +82,7 @@ module Twilio
78
82
  # This operation lazily loads records as efficiently as possible until the limit
79
83
  # is reached.
80
84
  # @param [Boolean] muted Only show participants that are muted or unmuted
85
+ # @param [Boolean] hold The hold
81
86
  # @param [Integer] limit Upper limit for the number of records to return. stream()
82
87
  # guarantees to never return more than limit. Default is no limit
83
88
  # @param [Integer] page_size Number of records to fetch per request, when not set will use
@@ -100,13 +105,15 @@ module Twilio
100
105
  # Retrieve a single page of ParticipantInstance records from the API.
101
106
  # Request is executed immediately.
102
107
  # @param [Boolean] muted Only show participants that are muted or unmuted
108
+ # @param [Boolean] hold The hold
103
109
  # @param [String] page_token PageToken provided by the API
104
110
  # @param [Integer] page_number Page Number, this value is simply for client state
105
111
  # @param [Integer] page_size Number of records to return, defaults to 50
106
112
  # @return [Page] Page of ParticipantInstance
107
- def page(muted: nil, page_token: nil, page_number: nil, page_size: nil)
113
+ def page(muted: nil, hold: nil, page_token: nil, page_number: nil, page_size: nil)
108
114
  params = {
109
115
  'Muted' => muted,
116
+ 'Hold' => hold,
110
117
  'PageToken' => page_token,
111
118
  'Page' => page_number,
112
119
  'PageSize' => page_size,
@@ -209,10 +216,16 @@ module Twilio
209
216
  ##
210
217
  # Update the ParticipantInstance
211
218
  # @param [Boolean] muted Indicates if the participant should be muted
219
+ # @param [Boolean] hold The hold
220
+ # @param [String] hold_url The hold_url
221
+ # @param [String] hold_method The hold_method
212
222
  # @return [ParticipantInstance] Updated ParticipantInstance
213
- def update(muted: nil)
223
+ def update(muted: nil, hold: nil, hold_url: nil, hold_method: nil)
214
224
  data = {
215
225
  'Muted' => muted,
226
+ 'Hold' => hold,
227
+ 'HoldUrl' => hold_url,
228
+ 'HoldMethod' => hold_method,
216
229
  }
217
230
 
218
231
  payload = @version.update(
@@ -268,6 +281,7 @@ module Twilio
268
281
  'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
269
282
  'end_conference_on_exit' => payload['end_conference_on_exit'],
270
283
  'muted' => payload['muted'],
284
+ 'hold' => payload['hold'],
271
285
  'start_conference_on_enter' => payload['start_conference_on_enter'],
272
286
  'uri' => payload['uri'],
273
287
  }
@@ -326,6 +340,10 @@ module Twilio
326
340
  @properties['muted']
327
341
  end
328
342
 
343
+ def hold
344
+ @properties['hold']
345
+ end
346
+
329
347
  def start_conference_on_enter
330
348
  @properties['start_conference_on_enter']
331
349
  end
@@ -344,10 +362,16 @@ module Twilio
344
362
  ##
345
363
  # Update the ParticipantInstance
346
364
  # @param [Boolean] muted Indicates if the participant should be muted
365
+ # @param [Boolean] hold The hold
366
+ # @param [String] hold_url The hold_url
367
+ # @param [String] hold_method The hold_method
347
368
  # @return [ParticipantInstance] Updated ParticipantInstance
348
- def update(muted: nil)
369
+ def update(muted: nil, hold: nil, hold_url: nil, hold_method: nil)
349
370
  context.update(
350
371
  muted: muted,
372
+ hold: hold,
373
+ hold_url: hold_url,
374
+ hold_method: hold_method,
351
375
  )
352
376
  end
353
377
 
@@ -37,19 +37,19 @@ module Twilio
37
37
  # Application
38
38
  # @param [String] max_price The max_price
39
39
  # @param [Boolean] provide_feedback The provide_feedback
40
- # @param [String] body The body
41
- # @param [String] media_url The media_url
42
40
  # @param [String] from A Twilio phone number or alphanumeric sender ID enabled for
43
41
  # the type of message you wish to send.
44
42
  # @param [String] messaging_service_sid The messaging_service_sid
43
+ # @param [String] body The body
44
+ # @param [String] media_url The media_url
45
45
  # @return [MessageInstance] Newly created MessageInstance
46
- def create(to: nil, status_callback: nil, application_sid: nil, max_price: nil, provide_feedback: nil, body: nil, media_url: nil, from: nil, messaging_service_sid: nil)
46
+ def create(to: nil, status_callback: nil, application_sid: nil, max_price: nil, provide_feedback: nil, from: nil, messaging_service_sid: nil, body: nil, media_url: nil)
47
47
  data = {
48
48
  'To' => to,
49
- 'Body' => body,
50
- 'MediaUrl' => media_url,
51
49
  'From' => from,
52
50
  'MessagingServiceSid' => messaging_service_sid,
51
+ 'Body' => body,
52
+ 'MediaUrl' => media_url,
53
53
  'StatusCallback' => status_callback,
54
54
  'ApplicationSid' => application_sid,
55
55
  'MaxPrice' => max_price,
@@ -272,6 +272,11 @@ module Twilio
272
272
  'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
273
273
  'duration' => payload['duration'],
274
274
  'sid' => payload['sid'],
275
+ 'price' => payload['price'],
276
+ 'price_unit' => payload['price_unit'],
277
+ 'status' => payload['status'],
278
+ 'channels' => payload['channels'].to_i,
279
+ 'source' => payload['source'],
275
280
  'uri' => payload['uri'],
276
281
  }
277
282
 
@@ -327,6 +332,26 @@ module Twilio
327
332
  @properties['sid']
328
333
  end
329
334
 
335
+ def price
336
+ @properties['price']
337
+ end
338
+
339
+ def price_unit
340
+ @properties['price_unit']
341
+ end
342
+
343
+ def status
344
+ @properties['status']
345
+ end
346
+
347
+ def channels
348
+ @properties['channels']
349
+ end
350
+
351
+ def source
352
+ @properties['source']
353
+ end
354
+
330
355
  def uri
331
356
  @properties['uri']
332
357
  end
@@ -0,0 +1,406 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Api < Domain
10
+ class V2010 < Version
11
+ class AccountContext < InstanceContext
12
+ class ShortCodeList < ListResource
13
+ ##
14
+ # Initialize the ShortCodeList
15
+ # @param [Version] version Version that contains the resource
16
+ # @param [String] account_sid The unique id of the Account that owns this short
17
+ # code.
18
+ # @return [ShortCodeList] ShortCodeList
19
+ def initialize(version, account_sid: nil)
20
+ super(version)
21
+
22
+ # Path Solution
23
+ @solution = {
24
+ account_sid: account_sid
25
+ }
26
+ @uri = "/Accounts/#{@solution[:account_sid]}/SMS/ShortCodes.json"
27
+ end
28
+
29
+ ##
30
+ # Lists ShortCodeInstance records from the API as a list.
31
+ # Unlike stream(), this operation is eager and will load `limit` records into
32
+ # memory before returning.
33
+ # @param [String] friendly_name Only show the ShortCode resources with friendly
34
+ # names that exactly match this name
35
+ # @param [String] short_code Only show the ShortCode resources that match this
36
+ # pattern. You can specify partial numbers and use '*' as a wildcard for any digit
37
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
38
+ # guarantees to never return more than limit. Default is no limit
39
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
40
+ # the default value of 50 records. If no page_size is defined
41
+ # but a limit is defined, stream() will attempt to read the
42
+ # limit with the most efficient page size, i.e. min(limit, 1000)
43
+ # @return [Array] Array of up to limit results
44
+ def list(friendly_name: nil, short_code: nil, limit: nil, page_size: nil)
45
+ self.stream(
46
+ friendly_name: friendly_name,
47
+ short_code: short_code,
48
+ limit: limit,
49
+ page_size: page_size
50
+ ).entries
51
+ end
52
+
53
+ ##
54
+ # Streams ShortCodeInstance records from the API as an Enumerable.
55
+ # This operation lazily loads records as efficiently as possible until the limit
56
+ # is reached.
57
+ # @param [String] friendly_name Only show the ShortCode resources with friendly
58
+ # names that exactly match this name
59
+ # @param [String] short_code Only show the ShortCode resources that match this
60
+ # pattern. You can specify partial numbers and use '*' as a wildcard for any digit
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 [Enumerable] Enumerable that will yield up to limit results
68
+ def stream(friendly_name: nil, short_code: nil, limit: nil, page_size: nil)
69
+ limits = @version.read_limits(limit, page_size)
70
+
71
+ page = self.page(
72
+ friendly_name: friendly_name,
73
+ short_code: short_code,
74
+ page_size: limits[:page_size],
75
+ )
76
+
77
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
78
+ end
79
+
80
+ ##
81
+ # When passed a block, yields ShortCodeInstance records from the API.
82
+ # This operation lazily loads records as efficiently as possible until the limit
83
+ # is reached.
84
+ # @param [String] friendly_name Only show the ShortCode resources with friendly
85
+ # names that exactly match this name
86
+ # @param [String] short_code Only show the ShortCode resources that match this
87
+ # pattern. You can specify partial numbers and use '*' as a wildcard for any digit
88
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
89
+ # guarantees to never return more than limit. Default is no limit
90
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
91
+ # the default value of 50 records. If no page_size is defined
92
+ # but a limit is defined, stream() will attempt to read the
93
+ # limit with the most efficient page size, i.e. min(limit, 1000)
94
+ def each
95
+ limits = @version.read_limits
96
+
97
+ page = self.page(
98
+ page_size: limits[:page_size],
99
+ )
100
+
101
+ @version.stream(page,
102
+ limit: limits[:limit],
103
+ page_limit: limits[:page_limit]).each {|x| yield x}
104
+ end
105
+
106
+ ##
107
+ # Retrieve a single page of ShortCodeInstance records from the API.
108
+ # Request is executed immediately.
109
+ # @param [String] friendly_name Only show the ShortCode resources with friendly
110
+ # names that exactly match this name
111
+ # @param [String] short_code Only show the ShortCode resources that match this
112
+ # pattern. You can specify partial numbers and use '*' as a wildcard for any digit
113
+ # @param [String] page_token PageToken provided by the API
114
+ # @param [Integer] page_number Page Number, this value is simply for client state
115
+ # @param [Integer] page_size Number of records to return, defaults to 50
116
+ # @return [Page] Page of ShortCodeInstance
117
+ def page(friendly_name: nil, short_code: nil, page_token: nil, page_number: nil, page_size: nil)
118
+ params = {
119
+ 'FriendlyName' => friendly_name,
120
+ 'ShortCode' => short_code,
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.Api.V2010.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] account_sid The unique id of the Account that owns this short
147
+ # code.
148
+ # @return [ShortCodePage] ShortCodePage
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 ShortCodeInstance
158
+ # @param [Hash] payload Payload response from the API
159
+ # @return [ShortCodeInstance] ShortCodeInstance
160
+ def get_instance(payload)
161
+ return ShortCodeInstance.new(
162
+ @version,
163
+ payload,
164
+ account_sid: @solution[:account_sid],
165
+ )
166
+ end
167
+
168
+ ##
169
+ # Provide a user friendly representation
170
+ def to_s
171
+ '<Twilio.Api.V2010.ShortCodePage>'
172
+ end
173
+ end
174
+
175
+ class ShortCodeContext < InstanceContext
176
+ ##
177
+ # Initialize the ShortCodeContext
178
+ # @param [Version] version Version that contains the resource
179
+ # @param [String] account_sid The account_sid
180
+ # @param [String] sid The short-code Sid that uniquely identifies this resource
181
+ # @return [ShortCodeContext] ShortCodeContext
182
+ def initialize(version, account_sid, sid)
183
+ super(version)
184
+
185
+ # Path Solution
186
+ @solution = {
187
+ account_sid: account_sid,
188
+ sid: sid,
189
+ }
190
+ @uri = "/Accounts/#{@solution[:account_sid]}/SMS/ShortCodes/#{@solution[:sid]}.json"
191
+ end
192
+
193
+ ##
194
+ # Fetch a ShortCodeInstance
195
+ # @return [ShortCodeInstance] Fetched ShortCodeInstance
196
+ def fetch
197
+ params = {}
198
+
199
+ payload = @version.fetch(
200
+ 'GET',
201
+ @uri,
202
+ params,
203
+ )
204
+
205
+ return ShortCodeInstance.new(
206
+ @version,
207
+ payload,
208
+ account_sid: @solution[:account_sid],
209
+ sid: @solution[:sid],
210
+ )
211
+ end
212
+
213
+ ##
214
+ # Update the ShortCodeInstance
215
+ # @param [String] friendly_name A human readable descriptive text for this
216
+ # resource, up to 64 characters long. By default, the `FriendlyName` is just the
217
+ # short code.
218
+ # @param [String] api_version SMSs to this short code will start a new TwiML
219
+ # session with this API version.
220
+ # @param [String] sms_url The URL Twilio will request when receiving an incoming
221
+ # SMS message to this short code.
222
+ # @param [String] sms_method The HTTP method Twilio will use when making requests
223
+ # to the `SmsUrl`. Either `GET` or `POST`.
224
+ # @param [String] sms_fallback_url The URL that Twilio will request if an error
225
+ # occurs retrieving or executing the TwiML from `SmsUrl`.
226
+ # @param [String] sms_fallback_method The HTTP method Twilio will use when
227
+ # requesting the above URL. Either `GET` or `POST`.
228
+ # @return [ShortCodeInstance] Updated ShortCodeInstance
229
+ def update(friendly_name: nil, api_version: nil, sms_url: nil, sms_method: nil, sms_fallback_url: nil, sms_fallback_method: nil)
230
+ data = {
231
+ 'FriendlyName' => friendly_name,
232
+ 'ApiVersion' => api_version,
233
+ 'SmsUrl' => sms_url,
234
+ 'SmsMethod' => sms_method,
235
+ 'SmsFallbackUrl' => sms_fallback_url,
236
+ 'SmsFallbackMethod' => sms_fallback_method,
237
+ }
238
+
239
+ payload = @version.update(
240
+ 'POST',
241
+ @uri,
242
+ data: data,
243
+ )
244
+
245
+ return ShortCodeInstance.new(
246
+ @version,
247
+ payload,
248
+ account_sid: @solution[:account_sid],
249
+ sid: @solution[:sid],
250
+ )
251
+ end
252
+
253
+ ##
254
+ # Provide a user friendly representation
255
+ def to_s
256
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
257
+ "#<Twilio.Api.V2010.ShortCodeContext #{context}>"
258
+ end
259
+ end
260
+
261
+ class ShortCodeInstance < InstanceResource
262
+ ##
263
+ # Initialize the ShortCodeInstance
264
+ # @param [Version] version Version that contains the resource
265
+ # @param [Hash] payload payload that contains response from Twilio
266
+ # @param [String] account_sid The unique id of the Account that owns this short
267
+ # code.
268
+ # @param [String] sid The short-code Sid that uniquely identifies this resource
269
+ # @return [ShortCodeInstance] ShortCodeInstance
270
+ def initialize(version, payload, account_sid: nil, sid: nil)
271
+ super(version)
272
+
273
+ # Marshaled Properties
274
+ @properties = {
275
+ 'account_sid' => payload['account_sid'],
276
+ 'api_version' => payload['api_version'],
277
+ 'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
278
+ 'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
279
+ 'friendly_name' => payload['friendly_name'],
280
+ 'short_code' => payload['short_code'],
281
+ 'sid' => payload['sid'],
282
+ 'sms_fallback_method' => payload['sms_fallback_method'],
283
+ 'sms_fallback_url' => payload['sms_fallback_url'],
284
+ 'sms_method' => payload['sms_method'],
285
+ 'sms_url' => payload['sms_url'],
286
+ 'uri' => payload['uri'],
287
+ }
288
+
289
+ # Context
290
+ @instance_context = nil
291
+ @params = {
292
+ 'account_sid' => account_sid,
293
+ 'sid' => sid || @properties['sid'],
294
+ }
295
+ end
296
+
297
+ ##
298
+ # Generate an instance context for the instance, the context is capable of
299
+ # performing various actions. All instance actions are proxied to the context
300
+ # @param [Version] version Version that contains the resource
301
+ # @return [ShortCodeContext] ShortCodeContext for this ShortCodeInstance
302
+ def context
303
+ unless @instance_context
304
+ @instance_context = ShortCodeContext.new(
305
+ @version,
306
+ @params['account_sid'],
307
+ @params['sid'],
308
+ )
309
+ end
310
+ @instance_context
311
+ end
312
+
313
+ def account_sid
314
+ @properties['account_sid']
315
+ end
316
+
317
+ def api_version
318
+ @properties['api_version']
319
+ end
320
+
321
+ def date_created
322
+ @properties['date_created']
323
+ end
324
+
325
+ def date_updated
326
+ @properties['date_updated']
327
+ end
328
+
329
+ def friendly_name
330
+ @properties['friendly_name']
331
+ end
332
+
333
+ def short_code
334
+ @properties['short_code']
335
+ end
336
+
337
+ def sid
338
+ @properties['sid']
339
+ end
340
+
341
+ def sms_fallback_method
342
+ @properties['sms_fallback_method']
343
+ end
344
+
345
+ def sms_fallback_url
346
+ @properties['sms_fallback_url']
347
+ end
348
+
349
+ def sms_method
350
+ @properties['sms_method']
351
+ end
352
+
353
+ def sms_url
354
+ @properties['sms_url']
355
+ end
356
+
357
+ def uri
358
+ @properties['uri']
359
+ end
360
+
361
+ ##
362
+ # Fetch a ShortCodeInstance
363
+ # @return [ShortCodeInstance] Fetched ShortCodeInstance
364
+ def fetch
365
+ context.fetch
366
+ end
367
+
368
+ ##
369
+ # Update the ShortCodeInstance
370
+ # @param [String] friendly_name A human readable descriptive text for this
371
+ # resource, up to 64 characters long. By default, the `FriendlyName` is just the
372
+ # short code.
373
+ # @param [String] api_version SMSs to this short code will start a new TwiML
374
+ # session with this API version.
375
+ # @param [String] sms_url The URL Twilio will request when receiving an incoming
376
+ # SMS message to this short code.
377
+ # @param [String] sms_method The HTTP method Twilio will use when making requests
378
+ # to the `SmsUrl`. Either `GET` or `POST`.
379
+ # @param [String] sms_fallback_url The URL that Twilio will request if an error
380
+ # occurs retrieving or executing the TwiML from `SmsUrl`.
381
+ # @param [String] sms_fallback_method The HTTP method Twilio will use when
382
+ # requesting the above URL. Either `GET` or `POST`.
383
+ # @return [ShortCodeInstance] Updated ShortCodeInstance
384
+ def update(friendly_name: nil, api_version: nil, sms_url: nil, sms_method: nil, sms_fallback_url: nil, sms_fallback_method: nil)
385
+ context.update(
386
+ friendly_name: friendly_name,
387
+ api_version: api_version,
388
+ sms_url: sms_url,
389
+ sms_method: sms_method,
390
+ sms_fallback_url: sms_fallback_url,
391
+ sms_fallback_method: sms_fallback_method,
392
+ )
393
+ end
394
+
395
+ ##
396
+ # Provide a user friendly representation
397
+ def to_s
398
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
399
+ "<Twilio.Api.V2010.ShortCodeInstance #{values}>"
400
+ end
401
+ end
402
+ end
403
+ end
404
+ end
405
+ end
406
+ end