Class: Twilio::REST::Verify::V2::ServiceContext::WebhookInstance

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

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, service_sid: nil, sid: nil) ⇒ WebhookInstance

Initialize the WebhookInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • service_sid (String) (defaults to: nil)

    The unique SID identifier of the Service.

  • sid (String) (defaults to: nil)

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



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 256

def initialize(version, payload, service_sid: nil, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'service_sid' => payload['service_sid'],
      'account_sid' => payload['account_sid'],
      'friendly_name' => payload['friendly_name'],
      'event_types' => payload['event_types'],
      'status' => payload['status'],
      'webhook_url' => payload['webhook_url'],
      'webhook_method' => payload['webhook_method'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'url' => payload['url'],
  }

  # Context
  @instance_context = nil
  @params = {'service_sid' => service_sid, 'sid' => sid || @properties['sid'], }
end

Instance Method Details

#account_sidString

Returns The SID of the Account that created the resource.

Returns:

  • (String)

    The SID of the Account that created the resource



304
305
306
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 304

def 
  @properties['account_sid']
end

#contextWebhookContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



283
284
285
286
287
288
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 283

def context
  unless @instance_context
    @instance_context = WebhookContext.new(@version, @params['service_sid'], @params['sid'], )
  end
  @instance_context
end

#date_createdTime

Returns The RFC 2822 date and time in GMT when the resource was created.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT when the resource was created



340
341
342
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 340

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The RFC 2822 date and time in GMT when the resource was last updated.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT when the resource was last updated



346
347
348
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 346

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Delete the WebhookInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



379
380
381
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 379

def delete
  context.delete
end

#event_typesArray[String]

Returns The array of events that this Webhook is subscribed to.

Returns:

  • (Array[String])

    The array of events that this Webhook is subscribed to.



316
317
318
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 316

def event_types
  @properties['event_types']
end

#fetchWebhookInstance

Fetch the WebhookInstance

Returns:



386
387
388
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 386

def fetch
  context.fetch
end

#friendly_nameString

Returns The string that you assigned to describe the webhook.

Returns:

  • (String)

    The string that you assigned to describe the webhook



310
311
312
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 310

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



399
400
401
402
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 399

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Verify.V2.WebhookInstance #{values}>"
end

#service_sidString

Returns Service Sid.

Returns:

  • (String)

    Service Sid.



298
299
300
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 298

def service_sid
  @properties['service_sid']
end

#sidString

Returns The unique string that identifies the resource.

Returns:

  • (String)

    The unique string that identifies the resource



292
293
294
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 292

def sid
  @properties['sid']
end

#statuswebhook.Status

Returns The webhook status.

Returns:

  • (webhook.Status)

    The webhook status



322
323
324
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 322

def status
  @properties['status']
end

#to_sObject

Provide a user friendly representation



392
393
394
395
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 392

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Verify.V2.WebhookInstance #{values}>"
end

#update(friendly_name: :unset, event_types: :unset, webhook_url: :unset, status: :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 (webhook.Status) (defaults to: :unset)

    The webhook status. Default value is ‘enabled`. One of: `enabled` or `disabled`

Returns:



367
368
369
370
371
372
373
374
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 367

def update(friendly_name: :unset, event_types: :unset, webhook_url: :unset, status: :unset)
  context.update(
      friendly_name: friendly_name,
      event_types: event_types,
      webhook_url: webhook_url,
      status: status,
  )
end

#urlString

Returns The absolute URL of the Webhook resource.

Returns:

  • (String)

    The absolute URL of the Webhook resource



352
353
354
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 352

def url
  @properties['url']
end

#webhook_methodwebhook.Methods

Returns The method used when calling the webhook’s URL.

Returns:

  • (webhook.Methods)

    The method used when calling the webhook’s URL.



334
335
336
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 334

def webhook_method
  @properties['webhook_method']
end

#webhook_urlString

Returns The URL associated with this Webhook.

Returns:

  • (String)

    The URL associated with this Webhook.



328
329
330
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 328

def webhook_url
  @properties['webhook_url']
end