Class: Twilio::REST::Conversations::V1::ConversationContext::WebhookInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/conversations/v1/conversation/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, conversation_sid: nil, sid: nil) ⇒ WebhookInstance

Initialize the WebhookInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • conversation_sid (String) (defaults to: nil)

    The unique id of the [Conversation](www.twilio.com/docs/conversations/api/conversation-resource) for this webhook.

  • sid (String) (defaults to: nil)

    A 34 character string that uniquely identifies this resource.



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

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

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'account_sid' => payload['account_sid'],
      'conversation_sid' => payload['conversation_sid'],
      'target' => payload['target'],
      'url' => payload['url'],
      'configuration' => payload['configuration'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
  }

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

Instance Method Details

#account_sidString

Returns The unique id of the Account responsible for this conversation.

Returns:

  • (String)

    The unique id of the Account responsible for this conversation.



320
321
322
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 320

def 
  @properties['account_sid']
end

#configurationHash

Returns The configuration of this webhook.

Returns:

  • (Hash)

    The configuration of this webhook.



344
345
346
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 344

def configuration
  @properties['configuration']
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:



305
306
307
308
309
310
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 305

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

#conversation_sidString

Returns The unique id of the Conversation for this webhook.

Returns:

  • (String)

    The unique id of the Conversation for this webhook.



326
327
328
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 326

def conversation_sid
  @properties['conversation_sid']
end

#date_createdTime

Returns The date that this resource was created.

Returns:

  • (Time)

    The date that this resource was created.



350
351
352
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 350

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date that this resource was last updated.

Returns:

  • (Time)

    The date that this resource was last updated.



356
357
358
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 356

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Delete the WebhookInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



393
394
395
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 393

def delete
  context.delete
end

#fetchWebhookInstance

Fetch the WebhookInstance

Returns:



363
364
365
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 363

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



406
407
408
409
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 406

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

#sidString

Returns A 34 character string that uniquely identifies this resource.

Returns:

  • (String)

    A 34 character string that uniquely identifies this resource.



314
315
316
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 314

def sid
  @properties['sid']
end

#targetString

Returns The target of this webhook.

Returns:

  • (String)

    The target of this webhook.



332
333
334
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 332

def target
  @properties['target']
end

#to_sObject

Provide a user friendly representation



399
400
401
402
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 399

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

#update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset) ⇒ WebhookInstance

Update the WebhookInstance

Parameters:

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

    The absolute url the webhook request should be sent to.

  • configuration_method (webhook.Method) (defaults to: :unset)

    The HTTP method to be used when sending a webhook request.

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

    The list of events, firing webhook event for this Conversation.

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

    The list of keywords, firing webhook event for this Conversation.

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

    The studio flow sid, where the webhook should be sent to.

Returns:



380
381
382
383
384
385
386
387
388
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 380

def update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset)
  context.update(
      configuration_url: configuration_url,
      configuration_method: configuration_method,
      configuration_filters: configuration_filters,
      configuration_triggers: configuration_triggers,
      configuration_flow_sid: configuration_flow_sid,
  )
end

#urlString

Returns An absolute URL for this webhook.

Returns:

  • (String)

    An absolute URL for this webhook.



338
339
340
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 338

def url
  @properties['url']
end