Class: Twilio::REST::Notify::V1::ServiceContext
- Inherits:
-
InstanceContext
- Object
- InstanceContext
- Twilio::REST::Notify::V1::ServiceContext
- Defined in:
- lib/twilio-ruby/rest/notify/v1/service.rb,
lib/twilio-ruby/rest/notify/v1/service/binding.rb,
lib/twilio-ruby/rest/notify/v1/service/notification.rb
Defined Under Namespace
Classes: BindingContext, BindingInstance, BindingInstanceMetadata, BindingList, BindingListResponse, BindingPage, BindingPageMetadata, NotificationInstance, NotificationList, NotificationListResponse, NotificationPage, NotificationPageMetadata
Instance Method Summary collapse
-
#bindings(sid = :unset) ⇒ BindingList, BindingContext
Access the bindings.
-
#delete ⇒ Boolean
Delete the ServiceInstance.
-
#delete_with_metadata ⇒ Boolean
Delete the ServiceInstanceMetadata.
-
#fetch ⇒ ServiceInstance
Fetch the ServiceInstance.
-
#fetch_with_metadata ⇒ ServiceInstance
Fetch the ServiceInstanceMetadata.
-
#initialize(version, sid) ⇒ ServiceContext
constructor
Initialize the ServiceContext.
-
#inspect ⇒ Object
Provide a detailed, user friendly representation.
-
#notifications ⇒ NotificationList, NotificationContext
Access the notifications.
-
#to_s ⇒ Object
Provide a user friendly representation.
-
#update(friendly_name: :unset, apn_credential_sid: :unset, gcm_credential_sid: :unset, messaging_service_sid: :unset, facebook_messenger_page_id: :unset, default_apn_notification_protocol_version: :unset, default_gcm_notification_protocol_version: :unset, fcm_credential_sid: :unset, default_fcm_notification_protocol_version: :unset, log_enabled: :unset, alexa_skill_id: :unset, default_alexa_notification_protocol_version: :unset, delivery_callback_url: :unset, delivery_callback_enabled: :unset) ⇒ ServiceInstance
Update the ServiceInstance.
-
#update_with_metadata(friendly_name: :unset, apn_credential_sid: :unset, gcm_credential_sid: :unset, messaging_service_sid: :unset, facebook_messenger_page_id: :unset, default_apn_notification_protocol_version: :unset, default_gcm_notification_protocol_version: :unset, fcm_credential_sid: :unset, default_fcm_notification_protocol_version: :unset, log_enabled: :unset, alexa_skill_id: :unset, default_alexa_notification_protocol_version: :unset, delivery_callback_url: :unset, delivery_callback_enabled: :unset) ⇒ ServiceInstance
Update the ServiceInstanceMetadata.
Constructor Details
#initialize(version, sid) ⇒ ServiceContext
Initialize the ServiceContext
301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 301 def initialize(version, sid) super(version) # Path Solution @solution = { sid: sid, } @uri = "/Services/#{@solution[:sid]}" # Dependents @notifications = nil @bindings = nil end |
Instance Method Details
#bindings(sid = :unset) ⇒ BindingList, BindingContext
Access the bindings
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 540 def bindings(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return BindingContext.new(@version, @solution[:sid],sid ) end unless @bindings @bindings = BindingList.new( @version, service_sid: @solution[:sid], ) end @bindings end |
#delete ⇒ Boolean
Delete the ServiceInstance
316 317 318 319 320 321 322 323 324 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 316 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 ServiceInstanceMetadata
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 329 def headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) response = @version.('DELETE', @uri, headers: headers) service_instance = ServiceInstance.new( @version, response.body, account_sid: @solution[:account_sid], sid: @solution[:sid], ) ServiceInstanceMetadata.new(@version, service_instance, response.headers, response.status_code) end |
#fetch ⇒ ServiceInstance
Fetch the ServiceInstance
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 348 def fetch headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) payload = @version.fetch('GET', @uri, headers: headers) ServiceInstance.new( @version, payload, sid: @solution[:sid], ) end |
#fetch_with_metadata ⇒ ServiceInstance
Fetch the ServiceInstanceMetadata
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 367 def headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) response = @version.('GET', @uri, headers: headers) service_instance = ServiceInstance.new( @version, response.body, sid: @solution[:sid], ) ServiceInstanceMetadata.new( @version, service_instance, response.headers, response.status_code ) end |
#inspect ⇒ Object
Provide a detailed, user friendly representation
565 566 567 568 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 565 def inspect context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.Notify.V1.ServiceContext #{context}>" end |
#notifications ⇒ NotificationList, NotificationContext
Access the notifications
529 530 531 532 533 534 535 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 529 def notifications unless @notifications @notifications = NotificationList.new( @version, service_sid: @solution[:sid], ) end @notifications end |
#to_s ⇒ Object
Provide a user friendly representation
558 559 560 561 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 558 def to_s context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.Notify.V1.ServiceContext #{context}>" end |
#update(friendly_name: :unset, apn_credential_sid: :unset, gcm_credential_sid: :unset, messaging_service_sid: :unset, facebook_messenger_page_id: :unset, default_apn_notification_protocol_version: :unset, default_gcm_notification_protocol_version: :unset, fcm_credential_sid: :unset, default_fcm_notification_protocol_version: :unset, log_enabled: :unset, alexa_skill_id: :unset, default_alexa_notification_protocol_version: :unset, delivery_callback_url: :unset, delivery_callback_enabled: :unset) ⇒ ServiceInstance
Update the ServiceInstance
406 407 408 409 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 449 450 451 452 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 406 def update( friendly_name: :unset, apn_credential_sid: :unset, gcm_credential_sid: :unset, messaging_service_sid: :unset, facebook_messenger_page_id: :unset, default_apn_notification_protocol_version: :unset, default_gcm_notification_protocol_version: :unset, fcm_credential_sid: :unset, default_fcm_notification_protocol_version: :unset, log_enabled: :unset, alexa_skill_id: :unset, default_alexa_notification_protocol_version: :unset, delivery_callback_url: :unset, delivery_callback_enabled: :unset ) data = Twilio::Values.of({ 'FriendlyName' => friendly_name, 'ApnCredentialSid' => apn_credential_sid, 'GcmCredentialSid' => gcm_credential_sid, 'MessagingServiceSid' => messaging_service_sid, 'FacebookMessengerPageId' => facebook_messenger_page_id, 'DefaultApnNotificationProtocolVersion' => default_apn_notification_protocol_version, 'DefaultGcmNotificationProtocolVersion' => default_gcm_notification_protocol_version, 'FcmCredentialSid' => fcm_credential_sid, 'DefaultFcmNotificationProtocolVersion' => default_fcm_notification_protocol_version, 'LogEnabled' => log_enabled, 'AlexaSkillId' => alexa_skill_id, 'DefaultAlexaNotificationProtocolVersion' => default_alexa_notification_protocol_version, 'DeliveryCallbackUrl' => delivery_callback_url, 'DeliveryCallbackEnabled' => delivery_callback_enabled, }) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) payload = @version.update('POST', @uri, data: data, headers: headers) ServiceInstance.new( @version, payload, sid: @solution[:sid], ) end |
#update_with_metadata(friendly_name: :unset, apn_credential_sid: :unset, gcm_credential_sid: :unset, messaging_service_sid: :unset, facebook_messenger_page_id: :unset, default_apn_notification_protocol_version: :unset, default_gcm_notification_protocol_version: :unset, fcm_credential_sid: :unset, default_fcm_notification_protocol_version: :unset, log_enabled: :unset, alexa_skill_id: :unset, default_alexa_notification_protocol_version: :unset, delivery_callback_url: :unset, delivery_callback_enabled: :unset) ⇒ ServiceInstance
Update the ServiceInstanceMetadata
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 |
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 471 def ( friendly_name: :unset, apn_credential_sid: :unset, gcm_credential_sid: :unset, messaging_service_sid: :unset, facebook_messenger_page_id: :unset, default_apn_notification_protocol_version: :unset, default_gcm_notification_protocol_version: :unset, fcm_credential_sid: :unset, default_fcm_notification_protocol_version: :unset, log_enabled: :unset, alexa_skill_id: :unset, default_alexa_notification_protocol_version: :unset, delivery_callback_url: :unset, delivery_callback_enabled: :unset ) data = Twilio::Values.of({ 'FriendlyName' => friendly_name, 'ApnCredentialSid' => apn_credential_sid, 'GcmCredentialSid' => gcm_credential_sid, 'MessagingServiceSid' => messaging_service_sid, 'FacebookMessengerPageId' => facebook_messenger_page_id, 'DefaultApnNotificationProtocolVersion' => default_apn_notification_protocol_version, 'DefaultGcmNotificationProtocolVersion' => default_gcm_notification_protocol_version, 'FcmCredentialSid' => fcm_credential_sid, 'DefaultFcmNotificationProtocolVersion' => default_fcm_notification_protocol_version, 'LogEnabled' => log_enabled, 'AlexaSkillId' => alexa_skill_id, 'DefaultAlexaNotificationProtocolVersion' => default_alexa_notification_protocol_version, 'DeliveryCallbackUrl' => delivery_callback_url, 'DeliveryCallbackEnabled' => delivery_callback_enabled, }) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) response = @version.('POST', @uri, data: data, headers: headers) service_instance = ServiceInstance.new( @version, response.body, sid: @solution[:sid], ) ServiceInstanceMetadata.new( @version, service_instance, response.headers, response.status_code ) end |