twilio-ruby 5.39.1 → 5.40.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGES.md +101 -1
  4. data/CONTRIBUTING.md +2 -2
  5. data/ISSUE_TEMPLATE.md +5 -1
  6. data/Makefile +1 -1
  7. data/PULL_REQUEST_TEMPLATE.md +1 -1
  8. data/README.md +4 -3
  9. data/lib/twilio-ruby/framework/version.rb +2 -7
  10. data/lib/twilio-ruby/rest/api/v2010/account/application.rb +6 -4
  11. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number/local.rb +3 -3
  12. data/lib/twilio-ruby/rest/api/v2010/account/call/payment.rb +79 -60
  13. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/local.rb +14 -0
  14. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb +14 -0
  15. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/toll_free.rb +14 -0
  16. data/lib/twilio-ruby/rest/client.rb +7 -0
  17. data/lib/twilio-ruby/rest/conversations.rb +52 -0
  18. data/lib/twilio-ruby/rest/conversations/v1.rb +88 -1
  19. data/lib/twilio-ruby/rest/conversations/v1/configuration.rb +258 -0
  20. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +15 -4
  21. data/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb +19 -10
  22. data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +12 -2
  23. data/lib/twilio-ruby/rest/conversations/v1/credential.rb +427 -0
  24. data/lib/twilio-ruby/rest/conversations/v1/notification.rb +310 -0
  25. data/lib/twilio-ruby/rest/conversations/v1/role.rb +372 -0
  26. data/lib/twilio-ruby/rest/conversations/v1/service.rb +442 -0
  27. data/lib/twilio-ruby/rest/conversations/v1/service/binding.rb +385 -0
  28. data/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb +259 -0
  29. data/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb +586 -0
  30. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb +546 -0
  31. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb +388 -0
  32. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb +513 -0
  33. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb +454 -0
  34. data/lib/twilio-ruby/rest/conversations/v1/service/role.rb +393 -0
  35. data/lib/twilio-ruby/rest/conversations/v1/service/user.rb +419 -0
  36. data/lib/twilio-ruby/rest/conversations/v1/user.rb +398 -0
  37. data/lib/twilio-ruby/rest/events.rb +63 -0
  38. data/lib/twilio-ruby/rest/events/v1.rb +74 -0
  39. data/lib/twilio-ruby/rest/events/v1/event_type.rb +291 -0
  40. data/lib/twilio-ruby/rest/events/v1/sink.rb +380 -0
  41. data/lib/twilio-ruby/rest/events/v1/sink/sink_test.rb +115 -0
  42. data/lib/twilio-ruby/rest/events/v1/sink/sink_validate.rb +119 -0
  43. data/lib/twilio-ruby/rest/events/v1/subscription.rb +363 -0
  44. data/lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb +322 -0
  45. data/lib/twilio-ruby/rest/messaging.rb +6 -0
  46. data/lib/twilio-ruby/rest/messaging/v1.rb +7 -0
  47. data/lib/twilio-ruby/rest/messaging/v1/deactivation.rb +164 -0
  48. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance.rb +3 -3
  49. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/end_user.rb +16 -2
  50. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb +18 -4
  51. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +45 -4
  52. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +14 -1
  53. data/lib/twilio-ruby/rest/serverless/v1/service.rb +13 -13
  54. data/lib/twilio-ruby/rest/serverless/v1/service/asset.rb +6 -6
  55. data/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb +5 -5
  56. data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +8 -8
  57. data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +6 -8
  58. data/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb +8 -8
  59. data/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb +14 -14
  60. data/lib/twilio-ruby/rest/serverless/v1/service/function.rb +4 -4
  61. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb +7 -7
  62. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb +1 -1
  63. data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +12 -11
  64. data/lib/twilio-ruby/rest/supersim/v1/sim.rb +39 -9
  65. data/lib/twilio-ruby/rest/supersim/v1/usage_record.rb +75 -9
  66. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +2 -1
  67. data/lib/twilio-ruby/rest/trunking/v1/trunk.rb +25 -3
  68. data/lib/twilio-ruby/rest/verify/v2/service.rb +21 -9
  69. data/lib/twilio-ruby/rest/verify/v2/service/entity/challenge.rb +10 -2
  70. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +4 -1
  71. data/lib/twilio-ruby/rest/video/v1/room/room_participant/room_participant_subscribe_rule.rb +0 -6
  72. data/lib/twilio-ruby/rest/wireless/v1/sim/data_session.rb +5 -19
  73. data/lib/twilio-ruby/version.rb +1 -1
  74. data/spec/framework/version_spec.rb +42 -0
  75. data/spec/holodeck/holodeck.rb +3 -3
  76. data/spec/integration/api/v2010/account/incoming_phone_number/local_spec.rb +35 -36
  77. data/spec/integration/api/v2010/account/incoming_phone_number/mobile_spec.rb +39 -40
  78. data/spec/integration/api/v2010/account/incoming_phone_number/toll_free_spec.rb +35 -36
  79. data/spec/integration/api/v2010/account/incoming_phone_number_spec.rb +25 -23
  80. data/spec/integration/api/v2010/account/message_spec.rb +37 -0
  81. data/spec/integration/bulkexports/v1/export/day_spec.rb +5 -5
  82. data/spec/integration/bulkexports/v1/export_configuration_spec.rb +4 -4
  83. data/spec/integration/bulkexports/v1/export_spec.rb +3 -3
  84. data/spec/integration/conversations/v1/configuration_spec.rb +85 -0
  85. data/spec/integration/conversations/v1/conversation/message/delivery_receipt_spec.rb +4 -0
  86. data/spec/integration/conversations/v1/conversation/message_spec.rb +38 -0
  87. data/spec/integration/conversations/v1/conversation/participant_spec.rb +60 -4
  88. data/spec/integration/conversations/v1/conversation_spec.rb +35 -0
  89. data/spec/integration/conversations/v1/credential_spec.rb +219 -0
  90. data/spec/integration/conversations/v1/notification_spec.rb +107 -0
  91. data/spec/integration/conversations/v1/role_spec.rb +249 -0
  92. data/spec/integration/conversations/v1/service/binding_spec.rb +166 -0
  93. data/spec/integration/conversations/v1/service/configuration_spec.rb +87 -0
  94. data/spec/integration/conversations/v1/service/conversation/message/delivery_receipt_spec.rb +144 -0
  95. data/spec/integration/conversations/v1/service/conversation/message_spec.rb +429 -0
  96. data/spec/integration/conversations/v1/service/conversation/participant_spec.rb +407 -0
  97. data/spec/integration/conversations/v1/service/conversation/webhook_spec.rb +299 -0
  98. data/spec/integration/conversations/v1/service/conversation_spec.rb +289 -0
  99. data/spec/integration/conversations/v1/service/role_spec.rb +260 -0
  100. data/spec/integration/conversations/v1/service/user_spec.rb +230 -0
  101. data/spec/integration/conversations/v1/service_spec.rb +174 -0
  102. data/spec/integration/conversations/v1/user_spec.rb +220 -0
  103. data/spec/integration/events/v1/event_type_spec.rb +133 -0
  104. data/spec/integration/events/v1/sink/sink_test_spec.rb +42 -0
  105. data/spec/integration/events/v1/sink/sink_validate_spec.rb +44 -0
  106. data/spec/integration/events/v1/sink_spec.rb +217 -0
  107. data/spec/integration/events/v1/subscription/subscribed_event_spec.rb +212 -0
  108. data/spec/integration/events/v1/subscription_spec.rb +205 -0
  109. data/spec/integration/messaging/v1/deactivation_spec.rb +40 -0
  110. data/spec/integration/numbers/v2/regulatory_compliance/end_user_spec.rb +27 -0
  111. data/spec/integration/numbers/v2/regulatory_compliance/supporting_document_spec.rb +27 -0
  112. data/spec/integration/studio/v1/flow/execution/execution_step_spec.rb +1 -0
  113. data/spec/integration/studio/v2/flow/execution/execution_step_spec.rb +1 -0
  114. data/spec/integration/supersim/v1/sim_spec.rb +23 -0
  115. data/spec/integration/supersim/v1/usage_record_spec.rb +463 -18
  116. data/spec/integration/trunking/v1/trunk_spec.rb +4 -0
  117. data/spec/integration/verify/v2/service/access_token_spec.rb +1 -1
  118. data/spec/integration/verify/v2/service/entity/challenge_spec.rb +8 -8
  119. data/spec/integration/video/v1/room_spec.rb +37 -0
  120. data/spec/integration/wireless/v1/sim/data_session_spec.rb +2 -2
  121. data/spec/spec_helper.rb +1 -1
  122. metadata +70 -2
