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.



252
253
254
255
256
257
258
259
260
261
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 252

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



265
266
267
268
269
270
271
272
273
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 265

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

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

#delete_with_metadataBoolean

Delete the WebhookInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 278

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      webhook_instance = WebhookInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      WebhookInstanceMetadata.new(@version, webhook_instance, response.headers, response.status_code)
end

#fetchWebhookInstance

Fetch the WebhookInstance

Returns:



297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 297

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    WebhookInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        sid: @solution[:sid],
    )
end

#fetch_with_metadataWebhookInstance

Fetch the WebhookInstanceMetadata

Returns:



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 317

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    webhook_instance = WebhookInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        sid: @solution[:sid],
    )
    WebhookInstanceMetadata.new(
        @version,
        webhook_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



434
435
436
437
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 434

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

#to_sObject

Provide a user friendly representation



427
428
429
430
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 427

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:



348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 348

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_,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    WebhookInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        sid: @solution[:sid],
    )
end

#update_with_metadata(friendly_name: :unset, event_types: :unset, webhook_url: :unset, status: :unset, version_: :unset) ⇒ WebhookInstance

Update the WebhookInstanceMetadata

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:



387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
# File 'lib/twilio-ruby/rest/verify/v2/service/webhook.rb', line 387

def (
  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_,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    webhook_instance = WebhookInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        sid: @solution[:sid],
    )
    WebhookInstanceMetadata.new(
        @version,
        webhook_instance,
        response.headers,
        response.status_code
    )
end