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

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

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

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

  • sid (String) (defaults to: nil)

    The sid



389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 389

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'],
  }

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

Instance Method Details

#account_sidString

Returns The account_sid.

Returns:

  • (String)

    The account_sid



438
439
440
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 438

def 
  @properties['account_sid']
end

#alexa_skill_idString

Returns The alexa_skill_id.

Returns:

  • (String)

    The alexa_skill_id



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

def alexa_skill_id
  @properties['alexa_skill_id']
end

#apn_credential_sidString

Returns The SID of the Credential to be used for APN Bindings.

Returns:

  • (String)

    The SID of the Credential to be used for APN Bindings.



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

def apn_credential_sid
  @properties['apn_credential_sid']
end

#bindingsbindings

Access the bindings

Returns:



602
603
604
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 602

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:



423
424
425
426
427
428
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 423

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

#date_createdTime

Returns The date_created.

Returns:

  • (Time)

    The date_created



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

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date_updated.

Returns:

  • (Time)

    The date_updated



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

def date_updated
  @properties['date_updated']
end

#default_alexa_notification_protocol_versionString

Returns The default_alexa_notification_protocol_version.

Returns:

  • (String)

    The default_alexa_notification_protocol_version



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

def default_alexa_notification_protocol_version
  @properties['default_alexa_notification_protocol_version']
end

#default_apn_notification_protocol_versionString

Returns The version of the protocol to be used for sending APNS notifications.

Returns:

  • (String)

    The version of the protocol to be used for sending APNS notifications.



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

def default_apn_notification_protocol_version
  @properties['default_apn_notification_protocol_version']
end

#default_fcm_notification_protocol_versionString

Returns The version of the protocol to be used for sending FCM notifications.

Returns:

  • (String)

    The version of the protocol to be used for sending FCM notifications.



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

def default_fcm_notification_protocol_version
  @properties['default_fcm_notification_protocol_version']
end

#default_gcm_notification_protocol_versionString

Returns The version of the protocol to be used for sending GCM notifications.

Returns:

  • (String)

    The version of the protocol to be used for sending GCM notifications.



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

def default_gcm_notification_protocol_version
  @properties['default_gcm_notification_protocol_version']
end

#deleteBoolean

Deletes the ServiceInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



541
542
543
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 541

def delete
  context.delete
end

#facebook_messenger_page_idString

Returns The Page ID to be used to send for Facebook Messenger Bindings.

Returns:

  • (String)

    The Page ID to be used to send for Facebook Messenger Bindings.



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

def facebook_messenger_page_id
  @properties['facebook_messenger_page_id']
end

#fcm_credential_sidString

Returns The SID of the Credential to be used for FCM Bindings.

Returns:

  • (String)

    The SID of the Credential to be used for FCM Bindings.



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

def fcm_credential_sid
  @properties['fcm_credential_sid']
end

#fetchServiceInstance

Fetch a ServiceInstance

Returns:



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

def fetch
  context.fetch
end

#friendly_nameString

Returns Human-readable name for this service instance.

Returns:

  • (String)

    Human-readable name for this service instance



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

def friendly_name
  @properties['friendly_name']
end

#gcm_credential_sidString

Returns The SID of the Credential to be used for GCM Bindings.

Returns:

  • (String)

    The SID of the Credential to be used for GCM Bindings.



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

def gcm_credential_sid
  @properties['gcm_credential_sid']
end

#inspectObject

Provide a detailed, user friendly representation



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

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

Returns The links.

Returns:

  • (String)

    The links



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

def links
  @properties['links']
end

#log_enabledBoolean

Returns The log_enabled.

Returns:

  • (Boolean)

    The log_enabled



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

def log_enabled
  @properties['log_enabled']
end

#messaging_service_sidString

Returns The SID of the Messaging Service to be used for SMS Bindings.

Returns:

  • (String)

    The SID of the Messaging Service to be used for SMS Bindings.



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

def messaging_service_sid
  @properties['messaging_service_sid']
end

#notificationsnotifications

Access the notifications

Returns:



609
610
611
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 609

def notifications
  context.notifications
end

#segmentssegments

Access the segments

Returns:



623
624
625
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 623

def segments
  context.segments
end

#sidString

Returns The sid.

Returns:

  • (String)

    The sid



432
433
434
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 432

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation



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

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) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

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

    Human-readable name for this service instance

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

    The SID of the default Credential to be used for APN Bindings

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

    The SID of the default Credential to be used for GCM Bindings

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

    The SID of the [Messaging Service](www.twilio.com/docs/api/rest/sending-messages#messaging-services) to be used for SMS Bindings. In order to send SMS notifications this parameter has to be set.

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

    The Page ID to be used to send for Facebook Messenger Bindings. It has to match the Page ID you configured when you [enabled Facebook Messaging](www.twilio.com/console/sms/settings) on your account. Facebook Messenger integration is in beta. You need to be in the beta program to be able to enable Facebook Messaging for your account.

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

    The version of the protocol to be used for sending APNS notifications. Can be overriden on a Binding by Binding basis when creating a Binding resource.

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

    The version of the protocol to be used for sending GCM notifications. Can be overriden on a Binding by Binding basis when creating a Binding resource.

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

    The SID of the default Credential to be used for FCM Bindings

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

    The version of the protocol to be used for sending FCM notifications. Can be overriden on a Binding by Binding basis when creating a Binding resource.

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

    The log_enabled

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

    The alexa_skill_id

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

    The default_alexa_notification_protocol_version

Returns:



582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 582

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)
  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,
  )
end

#urlString

Returns The url.

Returns:

  • (String)

    The url



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

def url
  @properties['url']
end

#usersusers

Access the users

Returns:



616
617
618
# File 'lib/twilio-ruby/rest/notify/v1/service.rb', line 616

def users
  context.users
end