@@ -0,0 +1,115 @@
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
+ class SinkContext < InstanceContext
14
+ ##
15
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
16
+ class SinkTestList < ListResource
17
+ ##
18
+ # Initialize the SinkTestList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] sid A 34 character string that uniquely identifies this Sink.
21
+ # @return [SinkTestList] SinkTestList
22
+ def initialize(version, sid: nil)
23
+ super(version)
24
+
25
+ # Path Solution
26
+ @solution = {sid: sid}
27
+ @uri = "/Sinks/#{@solution[:sid]}/Test"
28
+ end
29
+
30
+ ##
31
+ # Create the SinkTestInstance
32
+ # @return [SinkTestInstance] Created SinkTestInstance
33
+ def create
34
+ payload = @version.create('POST', @uri)
35
+
36
+ SinkTestInstance.new(@version, payload, sid: @solution[:sid], )
37
+ end
38
+
39
+ ##
40
+ # Provide a user friendly representation
41
+ def to_s
42
+ '#<Twilio.Events.V1.SinkTestList>'
43
+ end
44
+ end
45
+
46
+ ##
47
+ # 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.
48
+ class SinkTestPage < Page
49
+ ##
50
+ # Initialize the SinkTestPage
51
+ # @param [Version] version Version that contains the resource
52
+ # @param [Response] response Response from the API
53
+ # @param [Hash] solution Path solution for the resource
54
+ # @return [SinkTestPage] SinkTestPage
55
+ def initialize(version, response, solution)
56
+ super(version, response)
57
+
58
+ # Path Solution
59
+ @solution = solution
60
+ end
61
+
62
+ ##
63
+ # Build an instance of SinkTestInstance
64
+ # @param [Hash] payload Payload response from the API
65
+ # @return [SinkTestInstance] SinkTestInstance
66
+ def get_instance(payload)
67
+ SinkTestInstance.new(@version, payload, sid: @solution[:sid], )
68
+ end
69
+
70
+ ##
71
+ # Provide a user friendly representation
72
+ def to_s
73
+ '<Twilio.Events.V1.SinkTestPage>'
74
+ end
75
+ end
76
+
77
+ ##
78
+ # 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.
79
+ class SinkTestInstance < InstanceResource
80
+ ##
81
+ # Initialize the SinkTestInstance
82
+ # @param [Version] version Version that contains the resource
83
+ # @param [Hash] payload payload that contains response from Twilio
84
+ # @param [String] sid A 34 character string that uniquely identifies this Sink.
85
+ # @return [SinkTestInstance] SinkTestInstance
86
+ def initialize(version, payload, sid: nil)
87
+ super(version)
88
+
89
+ # Marshaled Properties
90
+ @properties = {'result' => payload['result'], }
91
+ end
92
+
93
+ ##
94
+ # @return [String] Feedback indicating whether the test event was generated.
95
+ def result
96
+ @properties['result']
97
+ end
98
+
99
+ ##
100
+ # Provide a user friendly representation
101
+ def to_s
102
+ "<Twilio.Events.V1.SinkTestInstance>"
103
+ end
104
+
105
+ ##
106
+ # Provide a detailed, user friendly representation
107
+ def inspect
108
+ "<Twilio.Events.V1.SinkTestInstance>"
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,119 @@
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
+ class SinkContext < InstanceContext
14
+ ##
15
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
16
+ class SinkValidateList < ListResource
17
+ ##
18
+ # Initialize the SinkValidateList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] sid A 34 character string that uniquely identifies this Sink.
21
+ # @return [SinkValidateList] SinkValidateList
22
+ def initialize(version, sid: nil)
23
+ super(version)
24
+
25
+ # Path Solution
26
+ @solution = {sid: sid}
27
+ @uri = "/Sinks/#{@solution[:sid]}/Validate"
28
+ end
29
+
30
+ ##
31
+ # Create the SinkValidateInstance
32
+ # @param [String] test_id A 34 character string that uniquely identifies the test
33
+ # event for a Sink being validated.
34
+ # @return [SinkValidateInstance] Created SinkValidateInstance
35
+ def create(test_id: nil)
36
+ data = Twilio::Values.of({'TestId' => test_id, })
37
+
38
+ payload = @version.create('POST', @uri, data: data)
39
+
40
+ SinkValidateInstance.new(@version, payload, sid: @solution[:sid], )
41
+ end
42
+
43
+ ##
44
+ # Provide a user friendly representation
45
+ def to_s
46
+ '#<Twilio.Events.V1.SinkValidateList>'
47
+ end
48
+ end
49
+
50
+ ##
51
+ # 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.
52
+ class SinkValidatePage < Page
53
+ ##
54
+ # Initialize the SinkValidatePage
55
+ # @param [Version] version Version that contains the resource
56
+ # @param [Response] response Response from the API
57
+ # @param [Hash] solution Path solution for the resource
58
+ # @return [SinkValidatePage] SinkValidatePage
59
+ def initialize(version, response, solution)
60
+ super(version, response)
61
+
62
+ # Path Solution
63
+ @solution = solution
64
+ end
65
+
66
+ ##
67
+ # Build an instance of SinkValidateInstance
68
+ # @param [Hash] payload Payload response from the API
69
+ # @return [SinkValidateInstance] SinkValidateInstance
70
+ def get_instance(payload)
71
+ SinkValidateInstance.new(@version, payload, sid: @solution[:sid], )
72
+ end
73
+
74
+ ##
75
+ # Provide a user friendly representation
76
+ def to_s
77
+ '<Twilio.Events.V1.SinkValidatePage>'
78
+ end
79
+ end
80
+
81
+ ##
82
+ # 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.
83
+ class SinkValidateInstance < InstanceResource
84
+ ##
85
+ # Initialize the SinkValidateInstance
86
+ # @param [Version] version Version that contains the resource
87
+ # @param [Hash] payload payload that contains response from Twilio
88
+ # @param [String] sid A 34 character string that uniquely identifies this Sink.
89
+ # @return [SinkValidateInstance] SinkValidateInstance
90
+ def initialize(version, payload, sid: nil)
91
+ super(version)
92
+
93
+ # Marshaled Properties
94
+ @properties = {'result' => payload['result'], }
95
+ end
96
+
97
+ ##
98
+ # @return [String] Feedback indicating whether the given Sink was validated.
99
+ def result
100
+ @properties['result']
101
+ end
102
+
103
+ ##
104
+ # Provide a user friendly representation
105
+ def to_s
106
+ "<Twilio.Events.V1.SinkValidateInstance>"
107
+ end
108
+
109
+ ##
110
+ # Provide a detailed, user friendly representation
111
+ def inspect
112
+ "<Twilio.Events.V1.SinkValidateInstance>"
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,363 @@
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 SubscriptionList < ListResource
16
+ ##
17
+ # Initialize the SubscriptionList
18
+ # @param [Version] version Version that contains the resource
19
+ # @return [SubscriptionList] SubscriptionList
20
+ def initialize(version)
21
+ super(version)
22
+
23
+ # Path Solution
24
+ @solution = {}
25
+ @uri = "/Subscriptions"
26
+ end
27
+
28
+ ##
29
+ # Lists SubscriptionInstance records from the API as a list.
30
+ # Unlike stream(), this operation is eager and will load `limit` records into
31
+ # memory before returning.
32
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
33
+ # guarantees to never return more than limit. Default is no limit
34
+ # @param [Integer] page_size Number of records to fetch per request, when
35
+ # not set will use the default value of 50 records. If no page_size is defined
36
+ # but a limit is defined, stream() will attempt to read the limit with the most
37
+ # efficient page size, i.e. min(limit, 1000)
38
+ # @return [Array] Array of up to limit results
39
+ def list(limit: nil, page_size: nil)
40
+ self.stream(limit: limit, page_size: page_size).entries
41
+ end
42
+
43
+ ##
44
+ # Streams SubscriptionInstance records from the API as an Enumerable.
45
+ # This operation lazily loads records as efficiently as possible until the limit
46
+ # is reached.
47
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
48
+ # guarantees to never return more than limit. Default is no limit.
49
+ # @param [Integer] page_size Number of records to fetch per request, when
50
+ # not set will use the default value of 50 records. If no page_size is defined
51
+ # but a limit is defined, stream() will attempt to read the limit with the most
52
+ # efficient page size, i.e. min(limit, 1000)
53
+ # @return [Enumerable] Enumerable that will yield up to limit results
54
+ def stream(limit: nil, page_size: nil)
55
+ limits = @version.read_limits(limit, page_size)
56
+
57
+ page = self.page(page_size: limits[:page_size], )
58
+
59
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
60
+ end
61
+
62
+ ##
63
+ # When passed a block, yields SubscriptionInstance records from the API.
64
+ # This operation lazily loads records as efficiently as possible until the limit
65
+ # is reached.
66
+ def each
67
+ limits = @version.read_limits
68
+
69
+ page = self.page(page_size: limits[:page_size], )
70
+
71
+ @version.stream(page,
72
+ limit: limits[:limit],
73
+ page_limit: limits[:page_limit]).each {|x| yield x}
74
+ end
75
+
76
+ ##
77
+ # Retrieve a single page of SubscriptionInstance records from the API.
78
+ # Request is executed immediately.
79
+ # @param [String] page_token PageToken provided by the API
80
+ # @param [Integer] page_number Page Number, this value is simply for client state
81
+ # @param [Integer] page_size Number of records to return, defaults to 50
82
+ # @return [Page] Page of SubscriptionInstance
83
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
84
+ params = Twilio::Values.of({
85
+ 'PageToken' => page_token,
86
+ 'Page' => page_number,
87
+ 'PageSize' => page_size,
88
+ })
89
+
90
+ response = @version.page('GET', @uri, params: params)
91
+
92
+ SubscriptionPage.new(@version, response, @solution)
93
+ end
94
+
95
+ ##
96
+ # Retrieve a single page of SubscriptionInstance records from the API.
97
+ # Request is executed immediately.
98
+ # @param [String] target_url API-generated URL for the requested results page
99
+ # @return [Page] Page of SubscriptionInstance
100
+ def get_page(target_url)
101
+ response = @version.domain.request(
102
+ 'GET',
103
+ target_url
104
+ )
105
+ SubscriptionPage.new(@version, response, @solution)
106
+ end
107
+
108
+ ##
109
+ # Create the SubscriptionInstance
110
+ # @param [String] description A human readable description for the Subscription
111
+ # @param [String] sink_sid The SID of the sink that events selected by this
112
+ # subscription should be sent to. Sink must be active for the subscription to be
113
+ # created.
114
+ # @param [Hash] types Contains a dictionary of URL links to nested resources of
115
+ # this Subscription.
116
+ # @return [SubscriptionInstance] Created SubscriptionInstance
117
+ def create(description: nil, sink_sid: nil, types: nil)
118
+ data = Twilio::Values.of({
119
+ 'Description' => description,
120
+ 'SinkSid' => sink_sid,
121
+ 'Types' => Twilio.serialize_list(types) { |e| Twilio.serialize_object(e) },
122
+ })
123
+
124
+ payload = @version.create('POST', @uri, data: data)
125
+
126
+ SubscriptionInstance.new(@version, payload, )
127
+ end
128
+
129
+ ##
130
+ # Provide a user friendly representation
131
+ def to_s
132
+ '#<Twilio.Events.V1.SubscriptionList>'
133
+ end
134
+ end
135
+
136
+ ##
137
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
138
+ class SubscriptionPage < Page
139
+ ##
140
+ # Initialize the SubscriptionPage
141
+ # @param [Version] version Version that contains the resource
142
+ # @param [Response] response Response from the API
143
+ # @param [Hash] solution Path solution for the resource
144
+ # @return [SubscriptionPage] SubscriptionPage
145
+ def initialize(version, response, solution)
146
+ super(version, response)
147
+
148
+ # Path Solution
149
+ @solution = solution
150
+ end
151
+
152
+ ##
153
+ # Build an instance of SubscriptionInstance
154
+ # @param [Hash] payload Payload response from the API
155
+ # @return [SubscriptionInstance] SubscriptionInstance
156
+ def get_instance(payload)
157
+ SubscriptionInstance.new(@version, payload, )
158
+ end
159
+
160
+ ##
161
+ # Provide a user friendly representation
162
+ def to_s
163
+ '<Twilio.Events.V1.SubscriptionPage>'
164
+ end
165
+ end
166
+
167
+ ##
168
+ # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
169
+ class SubscriptionContext < InstanceContext
170
+ ##
171
+ # Initialize the SubscriptionContext
172
+ # @param [Version] version Version that contains the resource
173
+ # @param [String] sid A 34 character string that uniquely identifies this
174
+ # Subscription.
175
+ # @return [SubscriptionContext] SubscriptionContext
176
+ def initialize(version, sid)
177
+ super(version)
178
+
179
+ # Path Solution
180
+ @solution = {sid: sid, }
181
+ @uri = "/Subscriptions/#{@solution[:sid]}"
182
+
183
+ # Dependents
184
+ @subscribed_events = nil
185
+ end
186
+
187
+ ##
188
+ # Fetch the SubscriptionInstance
189
+ # @return [SubscriptionInstance] Fetched SubscriptionInstance
190
+ def fetch
191
+ payload = @version.fetch('GET', @uri)
192
+
193
+ SubscriptionInstance.new(@version, payload, sid: @solution[:sid], )
194
+ end
195
+
196
+ ##
197
+ # Delete the SubscriptionInstance
198
+ # @return [Boolean] true if delete succeeds, false otherwise
199
+ def delete
200
+ @version.delete('DELETE', @uri)
201
+ end
202
+
203
+ ##
204
+ # Access the subscribed_events
205
+ # @return [SubscribedEventList]
206
+ # @return [SubscribedEventContext] if type was passed.
207
+ def subscribed_events(type=:unset)
208
+ raise ArgumentError, 'type cannot be nil' if type.nil?
209
+
210
+ if type != :unset
211
+ return SubscribedEventContext.new(@version, @solution[:sid], type, )
212
+ end
213
+
214
+ unless @subscribed_events
215
+ @subscribed_events = SubscribedEventList.new(@version, subscription_sid: @solution[:sid], )
216
+ end
217
+
218
+ @subscribed_events
219
+ end
220
+
221
+ ##
222
+ # Provide a user friendly representation
223
+ def to_s
224
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
225
+ "#<Twilio.Events.V1.SubscriptionContext #{context}>"
226
+ end
227
+
228
+ ##
229
+ # Provide a detailed, user friendly representation
230
+ def inspect
231
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
232
+ "#<Twilio.Events.V1.SubscriptionContext #{context}>"
233
+ end
234
+ end
235
+
236
+ ##
237
+ # 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.
238
+ class SubscriptionInstance < InstanceResource
239
+ ##
240
+ # Initialize the SubscriptionInstance
241
+ # @param [Version] version Version that contains the resource
242
+ # @param [Hash] payload payload that contains response from Twilio
243
+ # @param [String] sid A 34 character string that uniquely identifies this
244
+ # Subscription.
245
+ # @return [SubscriptionInstance] SubscriptionInstance
246
+ def initialize(version, payload, sid: nil)
247
+ super(version)
248
+
249
+ # Marshaled Properties
250
+ @properties = {
251
+ 'account_sid' => payload['account_sid'],
252
+ 'sid' => payload['sid'],
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
+ 'sink_sid' => payload['sink_sid'],
257
+ 'url' => payload['url'],
258
+ 'links' => payload['links'],
259
+ }
260
+
261
+ # Context
262
+ @instance_context = nil
263
+ @params = {'sid' => sid || @properties['sid'], }
264
+ end
265
+
266
+ ##
267
+ # Generate an instance context for the instance, the context is capable of
268
+ # performing various actions. All instance actions are proxied to the context
269
+ # @return [SubscriptionContext] SubscriptionContext for this SubscriptionInstance
270
+ def context
271
+ unless @instance_context
272
+ @instance_context = SubscriptionContext.new(@version, @params['sid'], )
273
+ end
274
+ @instance_context
275
+ end
276
+
277
+ ##
278
+ # @return [String] Account SID.
279
+ def account_sid
280
+ @properties['account_sid']
281
+ end
282
+
283
+ ##
284
+ # @return [String] A string that uniquely identifies this Subscription.
285
+ def sid
286
+ @properties['sid']
287
+ end
288
+
289
+ ##
290
+ # @return [Time] The date this Subscription was created
291
+ def date_created
292
+ @properties['date_created']
293
+ end
294
+
295
+ ##
296
+ # @return [Time] The date this Subscription was updated
297
+ def date_updated
298
+ @properties['date_updated']
299
+ end
300
+
301
+ ##
302
+ # @return [String] Subscription description
303
+ def description
304
+ @properties['description']
305
+ end
306
+
307
+ ##
308
+ # @return [String] Sink SID.
309
+ def sink_sid
310
+ @properties['sink_sid']
311
+ end
312
+
313
+ ##
314
+ # @return [String] The URL of this resource.
315
+ def url
316
+ @properties['url']
317
+ end
318
+
319
+ ##
320
+ # @return [String] Nested resource URLs.
321
+ def links
322
+ @properties['links']
323
+ end
324
+
325
+ ##
326
+ # Fetch the SubscriptionInstance
327
+ # @return [SubscriptionInstance] Fetched SubscriptionInstance
328
+ def fetch
329
+ context.fetch
330
+ end
331
+
332
+ ##
333
+ # Delete the SubscriptionInstance
334
+ # @return [Boolean] true if delete succeeds, false otherwise
335
+ def delete
336
+ context.delete
337
+ end
338
+
339
+ ##
340
+ # Access the subscribed_events
341
+ # @return [subscribed_events] subscribed_events
342
+ def subscribed_events
343
+ context.subscribed_events
344
+ end
345
+
346
+ ##
347
+ # Provide a user friendly representation
348
+ def to_s
349
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
350
+ "<Twilio.Events.V1.SubscriptionInstance #{values}>"
351
+ end
352
+
353
+ ##
354
+ # Provide a detailed, user friendly representation
355
+ def inspect
356
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
357
+ "<Twilio.Events.V1.SubscriptionInstance #{values}>"
358
+ end
359
+ end
360
+ end
361
+ end
362
+ end
363
+ end