twilio-ruby 5.39.3 → 5.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +24 -1
  3. data/CONTRIBUTING.md +2 -2
  4. data/README.md +2 -3
  5. data/lib/twilio-ruby/rest/api/v2010/account/application.rb +6 -4
  6. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/local.rb +3 -3
  7. data/lib/twilio-ruby/rest/client.rb +7 -0
  8. data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +12 -2
  9. data/lib/twilio-ruby/rest/events.rb +54 -0
  10. data/lib/twilio-ruby/rest/events/v1.rb +58 -0
  11. data/lib/twilio-ruby/rest/events/v1/sink.rb +379 -0
  12. data/lib/twilio-ruby/rest/events/v1/sink/sink_test.rb +115 -0
  13. data/lib/twilio-ruby/rest/events/v1/sink/sink_validate.rb +118 -0
  14. data/lib/twilio-ruby/rest/events/v1/subscription.rb +358 -0
  15. data/lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb +322 -0
  16. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +33 -17
  17. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +13 -1
  18. data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +12 -11
  19. data/lib/twilio-ruby/rest/supersim/v1/usage_record.rb +75 -9
  20. data/lib/twilio-ruby/rest/video/v1/room/room_participant/room_participant_subscribe_rule.rb +0 -6
  21. data/lib/twilio-ruby/rest/wireless/v1/sim/data_session.rb +5 -19
  22. data/lib/twilio-ruby/version.rb +1 -1
  23. data/spec/integration/events/v1/sink/sink_test_spec.rb +42 -0
  24. data/spec/integration/events/v1/sink/sink_validate_spec.rb +44 -0
  25. data/spec/integration/events/v1/sink_spec.rb +217 -0
  26. data/spec/integration/events/v1/subscription/subscribed_event_spec.rb +212 -0
  27. data/spec/integration/events/v1/subscription_spec.rb +205 -0
  28. data/spec/integration/supersim/v1/usage_record_spec.rb +463 -18
  29. data/spec/integration/wireless/v1/sim/data_session_spec.rb +2 -2
  30. metadata +19 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 841eb384db83b5c1a3a721c97098684d75d6d5b1ffb859131406d021a4622979
4
- data.tar.gz: 7947f0f1a27572f6fc89029d822b58e91c7f27e60f04382a396677afdad1155c
3
+ metadata.gz: 5e7abb84b47619335c61019756209b28fff163d70e3c47b2483e1fb5193acf43
4
+ data.tar.gz: 46339a7574f145f039d8faf00ee699b943a8c3dc1b4c0b4aa06c2638fef31b4f
5
5
  SHA512:
6
- metadata.gz: b87be38b318fd24a402aaadb4127a34813380889563b77f6b531bcb63d02990f4de2b68fbe10d76bcc1ce6c81889e31922533094efbeb2510b5653b7a52d5453
7
- data.tar.gz: 1a054d5e499e9561aa6549dcf63b93da6890e34e99d0449ad8d61bd3cfbde7f79cc4e4c61e0d58a51a463fe735a708b46b38cd264c7f8f4f1d0d1ce6b5c6bd8b
6
+ metadata.gz: 6391aa993c8ba9fe0b8e79be818dcf9b578096fc081108f9c0a338af5aff977483047f0b1a6561d43516b3c8d0e97539fc082d6a2d1fe83bb5f7693204a23b77
7
+ data.tar.gz: fe0f4f4384558145e22bd74cb8fc3678367b66eb46699f3c602dc2a1d2c8a19d1627531a0aa1a10d761b7e0239a25b4710e17f129b89a235e08a6377aa12c874
data/CHANGES.md CHANGED
@@ -1,6 +1,29 @@
1
1
  twilio-ruby changelog
2
2
  =====================
3
3
 
