class Twilio::REST::Chat::V2::ServiceContext::ChannelContext::WebhookInstance
Public Class Methods
Initialize the WebhookInstance
@param [Version] version Version
that contains the resource @param [Hash] payload payload that contains response from Twilio
@param [String] service_sid
The SID of the
{Service}[https://www.twilio.com/docs/chat/rest/service-resource] the Channel Webhook resource is associated with.
@param [String] channel_sid
The SID of the
{Channel}[https://www.twilio.com/docs/chat/channels] the Channel Webhook resource belongs to.
@param [String] sid The SID of the Channel Webhook resource to fetch. @return [WebhookInstance] WebhookInstance
Twilio::REST::InstanceResource::new
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 316 def initialize(version, payload, service_sid: nil, channel_sid: nil, sid: nil) 317 super(version) 318 319 # Marshaled Properties 320 @properties = { 321 'sid' => payload['sid'], 322 'account_sid' => payload['account_sid'], 323 'service_sid' => payload['service_sid'], 324 'channel_sid' => payload['channel_sid'], 325 'type' => payload['type'], 326 'url' => payload['url'], 327 'configuration' => payload['configuration'], 328 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), 329 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']), 330 } 331 332 # Context 333 @instance_context = nil 334 @params = { 335 'service_sid' => service_sid, 336 'channel_sid' => channel_sid, 337 'sid' => sid || @properties['sid'], 338 } 339 end
Public Instance Methods
@return [String] The SID of the Account that created the resource
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 365 def account_sid 366 @properties['account_sid'] 367 end
@return [String] The SID of the Channel the Channel Webhook resource belongs to
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 377 def channel_sid 378 @properties['channel_sid'] 379 end
@return [Hash] The JSON string that describes the configuration object for the channel webhook
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 395 def configuration 396 @properties['configuration'] 397 end
Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context @return [WebhookContext] WebhookContext
for this WebhookInstance
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 345 def context 346 unless @instance_context 347 @instance_context = WebhookContext.new( 348 @version, 349 @params['service_sid'], 350 @params['channel_sid'], 351 @params['sid'], 352 ) 353 end 354 @instance_context 355 end
@return [Time] The ISO 8601 date and time in GMT when the resource was created
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 401 def date_created 402 @properties['date_created'] 403 end
@return [Time] The ISO 8601 date and time in GMT when the resource was last updated
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 407 def date_updated 408 @properties['date_updated'] 409 end
Delete the WebhookInstance
@return [Boolean] true if delete succeeds, false otherwise
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 455 def delete 456 context.delete 457 end
Fetch the WebhookInstance
@return [WebhookInstance] Fetched WebhookInstance
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 414 def fetch 415 context.fetch 416 end
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 468 def inspect 469 values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") 470 "<Twilio.Chat.V2.WebhookInstance #{values}>" 471 end
@return [String] The SID of the Service that the Channel Webhook resource is associated with
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 371 def service_sid 372 @properties['service_sid'] 373 end
@return [String] The unique string that identifies the resource
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 359 def sid 360 @properties['sid'] 361 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 461 def to_s 462 values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") 463 "<Twilio.Chat.V2.WebhookInstance #{values}>" 464 end
@return [String] The type of webhook
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 383 def type 384 @properties['type'] 385 end
Update the WebhookInstance
@param [String] configuration_url The URL of the webhook to call using the
`configuration.method`.
@param [webhook.Method] configuration_method The HTTP
method used to call
`configuration.url`. Can be: `GET` or `POST` and the default is `POST`.
@param [Array] configuration_filters The events that cause us to call
the Channel Webhook. Used when `type` is `webhook`. This parameter takes only one event. To specify more than one event, repeat this parameter for each event. For the list of possible events, see {Webhook Event Triggers}[https://www.twilio.com/docs/chat/webhook-events#webhook-event-trigger].
@param [Array] configuration_triggers A string that will cause us to
call the webhook when it is present in a message body. This parameter takes only one trigger string. To specify more than one, repeat this parameter for each trigger string up to a total of 5 trigger strings. Used only when `type` = `trigger`.
@param [String] configuration_flow_sid The SID of the Studio
{Flow}[https://www.twilio.com/docs/studio/rest-api/flow] to call when an event in `configuration.filters` occurs. Used only when `type` = `studio`.
@param [String] configuration_retry_count The number of times to retry the
webhook if the first attempt fails. Can be an integer between 0 and 3, inclusive, and the default is 0.
@return [WebhookInstance] Updated WebhookInstance
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 441 def update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_retry_count: :unset) 442 context.update( 443 configuration_url: configuration_url, 444 configuration_method: configuration_method, 445 configuration_filters: configuration_filters, 446 configuration_triggers: configuration_triggers, 447 configuration_flow_sid: configuration_flow_sid, 448 configuration_retry_count: configuration_retry_count, 449 ) 450 end
@return [String] The absolute URL of the Channel Webhook resource
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 389 def url 390 @properties['url'] 391 end