twilio-ruby 5.34.0 → 5.38.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 (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +126 -0
  3. data/README.md +24 -3
  4. data/lib/twilio-ruby.rb +1 -1
  5. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +87 -87
  6. data/lib/twilio-ruby/rest/api/v2010/account/conference.rb +14 -0
  7. data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +47 -9
  8. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +71 -71
  9. data/lib/twilio-ruby/rest/api/v2010/account/queue.rb +29 -29
  10. data/lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb +38 -3
  11. data/lib/twilio-ruby/rest/api/v2010/account/validation_request.rb +12 -12
  12. data/lib/twilio-ruby/rest/autopilot.rb +6 -0
  13. data/lib/twilio-ruby/rest/autopilot/v1.rb +7 -0
  14. data/lib/twilio-ruby/rest/autopilot/v1/assistant.rb +0 -16
  15. data/lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb +12 -3
  16. data/lib/twilio-ruby/rest/autopilot/v1/restore_assistant.rb +198 -0
  17. data/lib/twilio-ruby/rest/client.rb +35 -15
  18. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +28 -3
  19. data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +27 -4
  20. data/lib/twilio-ruby/rest/flex_api/v1/channel.rb +2 -1
  21. data/lib/twilio-ruby/rest/flex_api/v1/configuration.rb +7 -0
  22. data/lib/twilio-ruby/rest/flex_api/v1/flex_flow.rb +6 -3
  23. data/lib/twilio-ruby/rest/monitor/v1/alert.rb +8 -8
  24. data/lib/twilio-ruby/rest/notify/v1/service.rb +20 -1
  25. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle.rb +26 -0
  26. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/evaluation.rb +324 -0
  27. data/lib/twilio-ruby/rest/preview.rb +6 -0
  28. data/lib/twilio-ruby/rest/preview/trusted_comms.rb +7 -0
  29. data/lib/twilio-ruby/rest/preview/trusted_comms/brands_information.rb +193 -0
  30. data/lib/twilio-ruby/rest/preview/trusted_comms/business.rb +26 -0
  31. data/lib/twilio-ruby/rest/{autopilot/v1/assistant/export_assistant.rb → preview/trusted_comms/business/brand.rb} +88 -71
  32. data/lib/twilio-ruby/rest/preview/trusted_comms/business/brand/branded_channel.rb +266 -0
  33. data/lib/twilio-ruby/rest/preview/trusted_comms/business/brand/branded_channel/channel.rb +194 -0
  34. data/lib/twilio-ruby/rest/serverless/v1/service/environment/log.rb +7 -0
  35. data/lib/twilio-ruby/rest/supersim.rb +18 -0
  36. data/lib/twilio-ruby/rest/supersim/v1.rb +30 -0
  37. data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +63 -16
  38. data/lib/twilio-ruby/rest/supersim/v1/network.rb +315 -0
  39. data/lib/twilio-ruby/rest/{authy/v1/service.rb → supersim/v1/network_access_profile.rb} +95 -121
  40. data/lib/twilio-ruby/rest/supersim/v1/network_access_profile/network_access_profile_network.rb +352 -0
  41. data/lib/twilio-ruby/rest/verify.rb +9 -0
  42. data/lib/twilio-ruby/rest/verify/v2.rb +16 -0
  43. data/lib/twilio-ruby/rest/{authy/v1 → verify/v2}/form.rb +8 -8
  44. data/lib/twilio-ruby/rest/verify/v2/service.rb +74 -3
  45. data/lib/twilio-ruby/rest/{authy/v1 → verify/v2}/service/entity.rb +32 -8
  46. data/lib/twilio-ruby/rest/verify/v2/service/entity/access_token.rb +141 -0
  47. data/lib/twilio-ruby/rest/{authy/v1 → verify/v2}/service/entity/factor.rb +8 -8
  48. data/lib/twilio-ruby/rest/{authy/v1 → verify/v2}/service/entity/factor/challenge.rb +8 -8
  49. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +3 -3
  50. data/lib/twilio-ruby/rest/verify/v2/service/webhook.rb +425 -0
  51. data/lib/twilio-ruby/rest/video/v1/composition_settings.rb +8 -4
  52. data/lib/twilio-ruby/rest/video/v1/recording_settings.rb +8 -4
  53. data/lib/twilio-ruby/rest/voice.rb +36 -0
  54. data/lib/twilio-ruby/rest/voice/v1.rb +64 -0
  55. data/lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb +513 -0
  56. data/lib/twilio-ruby/rest/voice/v1/connection_policy.rb +379 -0
  57. data/lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb +458 -0
  58. data/lib/twilio-ruby/rest/voice/v1/ip_record.rb +366 -0
  59. data/lib/twilio-ruby/rest/voice/v1/source_ip_mapping.rb +346 -0
  60. data/lib/twilio-ruby/util/configuration.rb +9 -1
  61. data/lib/twilio-ruby/version.rb +1 -1
  62. data/spec/integration/api/v2010/account/call_spec.rb +5 -5
  63. data/spec/integration/api/v2010/account/conference/participant_spec.rb +177 -0
  64. data/spec/integration/api/v2010/account/conference_spec.rb +42 -14
  65. data/spec/integration/api/v2010/account/outgoing_caller_id_spec.rb +8 -14
  66. data/spec/integration/api/v2010/account/sip/domain_spec.rb +12 -4
  67. data/spec/integration/api/v2010/account/token_spec.rb +23 -11
  68. data/spec/integration/api/v2010/account/validation_request_spec.rb +1 -1
  69. data/spec/integration/autopilot/v1/assistant/query_spec.rb +4 -4
  70. data/spec/integration/autopilot/v1/assistant_spec.rb +4 -8
  71. data/spec/integration/autopilot/v1/restore_assistant_spec.rb +53 -0
  72. data/spec/integration/conversations/v1/conversation/participant_spec.rb +7 -0
  73. data/spec/integration/conversations/v1/conversation_spec.rb +16 -0
  74. data/spec/integration/flex_api/v1/configuration_spec.rb +3 -0
  75. data/spec/integration/numbers/v2/regulatory_compliance/bundle/evaluation_spec.rb +623 -0
  76. data/spec/integration/numbers/v2/regulatory_compliance/bundle_spec.rb +4 -0
  77. data/spec/integration/preview/trusted_comms/brands_information_spec.rb +44 -0
  78. data/spec/integration/preview/trusted_comms/business/brand/branded_channel/channel_spec.rb +54 -0
  79. data/spec/integration/preview/trusted_comms/business/brand/branded_channel_spec.rb +52 -0
  80. data/spec/integration/preview/trusted_comms/business/brand_spec.rb +49 -0
  81. data/spec/integration/preview/trusted_comms/business_spec.rb +1 -0
  82. data/spec/integration/serverless/v1/service/environment/log_spec.rb +1 -0
  83. data/spec/integration/supersim/v1/fleet_spec.rb +16 -7
  84. data/spec/integration/supersim/v1/network_access_profile/network_access_profile_network_spec.rb +179 -0
  85. data/spec/integration/supersim/v1/network_access_profile_spec.rb +223 -0
  86. data/spec/integration/supersim/v1/network_spec.rb +139 -0
  87. data/spec/integration/supersim/v1/sim_spec.rb +78 -6
  88. data/spec/integration/trunking/v1/trunk/credential_list_spec.rb +13 -13
  89. data/spec/integration/trunking/v1/trunk/ip_access_control_list_spec.rb +23 -23
  90. data/spec/integration/trunking/v1/trunk/origination_url_spec.rb +28 -28
  91. data/spec/integration/trunking/v1/trunk/phone_number_spec.rb +17 -17
  92. data/spec/integration/trunking/v1/trunk_spec.rb +33 -33
  93. data/spec/integration/{authy/v1 → verify/v2}/form_spec.rb +4 -4
  94. data/spec/integration/verify/v2/service/entity/access_token_spec.rb +46 -0
  95. data/spec/integration/{authy/v1 → verify/v2}/service/entity/factor/challenge_spec.rb +73 -73
  96. data/spec/integration/{authy/v1 → verify/v2}/service/entity/factor_spec.rb +54 -54
  97. data/spec/integration/verify/v2/service/entity_spec.rb +204 -0
  98. data/spec/integration/verify/v2/service/webhook_spec.rb +262 -0
  99. data/spec/integration/verify/v2/service_spec.rb +32 -4
  100. data/spec/integration/voice/v1/byoc_trunk_spec.rb +250 -0
  101. data/spec/integration/voice/v1/connection_policy/connection_policy_target_spec.rb +246 -0
  102. data/spec/integration/voice/v1/connection_policy_spec.rb +226 -0
  103. data/spec/integration/voice/v1/ip_record_spec.rb +223 -0
  104. data/spec/integration/voice/v1/source_ip_mapping_spec.rb +219 -0
  105. data/spec/rest/client_spec.rb +168 -58
  106. data/spec/util/configuration_spec.rb +12 -0
  107. data/twilio-ruby.gemspec +1 -1
  108. metadata +63 -23
  109. data/lib/twilio-ruby/rest/authy.rb +0 -55
  110. data/lib/twilio-ruby/rest/authy/v1.rb +0 -59
  111. data/spec/integration/authy/v1/service/entity_spec.rb +0 -201
  112. data/spec/integration/authy/v1/service_spec.rb +0 -231
  113. data/spec/integration/autopilot/v1/assistant/export_assistant_spec.rb +0 -49
@@ -8,8 +8,8 @@
8
8
 
9
9
  module Twilio
10
10
  module REST
11
- class Authy < Domain
12
- class V1 < Version
11
+ class Verify < Domain
12
+ class V2 < Version
13
13
  class ServiceContext < InstanceContext
14
14
  class EntityContext < InstanceContext
15
15
  class FactorContext < InstanceContext
@@ -156,7 +156,7 @@ module Twilio
156
156
  ##
157
157
  # Provide a user friendly representation
158
158
  def to_s
159
- '#<Twilio.Authy.V1.ChallengeList>'
159
+ '#<Twilio.Verify.V2.ChallengeList>'
160
160
  end
161
161
  end
162
162
 
@@ -193,7 +193,7 @@ module Twilio
193
193
  ##
194
194
  # Provide a user friendly representation
195
195
  def to_s
196
- '<Twilio.Authy.V1.ChallengePage>'
196
+ '<Twilio.Verify.V2.ChallengePage>'
197
197
  end
198
198
  end
199
199
 
@@ -276,14 +276,14 @@ module Twilio
276
276
  # Provide a user friendly representation
277
277
  def to_s
278
278
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
279
- "#<Twilio.Authy.V1.ChallengeContext #{context}>"
279
+ "#<Twilio.Verify.V2.ChallengeContext #{context}>"
280
280
  end
281
281
 
282
282
  ##
283
283
  # Provide a detailed, user friendly representation
284
284
  def inspect
285
285
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
286
- "#<Twilio.Authy.V1.ChallengeContext #{context}>"
286
+ "#<Twilio.Verify.V2.ChallengeContext #{context}>"
287
287
  end
288
288
  end
289
289
 
@@ -475,14 +475,14 @@ module Twilio
475
475
  # Provide a user friendly representation
476
476
  def to_s
477
477
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
478
- "<Twilio.Authy.V1.ChallengeInstance #{values}>"
478
+ "<Twilio.Verify.V2.ChallengeInstance #{values}>"
479
479
  end
480
480
 
481
481
  ##
482
482
  # Provide a detailed, user friendly representation
483
483
  def inspect
484
484
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
485
- "<Twilio.Authy.V1.ChallengeInstance #{values}>"
485
+ "<Twilio.Verify.V2.ChallengeInstance #{values}>"
486
486
  end
487
487
  end
488
488
  end
@@ -42,9 +42,9 @@ module Twilio
42
42
  # Voice documentation of
43
43
  # [sendDigits](https://www.twilio.com/docs/voice/twiml/number#attributes-sendDigits).
44
44
  # @param [String] locale The locale to use for the verification SMS or call. Can
45
- # be: `af`, `ar`, `ca`, `cs`, `da`, `de`, `el`, `en`, `es`, `fi`, `fr`, `he`,
46
- # `hi`, `hr`, `hu`, `id`, `it`, `ja`, `ko`, `ms`, `nb`, `nl`, `pl`, `pt`, `pr-BR`,
47
- # `ro`, `ru`, `sv`, `th`, `tl`, `tr`, `vi`, `zh`, `zh-CN`, or `zh-HK.`
45
+ # be: `af`, `ar`, `ca`, `cs`, `da`, `de`, `el`, `en`, `en-GB`, `es`, `fi`, `fr`,
46
+ # `he`, `hi`, `hr`, `hu`, `id`, `it`, `ja`, `ko`, `ms`, `nb`, `nl`, `pl`, `pt`,
47
+ # `pr-BR`, `ro`, `ru`, `sv`, `th`, `tl`, `tr`, `vi`, `zh`, `zh-CN`, or `zh-HK.`
48
48
  # @param [String] custom_code A pre-generated code to use for verification. The
49
49
  # code can be between 4 and 10 characters, inclusive.
50
50
  # @param [String] amount The amount of the associated PSD2 compliant transaction.
@@ -0,0 +1,425 @@
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 Verify < Domain
12
+ class V2 < Version
13
+ class ServiceContext < 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 WebhookList < ListResource
17
+ ##
18
+ # Initialize the WebhookList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] service_sid The unique SID identifier of the Service.
21
+ # @return [WebhookList] WebhookList
22
+ def initialize(version, service_sid: nil)
23
+ super(version)
24
+
25
+ # Path Solution
26
+ @solution = {service_sid: service_sid}
27
+ @uri = "/Services/#{@solution[:service_sid]}/Webhooks"
28
+ end
29
+
30
+ ##
31
+ # Retrieve a single page of WebhookInstance records from the API.
32
+ # Request is executed immediately.
33
+ # @param [String] friendly_name The string that you assigned to describe the
34
+ # webhook. **This value should not contain PII.**
35
+ # @param [String] event_types The array of events that this Webhook is subscribed
36
+ # to. Possible event types: `*, factor.deleted, factor.created, factor.verified,
37
+ # challenge.approved, challenge.denied`
38
+ # @param [String] webhook_url The URL associated with this Webhook.
39
+ # @param [webhook.Status] status The webhook status. Default value is `enabled`.
40
+ # One of: `enabled` or `disabled`
41
+ # @return [WebhookInstance] Newly created WebhookInstance
42
+ def create(friendly_name: nil, event_types: nil, webhook_url: nil, status: :unset)
43
+ data = Twilio::Values.of({
44
+ 'FriendlyName' => friendly_name,
45
+ 'EventTypes' => Twilio.serialize_list(event_types) { |e| e },
46
+ 'WebhookUrl' => webhook_url,
47
+ 'Status' => status,
48
+ })
49
+
50
+ payload = @version.create(
51
+ 'POST',
52
+ @uri,
53
+ data: data
54
+ )
55
+
56
+ WebhookInstance.new(@version, payload, service_sid: @solution[:service_sid], )
57
+ end
58
+
59
+ ##
60
+ # Lists WebhookInstance records from the API as a list.
61
+ # Unlike stream(), this operation is eager and will load `limit` records into
62
+ # memory before returning.
63
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
64
+ # guarantees to never return more than limit. Default is no limit
65
+ # @param [Integer] page_size Number of records to fetch per request, when
66
+ # not set will use the default value of 50 records. If no page_size is defined
67
+ # but a limit is defined, stream() will attempt to read the limit with the most
68
+ # efficient page size, i.e. min(limit, 1000)
69
+ # @return [Array] Array of up to limit results
70
+ def list(limit: nil, page_size: nil)
71
+ self.stream(limit: limit, page_size: page_size).entries
72
+ end
73
+
74
+ ##
75
+ # Streams WebhookInstance records from the API as an Enumerable.
76
+ # This operation lazily loads records as efficiently as possible until the limit
77
+ # is reached.
78
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
79
+ # guarantees to never return more than limit. Default is no limit.
80
+ # @param [Integer] page_size Number of records to fetch per request, when
81
+ # not set will use the default value of 50 records. If no page_size is defined
82
+ # but a limit is defined, stream() will attempt to read the limit with the most
83
+ # efficient page size, i.e. min(limit, 1000)
84
+ # @return [Enumerable] Enumerable that will yield up to limit results
85
+ def stream(limit: nil, page_size: nil)
86
+ limits = @version.read_limits(limit, page_size)
87
+
88
+ page = self.page(page_size: limits[:page_size], )
89
+
90
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
91
+ end
92
+
93
+ ##
94
+ # When passed a block, yields WebhookInstance records from the API.
95
+ # This operation lazily loads records as efficiently as possible until the limit
96
+ # is reached.
97
+ def each
98
+ limits = @version.read_limits
99
+
100
+ page = self.page(page_size: limits[:page_size], )
101
+
102
+ @version.stream(page,
103
+ limit: limits[:limit],
104
+ page_limit: limits[:page_limit]).each {|x| yield x}
105
+ end
106
+
107
+ ##
108
+ # Retrieve a single page of WebhookInstance records from the API.
109
+ # Request is executed immediately.
110
+ # @param [String] page_token PageToken provided by the API
111
+ # @param [Integer] page_number Page Number, this value is simply for client state
112
+ # @param [Integer] page_size Number of records to return, defaults to 50
113
+ # @return [Page] Page of WebhookInstance
114
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
115
+ params = Twilio::Values.of({
116
+ 'PageToken' => page_token,
117
+ 'Page' => page_number,
118
+ 'PageSize' => page_size,
119
+ })
120
+ response = @version.page(
121
+ 'GET',
122
+ @uri,
123
+ params
124
+ )
125
+ WebhookPage.new(@version, response, @solution)
126
+ end
127
+
128
+ ##
129
+ # Retrieve a single page of WebhookInstance records from the API.
130
+ # Request is executed immediately.
131
+ # @param [String] target_url API-generated URL for the requested results page
132
+ # @return [Page] Page of WebhookInstance
133
+ def get_page(target_url)
134
+ response = @version.domain.request(
135
+ 'GET',
136
+ target_url
137
+ )
138
+ WebhookPage.new(@version, response, @solution)
139
+ end
140
+
141
+ ##
142
+ # Provide a user friendly representation
143
+ def to_s
144
+ '#<Twilio.Verify.V2.WebhookList>'
145
+ end
146
+ end
147
+
148
+ ##
149
+ # 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.
150
+ class WebhookPage < Page
151
+ ##
152
+ # Initialize the WebhookPage
153
+ # @param [Version] version Version that contains the resource
154
+ # @param [Response] response Response from the API
155
+ # @param [Hash] solution Path solution for the resource
156
+ # @return [WebhookPage] WebhookPage
157
+ def initialize(version, response, solution)
158
+ super(version, response)
159
+
160
+ # Path Solution
161
+ @solution = solution
162
+ end
163
+
164
+ ##
165
+ # Build an instance of WebhookInstance
166
+ # @param [Hash] payload Payload response from the API
167
+ # @return [WebhookInstance] WebhookInstance
168
+ def get_instance(payload)
169
+ WebhookInstance.new(@version, payload, service_sid: @solution[:service_sid], )
170
+ end
171
+
172
+ ##
173
+ # Provide a user friendly representation
174
+ def to_s
175
+ '<Twilio.Verify.V2.WebhookPage>'
176
+ end
177
+ end
178
+
179
+ ##
180
+ # 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.
181
+ class WebhookContext < InstanceContext
182
+ ##
183
+ # Initialize the WebhookContext
184
+ # @param [Version] version Version that contains the resource
185
+ # @param [String] service_sid The unique SID identifier of the Service.
186
+ # @param [String] sid The Twilio-provided string that uniquely identifies the
187
+ # Webhook resource to fetch.
188
+ # @return [WebhookContext] WebhookContext
189
+ def initialize(version, service_sid, sid)
190
+ super(version)
191
+
192
+ # Path Solution
193
+ @solution = {service_sid: service_sid, sid: sid, }
194
+ @uri = "/Services/#{@solution[:service_sid]}/Webhooks/#{@solution[:sid]}"
195
+ end
196
+
197
+ ##
198
+ # Update the WebhookInstance
199
+ # @param [String] friendly_name The string that you assigned to describe the
200
+ # webhook. **This value should not contain PII.**
201
+ # @param [String] event_types The array of events that this Webhook is subscribed
202
+ # to. Possible event types: `*, factor.deleted, factor.created, factor.verified,
203
+ # challenge.approved, challenge.denied`
204
+ # @param [String] webhook_url The URL associated with this Webhook.
205
+ # @param [webhook.Status] status The webhook status. Default value is `enabled`.
206
+ # One of: `enabled` or `disabled`
207
+ # @return [WebhookInstance] Updated WebhookInstance
208
+ def update(friendly_name: :unset, event_types: :unset, webhook_url: :unset, status: :unset)
209
+ data = Twilio::Values.of({
210
+ 'FriendlyName' => friendly_name,
211
+ 'EventTypes' => Twilio.serialize_list(event_types) { |e| e },
212
+ 'WebhookUrl' => webhook_url,
213
+ 'Status' => status,
214
+ })
215
+
216
+ payload = @version.update(
217
+ 'POST',
218
+ @uri,
219
+ data: data,
220
+ )
221
+
222
+ WebhookInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
223
+ end
224
+
225
+ ##
226
+ # Deletes the WebhookInstance
227
+ # @return [Boolean] true if delete succeeds, false otherwise
228
+ def delete
229
+ @version.delete('delete', @uri)
230
+ end
231
+
232
+ ##
233
+ # Fetch a WebhookInstance
234
+ # @return [WebhookInstance] Fetched WebhookInstance
235
+ def fetch
236
+ params = Twilio::Values.of({})
237
+
238
+ payload = @version.fetch(
239
+ 'GET',
240
+ @uri,
241
+ params,
242
+ )
243
+
244
+ WebhookInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
245
+ end
246
+
247
+ ##
248
+ # Provide a user friendly representation
249
+ def to_s
250
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
251
+ "#<Twilio.Verify.V2.WebhookContext #{context}>"
252
+ end
253
+
254
+ ##
255
+ # Provide a detailed, user friendly representation
256
+ def inspect
257
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
258
+ "#<Twilio.Verify.V2.WebhookContext #{context}>"
259
+ end
260
+ end
261
+
262
+ ##
263
+ # 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.
264
+ class WebhookInstance < InstanceResource
265
+ ##
266
+ # Initialize the WebhookInstance
267
+ # @param [Version] version Version that contains the resource
268
+ # @param [Hash] payload payload that contains response from Twilio
269
+ # @param [String] service_sid The unique SID identifier of the Service.
270
+ # @param [String] sid The Twilio-provided string that uniquely identifies the
271
+ # Webhook resource to fetch.
272
+ # @return [WebhookInstance] WebhookInstance
273
+ def initialize(version, payload, service_sid: nil, sid: nil)
274
+ super(version)
275
+
276
+ # Marshaled Properties
277
+ @properties = {
278
+ 'sid' => payload['sid'],
279
+ 'service_sid' => payload['service_sid'],
280
+ 'account_sid' => payload['account_sid'],
281
+ 'friendly_name' => payload['friendly_name'],
282
+ 'event_types' => payload['event_types'],
283
+ 'status' => payload['status'],
284
+ 'webhook_url' => payload['webhook_url'],
285
+ 'webhook_method' => payload['webhook_method'],
286
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
287
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
288
+ 'url' => payload['url'],
289
+ }
290
+
291
+ # Context
292
+ @instance_context = nil
293
+ @params = {'service_sid' => service_sid, 'sid' => sid || @properties['sid'], }
294
+ end
295
+
296
+ ##
297
+ # Generate an instance context for the instance, the context is capable of
298
+ # performing various actions. All instance actions are proxied to the context
299
+ # @return [WebhookContext] WebhookContext for this WebhookInstance
300
+ def context
301
+ unless @instance_context
302
+ @instance_context = WebhookContext.new(@version, @params['service_sid'], @params['sid'], )
303
+ end
304
+ @instance_context
305
+ end
306
+
307
+ ##
308
+ # @return [String] The unique string that identifies the resource
309
+ def sid
310
+ @properties['sid']
311
+ end
312
+
313
+ ##
314
+ # @return [String] Service Sid.
315
+ def service_sid
316
+ @properties['service_sid']
317
+ end
318
+
319
+ ##
320
+ # @return [String] The SID of the Account that created the resource
321
+ def account_sid
322
+ @properties['account_sid']
323
+ end
324
+
325
+ ##
326
+ # @return [String] The string that you assigned to describe the webhook
327
+ def friendly_name
328
+ @properties['friendly_name']
329
+ end
330
+
331
+ ##
332
+ # @return [String] The array of events that this Webhook is subscribed to.
333
+ def event_types
334
+ @properties['event_types']
335
+ end
336
+
337
+ ##
338
+ # @return [webhook.Status] The webhook status
339
+ def status
340
+ @properties['status']
341
+ end
342
+
343
+ ##
344
+ # @return [String] The URL associated with this Webhook.
345
+ def webhook_url
346
+ @properties['webhook_url']
347
+ end
348
+
349
+ ##
350
+ # @return [webhook.Methods] The method used when calling the webhook's URL.
351
+ def webhook_method
352
+ @properties['webhook_method']
353
+ end
354
+
355
+ ##
356
+ # @return [Time] The RFC 2822 date and time in GMT when the resource was created
357
+ def date_created
358
+ @properties['date_created']
359
+ end
360
+
361
+ ##
362
+ # @return [Time] The RFC 2822 date and time in GMT when the resource was last updated
363
+ def date_updated
364
+ @properties['date_updated']
365
+ end
366
+
367
+ ##
368
+ # @return [String] The absolute URL of the Webhook resource
369
+ def url
370
+ @properties['url']
371
+ end
372
+
373
+ ##
374
+ # Update the WebhookInstance
375
+ # @param [String] friendly_name The string that you assigned to describe the
376
+ # webhook. **This value should not contain PII.**
377
+ # @param [String] event_types The array of events that this Webhook is subscribed
378
+ # to. Possible event types: `*, factor.deleted, factor.created, factor.verified,
379
+ # challenge.approved, challenge.denied`
380
+ # @param [String] webhook_url The URL associated with this Webhook.
381
+ # @param [webhook.Status] status The webhook status. Default value is `enabled`.
382
+ # One of: `enabled` or `disabled`
383
+ # @return [WebhookInstance] Updated WebhookInstance
384
+ def update(friendly_name: :unset, event_types: :unset, webhook_url: :unset, status: :unset)
385
+ context.update(
386
+ friendly_name: friendly_name,
387
+ event_types: event_types,
388
+ webhook_url: webhook_url,
389
+ status: status,
390
+ )
391
+ end
392
+
393
+ ##
394
+ # Deletes the WebhookInstance
395
+ # @return [Boolean] true if delete succeeds, false otherwise
396
+ def delete
397
+ context.delete
398
+ end
399
+
400
+ ##
401
+ # Fetch a WebhookInstance
402
+ # @return [WebhookInstance] Fetched WebhookInstance
403
+ def fetch
404
+ context.fetch
405
+ end
406
+
407
+ ##
408
+ # Provide a user friendly representation
409
+ def to_s
410
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
411
+ "<Twilio.Verify.V2.WebhookInstance #{values}>"
412
+ end
413
+
414
+ ##
415
+ # Provide a detailed, user friendly representation
416
+ def inspect
417
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
418
+ "<Twilio.Verify.V2.WebhookInstance #{values}>"
419
+ end
420
+ end
421
+ end
422
+ end
423
+ end
424
+ end
425
+ end