Class: Twilio::REST::Notify::V1::ServiceInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/notify/v1/service.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, sid: nil) ⇒ ServiceInstance

Initialize the ServiceInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String)

    The SID of the Account that created this Service resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 397

def initialize(version, payload , sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'sid' => payload['sid'],
        'account_sid' => payload['account_sid'],
        'friendly_name' => payload['friendly_name'],
        'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
        'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
        'apn_credential_sid' => payload['apn_credential_sid'],
        'gcm_credential_sid' => payload['gcm_credential_sid'],
        'fcm_credential_sid' => payload['fcm_credential_sid'],
        'messaging_service_sid' => payload['messaging_service_sid'],
        'facebook_messenger_page_id' => payload['facebook_messenger_page_id'],
        'default_apn_notification_protocol_version' => payload['default_apn_notification_protocol_version'],
        'default_gcm_notification_protocol_version' => payload['default_gcm_notification_protocol_version'],
        'default_fcm_notification_protocol_version' => payload['default_fcm_notification_protocol_version'],
        'log_enabled' => payload['log_enabled'],
        'url' => payload['url'],
        'links' => payload['links'],
        'alexa_skill_id' => payload['alexa_skill_id'],
        'default_alexa_notification_protocol_version' => payload['default_alexa_notification_protocol_version'],
        'delivery_callback_url' => payload['delivery_callback_url'],
        'delivery_callback_enabled' => payload['delivery_callback_enabled'],
    }

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

Instance Method Details

#account_sidString

Returns The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the Service resource.

Returns:



448
449
450
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 448

def 
    @properties['account_sid']
end

#alexa_skill_idString

Returns Deprecated.

Returns:

  • (String)

    Deprecated.



538
539
540
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 538

def alexa_skill_id
    @properties['alexa_skill_id']
end

#apn_credential_sidString

Returns The SID of the [Credential](www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings.

Returns:



472
473
474
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 472

def apn_credential_sid
    @properties['apn_credential_sid']
end

#bindingsbindings

Access the bindings

Returns:



638
639
640
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 638

def bindings
    context.bindings
end

#contextServiceContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



433
434
435
436
437
438
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 433

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

#date_createdTime

Returns The date and time in GMT when the resource was created specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



460
461
462
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 460

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns The date and time in GMT when the resource was last updated specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



466
467
468
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 466

def date_updated
    @properties['date_updated']
end

#default_alexa_notification_protocol_versionString

Returns Deprecated.

Returns:

  • (String)

    Deprecated.



544
545
546
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 544

def default_alexa_notification_protocol_version
    @properties['default_alexa_notification_protocol_version']
end

#default_apn_notification_protocol_versionString

Returns The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](www.twilio.com/docs/notify/api/binding-resource) resource.

Returns:



502
503
504
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 502

def default_apn_notification_protocol_version
    @properties['default_apn_notification_protocol_version']
end

#default_fcm_notification_protocol_versionString

Returns The protocol version to use for sending FCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](www.twilio.com/docs/notify/api/binding-resource) resource.

Returns:



514
515
516
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 514

def default_fcm_notification_protocol_version
    @properties['default_fcm_notification_protocol_version']
end

#default_gcm_notification_protocol_versionString

Returns The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](www.twilio.com/docs/notify/api/binding-resource) resource.

Returns:



508
509
510
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 508

def default_gcm_notification_protocol_version
    @properties['default_gcm_notification_protocol_version']
end

#deleteBoolean

Delete the ServiceInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



563
564
565
566
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 563

def delete

    context.delete
end

#delivery_callback_enabledBoolean

Returns Callback configuration that enables delivery callbacks, default false.

Returns:

  • (Boolean)

    Callback configuration that enables delivery callbacks, default false



556
557
558
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 556

def delivery_callback_enabled
    @properties['delivery_callback_enabled']
end

#delivery_callback_urlString

Returns URL to send delivery status callback.

Returns:

  • (String)

    URL to send delivery status callback.



550
551
552
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 550

def delivery_callback_url
    @properties['delivery_callback_url']
end

#facebook_messenger_page_idString

Returns Deprecated.

Returns:

  • (String)

    Deprecated.



496
497
498
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 496

def facebook_messenger_page_id
    @properties['facebook_messenger_page_id']
end

#fcm_credential_sidString

Returns The SID of the [Credential](www.twilio.com/docs/notify/api/credential-resource) to use for FCM Bindings.

Returns:



484
485
486
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 484

