Class: Twilio::REST::Autopilot::V1::AssistantContext::WebhookInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb

Instance Method Summary collapse

Constructor Details

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

Initialize the WebhookInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String)

    The SID of the Account that created this Webhook resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 282

def initialize(version, payload , assistant_sid: nil, sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'url' => payload['url'],
        'account_sid' => payload['account_sid'],
        'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
        'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
        'assistant_sid' => payload['assistant_sid'],
        'sid' => payload['sid'],
        'unique_name' => payload['unique_name'],
        'events' => payload['events'],
        'webhook_url' => payload['webhook_url'],
        'webhook_method' => payload['webhook_method'],
    }

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

Instance Method Details

#account_sidString

Returns The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the Webhook resource.

Returns:



323
324
325
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 323

def 
    @properties['account_sid']
end

#assistant_sidString

Returns The SID of the [Assistant](www.twilio.com/docs/autopilot/api/assistant) that is the parent of the resource.

Returns:



341
342
343
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 341

def assistant_sid
    @properties['assistant_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:



308
309
310
311
312
313
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 308

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

#date_createdTime

Returns The date and time in GMT when the resource was created specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



329
330
331
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 329

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns The date and time in GMT when the resource was last updated specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



335
336
337
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 335

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the WebhookInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



378
379
380
381
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 378

def delete

    context.delete
end

#eventsString

Returns The list of space-separated events that this Webhook is subscribed to.

Returns:

  • (String)

    The list of space-separated events that this Webhook is subscribed to.



359
360
361
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 359

def events
    @properties['events']
end

#fetchWebhookInstance

Fetch the WebhookInstance

Returns:



386
387
388
389
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 386

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



422
423
424
425
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 422

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

#sidString

Returns The unique string that we created to identify the Webhook resource.

Returns:

  • (String)

    The unique string that we created to identify the Webhook resource.



347
348
349
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 347

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



415
416
417
418
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 415

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

#unique_nameString

Returns An application-defined string that uniquely identifies the resource. It can be used in place of the resource’s ‘sid` in the URL to address the resource.

Returns:

  • (String)

    An application-defined string that uniquely identifies the resource. It can be used in place of the resource’s ‘sid` in the URL to address the resource.



353
354
355
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 353

def unique_name
    @properties['unique_name']
end

#update(unique_name: :unset, events: :unset, webhook_url: :unset, webhook_method: :unset) ⇒ WebhookInstance

Update the WebhookInstance

Parameters:

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

    An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the ‘sid` in the URL path to address the resource. This value must be unique and 64 characters or less in length.

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

    The list of space-separated events that this Webhook will subscribe to.

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

    The URL associated with this Webhook.

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

    The method to be used when calling the webhook’s URL.

Returns:



398
399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 398

def update(
    unique_name: :unset, 
    events: :unset, 
    webhook_url: :unset, 
    webhook_method: :unset
)

    context.update(
        unique_name: unique_name, 
        events: events, 
        webhook_url: webhook_url, 
        webhook_method: webhook_method, 
    )
end

#urlString

Returns The absolute URL of the Webhook resource.

Returns:

  • (String)

    The absolute URL of the Webhook resource.



317
318
319
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 317

def url
    @properties['url']
end

#webhook_methodString

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

Returns:

  • (String)

    The method used when calling the webhook’s URL.



371
372
373
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 371

def webhook_method
    @properties['webhook_method']
end

#webhook_urlString

Returns The URL associated with this Webhook.

Returns:

  • (String)

    The URL associated with this Webhook.



365
366
367
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 365

def webhook_url
    @properties['webhook_url']
end