Class: Twilio::REST::Verify::V2::ServiceContext::WebhookContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/verify/v2/service/webhook.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, sid) ⇒ WebhookContext

Initialize the WebhookContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The unique SID identifier of the Service.

  • sid (String)

    The Twilio-provided string that uniquely identifies the Webhook resource to update.



167
168
169
170
171
172
173
174
175
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 167

def initialize(version, service_sid, sid)
    super(version)

    # Path Solution
    @solution = { service_sid: service_sid, sid: sid,  }
    @uri = "/Services/#{@solution[:service_sid]}/Webhooks/#{@solution[:sid]}"

    
end

Instance Method Details

#deleteBoolean

Delete the WebhookInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



179
180
181
182
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 179

def delete

    @version.delete('DELETE', @uri)
end

#fetchWebhookInstance

Fetch the WebhookInstance

Returns:



187
188
189
190
191
192
193
194
195
196
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 187

def fetch

    payload = @version.fetch('GET', @uri)
    WebhookInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



241
242
243
244
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 241

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Verify.V2.WebhookContext #{context}>"
end

#to_sObject

Provide a user friendly representation



234
235
236
237
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 234

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Verify.V2.WebhookContext #{context}>"
end

#update(friendly_name: :unset, event_types: :unset, webhook_url: :unset, status: :unset, version: :unset) ⇒ WebhookInstance

Update the WebhookInstance

Parameters:

  • friendly_name (String) (defaults to: :unset)

    The string that you assigned to describe the webhook. **This value should not contain PII.**

  • event_types (Array[String]) (defaults to: :unset)

    The array of events that this Webhook is subscribed to. Possible event types: ‘*, factor.deleted, factor.created, factor.verified, challenge.approved, challenge.denied`

  • webhook_url (String) (defaults to: :unset)

    The URL associated with this Webhook.

  • status (Status) (defaults to: :unset)
  • version (Version) (defaults to: :unset)

Returns:



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 206

def update(
    friendly_name: :unset, 
    event_types: :unset, 
    webhook_url: :unset, 
    status: :unset, 
    version: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'EventTypes' => Twilio.serialize_list(event_types) { |e| e },
        'WebhookUrl' => webhook_url,
        'Status' => status,
        'Version' => version,
    })

    payload = @version.update('POST', @uri, data: data)
    WebhookInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        sid: @solution[:sid],
    )
end