class Twilio::REST::Chat::V2::ServiceContext::ChannelContext::WebhookContext
Public Class Methods
Initialize the WebhookContext
@param [Version] version Version
that contains the resource @param [String] service_sid The SID of the
{Service}[https://www.twilio.com/docs/chat/rest/service-resource] with the Channel to fetch the Webhook resource from.
@param [String] channel_sid The SID of the
{Channel}[https://www.twilio.com/docs/chat/channels] the Channel Webhook resource to fetch belongs to. This value can be the Channel resource's `sid` or `unique_name`.
@param [String] sid The SID of the Channel Webhook resource to fetch. @return [WebhookContext] WebhookContext
Twilio::REST::InstanceContext::new
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 214 def initialize(version, service_sid, channel_sid, sid) 215 super(version) 216 217 # Path Solution 218 @solution = {service_sid: service_sid, channel_sid: channel_sid, sid: sid, } 219 @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:channel_sid]}/Webhooks/#{@solution[:sid]}" 220 end
Public Instance Methods
Delete the WebhookInstance
@return [Boolean] true if delete succeeds, false otherwise
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 284 def delete 285 @version.delete('DELETE', @uri) 286 end
Fetch the WebhookInstance
@return [WebhookInstance] Fetched WebhookInstance
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 225 def fetch 226 payload = @version.fetch('GET', @uri) 227 228 WebhookInstance.new( 229 @version, 230 payload, 231 service_sid: @solution[:service_sid], 232 channel_sid: @solution[:channel_sid], 233 sid: @solution[:sid], 234 ) 235 end
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 297 def inspect 298 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 299 "#<Twilio.Chat.V2.WebhookContext #{context}>" 300 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb 290 def to_s 291 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 292 "#<Twilio.Chat.V2.WebhookContext #{context}>" 293 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 260 def update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_retry_count: :unset) 261 data = Twilio::Values.of({ 262 'Configuration.Url' => configuration_url, 263 'Configuration.Method' => configuration_method, 264 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e }, 265 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e }, 266 'Configuration.FlowSid' => configuration_flow_sid, 267 'Configuration.RetryCount' => configuration_retry_count, 268 }) 269 270 payload = @version.update('POST', @uri, data: data) 271 272 WebhookInstance.new( 273 @version, 274 payload, 275 service_sid: @solution[:service_sid], 276 channel_sid: @solution[:channel_sid], 277 sid: @solution[:sid], 278 ) 279 end