4
+ [2020-08-19] Version 5.40.0
5
+ ---------------------------
6
+ **Library - Chore**
7
+ - [PR #526](https://github.com/twilio/twilio-ruby/pull/526): update GitHub branch references to use HEAD. Thanks to [@thinkingserious](https://github.com/thinkingserious)!
8
+
9
+ **Conversations**
10
+ - Allow Identity addition to Participants
11
+
12
+ **Events**
13
+ - Sinks API Get all Sinks
14
+
15
+ **Proxy**
16
+ - Clarified usage of FailOnParticipantConflict param as experimental
17
+ - Add FailOnParticipantConflict param to Proxy Session create and Proxy Participant create
18
+
19
+ **Supersim**
20
+ - Add fleet, network, and isoCountryCode to the UsageRecords resource
21
+ - Change sort order of UsageRecords from ascending to descending with respect to start time field, records are now returned newest to oldest
22
+
23
+ **Wireless**
24
+ - Removed `Start` and `End` parameters from the Data Sessions list endpoint. **(breaking change)**
25
+
26
+
4
27
  [2020-08-05] Version 5.39.3
5
28
  ---------------------------
6
29
  **Messaging**
@@ -504,7 +527,7 @@ twilio-ruby changelog
504
527
  **Library**
505
528
  - [PR #481](https://github.com/twilio/twilio-ruby/pull/481): added request validation for urls with and without ports. Thanks to [@eshanholtz](https://github.com/eshanholtz)!
506
529
  - [PR #480](https://github.com/twilio/twilio-ruby/pull/480): Update resources after sorting. Thanks to [@childish-sambino](https://github.com/childish-sambino)!
507
- - [PR #479](https://github.com/twilio/twilio-ruby/pull/479): Auto-deploy via Travis CI upon tagged commit to master. Thanks to [@thinkingserious](https://github.com/thinkingserious)!
530
+ - [PR #479](https://github.com/twilio/twilio-ruby/pull/479): Auto-deploy via Travis CI upon tagged commit to main. Thanks to [@thinkingserious](https://github.com/thinkingserious)!
508
531
 
509
532
  **Api**
510
533
  - Add new usage categories to the public api `sms-messages-carrierfees` and `mms-messages-carrierfees`
@@ -105,7 +105,7 @@ Before you submit your pull request consider the following guidelines:
105
105
  * Make your changes in a new git branch:
106
106
 
107
107
  ```shell
108
- git checkout -b my-fix-branch master
108
+ git checkout -b my-fix-branch main
109
109
  ```
110
110
 
111
111
  * Create your patch, **including appropriate test cases**.
@@ -132,7 +132,7 @@ Before you submit your pull request consider the following guidelines:
132
132
  git push origin my-fix-branch
133
133
  ```
134
134
 
135
- In GitHub, send a pull request to `twilio-ruby:master`.
135
+ In GitHub, send a pull request to `twilio-ruby:main`.
136
136
  If we suggest changes, then:
137
137
 
138
138
  * Make the required updates.
data/README.md CHANGED
@@ -34,13 +34,13 @@ This library supports the following Ruby implementations:
34
34
  To install using [Bundler][bundler] grab the latest stable version:
35
35
 
36
36
  ```ruby
37
- gem 'twilio-ruby', '~> 5.39.3'
37
+ gem 'twilio-ruby', '~> 5.40.0'
38
38
  ```
39
39
 
40
40
  To manually install `twilio-ruby` via [Rubygems][rubygems] simply gem install:
41
41
 
42
42
  ```bash
43
- gem install twilio-ruby -v 5.39.3
43
+ gem install twilio-ruby -v 5.40.0
44
44
  ```
45
45
 
46
46
  To build and install the development branch yourself from the latest source:
@@ -214,7 +214,6 @@ If you've instead found a bug in the library or would like new features added, g
214
214
  [libdocs]: https://www.twilio.com/docs/libraries/ruby
215
215
  [refdocs]: https://twilio.github.io/twilio-ruby
216
216
  [capability]: https://github.com/twilio/twilio-ruby/wiki/JWT-Tokens
217
- [examples]: https://github.com/twilio/twilio-ruby/blob/master/examples
218
217
  [wiki]: https://github.com/twilio/twilio-ruby/wiki
219
218
  [bundler]: https://bundler.io
220
219
  [rubygems]: https://rubygems.org
@@ -278,8 +278,9 @@ module Twilio
278
278
  # occurs while retrieving or executing the TwiML from `sms_url`.
279
279
  # @param [String] sms_fallback_method The HTTP method we should use to call
280
280
  # `sms_fallback_url`. Can be: `GET` or `POST`.
281
- # @param [String] sms_status_callback The URL we should call using a POST method
282
- # to send status information about SMS messages sent by the application.
281
+ # @param [String] sms_status_callback Same as message_status_callback: The URL we
282
+ # should call using a POST method to send status information about SMS messages
283
+ # sent by the application. Deprecated, included for backwards compatibility.
283
284
  # @param [String] message_status_callback The URL we should call using a POST
284
285
  # method to send message status information to your application.
285
286
  # @return [ApplicationInstance] Updated ApplicationInstance
@@ -545,8 +546,9 @@ module Twilio
545
546
  # occurs while retrieving or executing the TwiML from `sms_url`.
546
547
  # @param [String] sms_fallback_method The HTTP method we should use to call
547
548
  # `sms_fallback_url`. Can be: `GET` or `POST`.
548
- # @param [String] sms_status_callback The URL we should call using a POST method
549
- # to send status information about SMS messages sent by the application.
549
+ # @param [String] sms_status_callback Same as message_status_callback: The URL we
550
+ # should call using a POST method to send status information about SMS messages
551
+ # sent by the application. Deprecated, included for backwards compatibility.
550
552
  # @param [String] message_status_callback The URL we should call using a POST
551
553
  # method to send message status information to your application.
552
554
  # @return [ApplicationInstance] Updated ApplicationInstance
@@ -38,7 +38,7 @@ module Twilio
38
38
  # @param [String] contains The pattern on which to match phone numbers. Valid
39
39
  # characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any
40
40
  # single digit. For examples, see [Example
41
- # 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
41
+ # 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-available-local-phone-numbers-by-area-code) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-number-pattern). If specified, this value must have at least two characters.
42
42
  # @param [Boolean] sms_enabled Whether the phone numbers can receive text
43
43
  # messages. Can be: `true` or `false`.
44
44
  # @param [Boolean] mms_enabled Whether the phone numbers can receive MMS messages.
@@ -125,7 +125,7 @@ module Twilio
125
125
  # @param [String] contains The pattern on which to match phone numbers. Valid
126
126
  # characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any
127
127
  # single digit. For examples, see [Example
128
- # 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
128
+ # 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-available-local-phone-numbers-by-area-code) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-number-pattern). If specified, this value must have at least two characters.
129
129
  # @param [Boolean] sms_enabled Whether the phone numbers can receive text
130
130
  # messages. Can be: `true` or `false`.
131
131
  # @param [Boolean] mms_enabled Whether the phone numbers can receive MMS messages.
@@ -228,7 +228,7 @@ module Twilio
228
228
  # @param [String] contains The pattern on which to match phone numbers. Valid
229
229
  # characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any
230
230
  # single digit. For examples, see [Example
231
- # 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.
231
+ # 2](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-available-local-phone-numbers-by-area-code) and [Example 3](https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource?code-sample=code-find-phone-numbers-by-number-pattern). If specified, this value must have at least two characters.
232
232
  # @param [Boolean] sms_enabled Whether the phone numbers can receive text
233
233
  # messages. Can be: `true` or `false`.
234
234
  # @param [Boolean] mms_enabled Whether the phone numbers can receive MMS messages.
@@ -33,6 +33,7 @@ module Twilio
33
33
  @autopilot = nil
34
34
  @chat = nil
35
35
  @conversations = nil
36
+ @events = nil
36
37
  @fax = nil
37
38
  @flex_api = nil
38
39
  @insights = nil
@@ -160,6 +161,12 @@ module Twilio
160
161
  @conversations ||= Conversations.new self
161
162
  end
162
163
 
164
+ ##
165
+ # Access the Events Twilio Domain
166
+ def events
167
+ @events ||= Events.new self
168
+ end
169
+
163
170
  ##
164
171
  # Access the Fax Twilio Domain
165
172
  def fax
@@ -228,10 +228,14 @@ module Twilio
228
228
  # number that the participant is in contact with. 'null' value will remove it.
229
229
  # @param [String] messaging_binding_projected_address The address of the Twilio
230
230
  # phone number that is used in Group MMS. 'null' value will remove it.
231
+ # @param [String] identity A unique string identifier for the conversation
232
+ # participant as [Chat User](https://www.twilio.com/docs/chat/rest/user-resource).
233
+ # This parameter is non-null if (and only if) the participant is using the
234
+ # Programmable Chat SDK to communicate. Limited to 256 characters.
231
235
  # @param [participant.WebhookEnabledType] x_twilio_webhook_enabled The
232
236
  # X-Twilio-Webhook-Enabled HTTP request header
233
237
  # @return [ParticipantInstance] Updated ParticipantInstance
234
- def update(date_created: :unset, date_updated: :unset, attributes: :unset, role_sid: :unset, messaging_binding_proxy_address: :unset, messaging_binding_projected_address: :unset, x_twilio_webhook_enabled: :unset)
238
+ def update(date_created: :unset, date_updated: :unset, attributes: :unset, role_sid: :unset, messaging_binding_proxy_address: :unset, messaging_binding_projected_address: :unset, identity: :unset, x_twilio_webhook_enabled: :unset)
235
239
  data = Twilio::Values.of({
236
240
  'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
237
241
  'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
@@ -239,6 +243,7 @@ module Twilio
239
243
  'RoleSid' => role_sid,
240
244
  'MessagingBinding.ProxyAddress' => messaging_binding_proxy_address,
241
245
  'MessagingBinding.ProjectedAddress' => messaging_binding_projected_address,
246
+ 'Identity' => identity,
242
247
  })
243
248
  headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
244
249
 
@@ -412,10 +417,14 @@ module Twilio
412
417
  # number that the participant is in contact with. 'null' value will remove it.
413
418
  # @param [String] messaging_binding_projected_address The address of the Twilio
414
419
  # phone number that is used in Group MMS. 'null' value will remove it.
420
+ # @param [String] identity A unique string identifier for the conversation
421
+ # participant as [Chat User](https://www.twilio.com/docs/chat/rest/user-resource).
422
+ # This parameter is non-null if (and only if) the participant is using the
423
+ # Programmable Chat SDK to communicate. Limited to 256 characters.
415
424
  # @param [participant.WebhookEnabledType] x_twilio_webhook_enabled The
416
425
  # X-Twilio-Webhook-Enabled HTTP request header
417
426
  # @return [ParticipantInstance] Updated ParticipantInstance
418
- def update(date_created: :unset, date_updated: :unset, attributes: :unset, role_sid: :unset, messaging_binding_proxy_address: :unset, messaging_binding_projected_address: :unset, x_twilio_webhook_enabled: :unset)
427
+ def update(date_created: :unset, date_updated: :unset, attributes: :unset, role_sid: :unset, messaging_binding_proxy_address: :unset, messaging_binding_projected_address: :unset, identity: :unset, x_twilio_webhook_enabled: :unset)
419
428
  context.update(
420
429
  date_created: date_created,
421
430
  date_updated: date_updated,
@@ -423,6 +432,7 @@ module Twilio
423
432
  role_sid: role_sid,
424
433
  messaging_binding_proxy_address: messaging_binding_proxy_address,
425
434
  messaging_binding_projected_address: messaging_binding_projected_address,
435
+ identity: identity,
426
436
  x_twilio_webhook_enabled: x_twilio_webhook_enabled,
427
437
  )
428
438
  end
@@ -0,0 +1,54 @@
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 Events < Domain
12
+ ##
13
+ # Initialize the Events Domain
14
+ def initialize(twilio)
15
+ super
16
+
17
+ @base_url = 'https://events.twilio.com'
18
+ @host = 'events.twilio.com'
19
+ @port = 443
20
+
21
+ # Versions
22
+ @v1 = nil
23
+ end
24
+
25
+ ##
26
+ # Version v1 of events
27
+ def v1
28
+ @v1 ||= V1.new self
29
+ end
30
+
31
+ ##
32
+ # @param [String] sid The sid
33
+ # @return [Twilio::REST::Events::V1::SinkInstance] if sid was passed.
34
+ # @return [Twilio::REST::Events::V1::SinkList]
35
+ def sinks(sid=:unset)
36
+ self.v1.sinks(sid)
37
+ end
38
+
39
+ ##
40
+ # @param [String] sid The sid
41
+ # @return [Twilio::REST::Events::V1::SubscriptionInstance] if sid was passed.
42
+ # @return [Twilio::REST::Events::V1::SubscriptionList]
43
+ def subscriptions(sid=:unset)
44
+ self.v1.subscriptions(sid)
45
+ end
46
+
47
+ ##
48
+ # Provide a user friendly representation
49
+ def to_s
50
+ '#<Twilio::REST::Events>'
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,58 @@
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 Events
12
+ class V1 < Version
13
+ ##
14
+ # Initialize the V1 version of Events
15
+ def initialize(domain)
16
+ super
17
+ @version = 'v1'
18
+ @sinks = nil
19
+ @subscriptions = nil
20
+ end
21
+
22
+ ##
23
+ # @param [String] sid The sid
24
+ # @return [Twilio::REST::Events::V1::SinkContext] if sid was passed.
25
+ # @return [Twilio::REST::Events::V1::SinkList]
26
+ def sinks(sid=:unset)
27
+ if sid.nil?
28
+ raise ArgumentError, 'sid cannot be nil'
29
+ elsif sid == :unset
30
+ @sinks ||= SinkList.new self
31
+ else
32
+ SinkContext.new(self, sid)
33
+ end
34
+ end
35
+
36
+ ##
37
+ # @param [String] sid The sid
38
+ # @return [Twilio::REST::Events::V1::SubscriptionContext] if sid was passed.
39
+ # @return [Twilio::REST::Events::V1::SubscriptionList]
40
+ def subscriptions(sid=:unset)
41
+ if sid.nil?
42
+ raise ArgumentError, 'sid cannot be nil'
43
+ elsif sid == :unset
44
+ @subscriptions ||= SubscriptionList.new self
45
+ else
46
+ SubscriptionContext.new(self, sid)
47
+ end
48
+ end
49
+
50
+ ##
51
+ # Provide a user friendly representation
52
+ def to_s
53
+ '<Twilio::REST::Events::V1>'
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,379 @@
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 Events < Domain
12
+ class V1 < Version
13
+ ##
14
+ # 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.
15
+ class SinkList < ListResource
16
+ ##
17
+ # Initialize the SinkList
18
+ # @param [Version] version Version that contains the resource
19
+ # @return [SinkList] SinkList
20
+ def initialize(version)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {}
25
+ @uri = "/Sinks"
26
+ end
27
+
28
+ ##
29
+ # Create the SinkInstance
30
+ # @param [String] description The description
31
+ # @param [Hash] sink_configuration The sink_configuration
32
+ # @param [sink.SinkType] sink_type The sink_type
33
+ # @return [SinkInstance] Created SinkInstance
34
+ def create(description: nil, sink_configuration: nil, sink_type: nil)
35
+ data = Twilio::Values.of({
36
+ 'Description' => description,
37
+ 'SinkConfiguration' => Twilio.serialize_object(sink_configuration),
38
+ 'SinkType' => sink_type,
39
+ })
40
+
41
+ payload = @version.create('POST', @uri, data: data)
42
+
43
+ SinkInstance.new(@version, payload, )
44
+ end
45
+
46
+ ##
47
+ # Lists SinkInstance records from the API as a list.
48
+ # Unlike stream(), this operation is eager and will load `limit` records into
49
+ # memory before returning.
50
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
51
+ # guarantees to never return more than limit. Default is no limit
52
+ # @param [Integer] page_size Number of records to fetch per request, when
53
+ # not set will use the default value of 50 records. If no page_size is defined
54
+ # but a limit is defined, stream() will attempt to read the limit with the most
55
+ # efficient page size, i.e. min(limit, 1000)
56
+ # @return [Array] Array of up to limit results
57
+ def list(limit: nil, page_size: nil)
58
+ self.stream(limit: limit, page_size: page_size).entries
59
+ end
60
+
61
+ ##
62
+ # Streams SinkInstance records from the API as an Enumerable.
63
+ # This operation lazily loads records as efficiently as possible until the limit
64
+ # is reached.
65
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
66
+ # guarantees to never return more than limit. Default is no limit.
67
+ # @param [Integer] page_size Number of records to fetch per request, when
68
+ # not set will use the default value of 50 records. If no page_size is defined
69
+ # but a limit is defined, stream() will attempt to read the limit with the most
70
+ # efficient page size, i.e. min(limit, 1000)
71
+ # @return [Enumerable] Enumerable that will yield up to limit results
72
+ def stream(limit: nil, page_size: nil)
73
+ limits = @version.read_limits(limit, page_size)
74
+
75
+ page = self.page(page_size: limits[:page_size], )
76
+
77
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
78
+ end
79
+
80
+ ##
81
+ # When passed a block, yields SinkInstance records from the API.
82
+ # This operation lazily loads records as efficiently as possible until the limit
83
+ # is reached.
84
+ def each
85
+ limits = @version.read_limits
86
+
87
+ page = self.page(page_size: limits[:page_size], )
88
+
89
+ @version.stream(page,
90
+ limit: limits[:limit],
91
+ page_limit: limits[:page_limit]).each {|x| yield x}
92
+ end
93
+
94
+ ##
95
+ # Retrieve a single page of SinkInstance records from the API.
96
+ # Request is executed immediately.
97
+ # @param [String] page_token PageToken provided by the API
98
+ # @param [Integer] page_number Page Number, this value is simply for client state
99
+ # @param [Integer] page_size Number of records to return, defaults to 50
100
+ # @return [Page] Page of SinkInstance
101
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
102
+ params = Twilio::Values.of({
103
+ 'PageToken' => page_token,
104
+ 'Page' => page_number,
105
+ 'PageSize' => page_size,
106
+ })
107
+
108
+ response = @version.page('GET', @uri, params: params)
109
+
110
+ SinkPage.new(@version, response, @solution)
111
+ end
112
+
113
+ ##
114
+ # Retrieve a single page of SinkInstance records from the API.
115
+ # Request is executed immediately.
116
+ # @param [String] target_url API-generated URL for the requested results page
117
+ # @return [Page] Page of SinkInstance
118
+ def get_page(target_url)
119
+ response = @version.domain.request(
120
+ 'GET',
121
+ target_url
122
+ )
123
+ SinkPage.new(@version, response, @solution)
124
+ end
125
+
126
+ ##
127
+ # Provide a user friendly representation
128
+ def to_s
129
+ '#<Twilio.Events.V1.SinkList>'
130
+ end
131
+ end
132
+
133
+ ##
134
+ # 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.
135
+ class SinkPage < Page
136
+ ##
137
+ # Initialize the SinkPage
138
+ # @param [Version] version Version that contains the resource
139
+ # @param [Response] response Response from the API
140
+ # @param [Hash] solution Path solution for the resource
141
+ # @return [SinkPage] SinkPage
142
+ def initialize(version, response, solution)
143
+ super(version, response)
144
+
145
+ # Path Solution
146
+ @solution = solution
147
+ end
148
+
149
+ ##
150
+ # Build an instance of SinkInstance
151
+ # @param [Hash] payload Payload response from the API
152
+ # @return [SinkInstance] SinkInstance
153
+ def get_instance(payload)
154
+ SinkInstance.new(@version, payload, )
155
+ end
156
+
157
+ ##
158
+ # Provide a user friendly representation
159
+ def to_s
160
+ '<Twilio.Events.V1.SinkPage>'
161
+ end
162
+ end
163
+
164
+ ##
165
+ # 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.
166
+ class SinkContext < InstanceContext
167
+ ##
168
+ # Initialize the SinkContext
169
+ # @param [Version] version Version that contains the resource
170
+ # @param [String] sid The sid
171
+ # @return [SinkContext] SinkContext
172
+ def initialize(version, sid)
173
+ super(version)
174
+
175
+ # Path Solution
176
+ @solution = {sid: sid, }
177
+ @uri = "/Sinks/#{@solution[:sid]}"
178
+
179
+ # Dependents
180
+ @sink_test = nil
181
+ @sink_validate = nil
182
+ end
183
+
184
+ ##
185
+ # Fetch the SinkInstance
186
+ # @return [SinkInstance] Fetched SinkInstance
187
+ def fetch
188
+ payload = @version.fetch('GET', @uri)
189
+
190
+ SinkInstance.new(@version, payload, sid: @solution[:sid], )
191
+ end
192
+
193
+ ##
194
+ # Delete the SinkInstance
195
+ # @return [Boolean] true if delete succeeds, false otherwise
196
+ def delete
197
+ @version.delete('DELETE', @uri)
198
+ end
199
+
200
+ ##
201
+ # Access the sink_test
202
+ # @return [SinkTestList]
203
+ # @return [SinkTestContext]
204
+ def sink_test
205
+ unless @sink_test
206
+ @sink_test = SinkTestList.new(@version, sid: @solution[:sid], )
207
+ end
208
+
209
+ @sink_test
210
+ end
211
+
212
+ ##
213
+ # Access the sink_validate
214
+ # @return [SinkValidateList]
215
+ # @return [SinkValidateContext]
216
+ def sink_validate
217
+ unless @sink_validate
218
+ @sink_validate = SinkValidateList.new(@version, sid: @solution[:sid], )
219
+ end
220
+
221
+ @sink_validate
222
+ end
223
+
224
+ ##
225
+ # Provide a user friendly representation
226
+ def to_s
227
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
228
+ "#<Twilio.Events.V1.SinkContext #{context}>"
229
+ end
230
+
231
+ ##
232
+ # Provide a detailed, user friendly representation
233
+ def inspect
234
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
235
+ "#<Twilio.Events.V1.SinkContext #{context}>"
236
+ end
237
+ end
238
+
239
+ ##
240
+ # 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.
241
+ class SinkInstance < InstanceResource
242
+ ##
243
+ # Initialize the SinkInstance
244
+ # @param [Version] version Version that contains the resource
245
+ # @param [Hash] payload payload that contains response from Twilio
246
+ # @param [String] sid The sid
247
+ # @return [SinkInstance] SinkInstance
248
+ def initialize(version, payload, sid: nil)
249
+ super(version)
250
+
251
+ # Marshaled Properties
252
+ @properties = {
253
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
254
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
255
+ 'description' => payload['description'],
256
+ 'sid' => payload['sid'],
257
+ 'sink_configuration' => payload['sink_configuration'],
258
+ 'sink_type' => payload['sink_type'],
259
+ 'status' => payload['status'],
260
+ 'url' => payload['url'],
261
+ 'links' => payload['links'],
262
+ }
263
+
264
+ # Context
265
+ @instance_context = nil
266
+ @params = {'sid' => sid || @properties['sid'], }
267
+ end
268
+
269
+ ##
270
+ # Generate an instance context for the instance, the context is capable of
271
+ # performing various actions. All instance actions are proxied to the context
272
+ # @return [SinkContext] SinkContext for this SinkInstance
273
+ def context
274
+ unless @instance_context
275
+ @instance_context = SinkContext.new(@version, @params['sid'], )
276
+ end
277
+ @instance_context
278
+ end
279
+
280
+ ##
281
+ # @return [Time] The date_created
282
+ def date_created
283
+ @properties['date_created']
284
+ end
285
+
286
+ ##
287
+ # @return [Time] The date_updated
288
+ def date_updated
289
+ @properties['date_updated']
290
+ end
291
+
292
+ ##
293
+ # @return [String] The description
294
+ def description
295
+ @properties['description']
296
+ end
297
+
298
+ ##
299
+ # @return [String] The sid
300
+ def sid
301
+ @properties['sid']
302
+ end
303
+
304
+ ##
305
+ # @return [Hash] The sink_configuration
306
+ def sink_configuration
307
+ @properties['sink_configuration']
308
+ end
309
+
310
+ ##
311
+ # @return [sink.SinkType] The sink_type
312
+ def sink_type
313
+ @properties['sink_type']
314
+ end
315
+
316
+ ##
317
+ # @return [sink.Status] The status
318
+ def status
319
+ @properties['status']
320
+ end
321
+
322
+ ##
323
+ # @return [String] The url
324
+ def url
325
+ @properties['url']
326
+ end
327
+
328
+ ##
329
+ # @return [String] The links
330
+ def links
331
+ @properties['links']
332
+ end
333
+
334
+ ##
335
+ # Fetch the SinkInstance
336
+ # @return [SinkInstance] Fetched SinkInstance
337
+ def fetch
338
+ context.fetch
339
+ end
340
+
341
+ ##
342
+ # Delete the SinkInstance
343
+ # @return [Boolean] true if delete succeeds, false otherwise
344
+ def delete
345
+ context.delete
346
+ end
347
+
348
+ ##
349
+ # Access the sink_test
350
+ # @return [sink_test] sink_test
351
+ def sink_test
352
+ context.sink_test
353
+ end
354
+
355
+ ##
356
+ # Access the sink_validate
357
+ # @return [sink_validate] sink_validate
358
+ def sink_validate
359
+ context.sink_validate
360
+ end
361
+
362
+ ##
363
+ # Provide a user friendly representation
364
+ def to_s
365
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
366
+ "<Twilio.Events.V1.SinkInstance #{values}>"
367
+ end
368
+
369
+ ##
370
+ # Provide a detailed, user friendly representation
371
+ def inspect
372
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
373
+ "<Twilio.Events.V1.SinkInstance #{values}>"
374
+ end
375
+ end
376
+ end
377
+ end
378
+ end
379
+ end