def fcm_credential_sid
    @properties['fcm_credential_sid']
end

#fetchServiceInstance

Fetch the ServiceInstance

Returns:



571
572
573
574
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 571

def fetch

    context.fetch
end

#friendly_nameString

Returns The string that you assigned to describe the resource.

Returns:

  • (String)

    The string that you assigned to describe the resource.



454
455
456
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 454

def friendly_name
    @properties['friendly_name']
end

#gcm_credential_sidString

Returns The SID of the [Credential](www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings.

Returns:



478
479
480
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 478

def gcm_credential_sid
    @properties['gcm_credential_sid']
end

#inspectObject

Provide a detailed, user friendly representation



651
652
653
654
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 651

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

Returns The URLs of the Binding, Notification, Segment, and User resources related to the service.

Returns:

  • (Hash)

    The URLs of the Binding, Notification, Segment, and User resources related to the service.



532
533
534
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 532

def links
    @properties['links']
end

#log_enabledBoolean

Returns Whether to log notifications. Can be: ‘true` or `false` and the default is `true`.

Returns:

  • (Boolean)

    Whether to log notifications. Can be: ‘true` or `false` and the default is `true`.



520
521
522
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 520

def log_enabled
    @properties['log_enabled']
end

#messaging_service_sidString

Returns The SID of the [Messaging Service](www.twilio.com/docs/sms/quickstart#messaging-services) to use for SMS Bindings. In order to send SMS notifications this parameter has to be set.

Returns:



490
491
492
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 490

def messaging_service_sid
    @properties['messaging_service_sid']
end

#notificationsnotifications

Access the notifications

Returns:



631
632
633
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 631

def notifications
    context.notifications
end

#sidString

Returns The unique string that we created to identify the Service resource.

Returns:

  • (String)

    The unique string that we created to identify the Service resource.



442
443
444
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 442

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



644
645
646
647
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 644

def to_s
    values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Notify.V1.ServiceInstance #{values}>"
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

Parameters:

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

    A descriptive string that you create to describe the resource. It can be up to 64 characters long.

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

    The SID of the [Credential](www.twilio.com/docs/notify/api/credential-resource) to use for APN Bindings.

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

    The SID of the [Credential](www.twilio.com/docs/notify/api/credential-resource) to use for GCM Bindings.

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

    The SID of the [Messaging Service](www.twilio.com/docs/sms/quickstart#messaging-services) to use for SMS Bindings. This parameter must be set in order to send SMS notifications.

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

    Deprecated.

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

    The protocol version to use for sending APNS notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](www.twilio.com/docs/notify/api/binding-resource) resource.

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

    The protocol version to use for sending GCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](www.twilio.com/docs/notify/api/binding-resource) resource.

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

    The SID of the [Credential](www.twilio.com/docs/notify/api/credential-resource) to use for FCM Bindings.

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

    The protocol version to use for sending FCM notifications. Can be overridden on a Binding by Binding basis when creating a [Binding](www.twilio.com/docs/notify/api/binding-resource) resource.

  • log_enabled (Boolean) (defaults to: :unset)

    Whether to log notifications. Can be: ‘true` or `false` and the default is `true`.

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

    Deprecated.

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

    Deprecated.

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

    URL to send delivery status callback.

  • delivery_callback_enabled (Boolean) (defaults to: :unset)

    Callback configuration that enables delivery callbacks, default false

Returns:



593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 593

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
)

    context.update(
        friendly_name: friendly_name, 
        apn_credential_sid: apn_credential_sid, 
        gcm_credential_sid: gcm_credential_sid, 
        messaging_service_sid: messaging_service_sid, 
        facebook_messenger_page_id: facebook_messenger_page_id, 
        default_apn_notification_protocol_version: default_apn_notification_protocol_version, 
        default_gcm_notification_protocol_version: default_gcm_notification_protocol_version, 
        fcm_credential_sid: fcm_credential_sid, 
        default_fcm_notification_protocol_version: default_fcm_notification_protocol_version, 
        log_enabled: log_enabled, 
        alexa_skill_id: alexa_skill_id, 
        default_alexa_notification_protocol_version: default_alexa_notification_protocol_version, 
        delivery_callback_url: delivery_callback_url, 
        delivery_callback_enabled: delivery_callback_enabled, 
    )
end

#urlString

Returns The absolute URL of the Service resource.

Returns:

  • (String)

    The absolute URL of the Service resource.



526
527
528
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 526

def url
    @properties['url']
end