Class: Twilio::REST::Chat::V2::ServiceContext::ChannelContext::WebhookContext
- Inherits:
-
InstanceContext
- Object
- InstanceContext
- Twilio::REST::Chat::V2::ServiceContext::ChannelContext::WebhookContext
- Defined in:
- lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb
Instance Method Summary collapse
-
#delete ⇒ Boolean
Delete the WebhookInstance.
-
#delete_with_metadata ⇒ Boolean
Delete the WebhookInstanceMetadata.
-
#fetch ⇒ WebhookInstance
Fetch the WebhookInstance.
-
#fetch_with_metadata ⇒ WebhookInstance
Fetch the WebhookInstanceMetadata.
-
#initialize(version, service_sid, channel_sid, sid) ⇒ WebhookContext
constructor
Initialize the WebhookContext.
-
#inspect ⇒ Object
Provide a detailed, user friendly representation.
-
#to_s ⇒ Object
Provide a user friendly representation.
-
#update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_retry_count: :unset) ⇒ WebhookInstance
Update the WebhookInstance.
-
#update_with_metadata(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_retry_count: :unset) ⇒ WebhookInstance
Update the WebhookInstanceMetadata.
Constructor Details
#initialize(version, service_sid, channel_sid, sid) ⇒ WebhookContext
Initialize the WebhookContext
268 269 270 271 272 273 274 275 276 277 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 268 def initialize(version, service_sid, channel_sid, sid) super(version) # Path Solution @solution = { service_sid: service_sid, channel_sid: channel_sid, sid: sid, } @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:channel_sid]}/Webhooks/#{@solution[:sid]}" end |
Instance Method Details
#delete ⇒ Boolean
Delete the WebhookInstance
281 282 283 284 285 286 287 288 289 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 281 def delete headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) @version.delete('DELETE', @uri, headers: headers) end |
#delete_with_metadata ⇒ Boolean
Delete the WebhookInstanceMetadata
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 294 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 |
#fetch ⇒ WebhookInstance
Fetch the WebhookInstance
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 313 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], channel_sid: @solution[:channel_sid], sid: @solution[:sid], ) end |
#fetch_with_metadata ⇒ WebhookInstance
Fetch the WebhookInstanceMetadata
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 334 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], channel_sid: @solution[:channel_sid], sid: @solution[:sid], ) WebhookInstanceMetadata.new( @version, webhook_instance, response.headers, response.status_code ) end |
#inspect ⇒ Object
Provide a detailed, user friendly representation
460 461 462 463 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 460 def inspect context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.Chat.V2.WebhookContext #{context}>" end |
#to_s ⇒ Object
Provide a user friendly representation
453 454 455 456 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 453 def to_s context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.Chat.V2.WebhookContext #{context}>" end |
#update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_retry_count: :unset) ⇒ WebhookInstance
Update the WebhookInstance
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 367 def update( configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_retry_count: :unset ) data = Twilio::Values.of({ 'Configuration.Url' => configuration_url, 'Configuration.Method' => configuration_method, 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e }, 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e }, 'Configuration.FlowSid' => configuration_flow_sid, 'Configuration.RetryCount' => configuration_retry_count, }) 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], channel_sid: @solution[:channel_sid], sid: @solution[:sid], ) end |
#update_with_metadata(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_retry_count: :unset) ⇒ WebhookInstance
Update the WebhookInstanceMetadata
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb', line 410 def ( configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_retry_count: :unset ) data = Twilio::Values.of({ 'Configuration.Url' => configuration_url, 'Configuration.Method' => configuration_method, 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e }, 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e }, 'Configuration.FlowSid' => configuration_flow_sid, 'Configuration.RetryCount' => configuration_retry_count, }) 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], channel_sid: @solution[:channel_sid], sid: @solution[:sid], ) WebhookInstanceMetadata.new( @version, webhook_instance, response.headers, response.status_code ) end |