Class: Twilio::REST::Notify::V1::ServiceContext::BindingInstance

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, service_sid: nil, sid: nil) ⇒ BindingInstance

Initialize the BindingInstance

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 Binding resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 289

def initialize(version, payload , service_sid: nil, sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'sid' => payload['sid'],
        'account_sid' => payload['account_sid'],
        'service_sid' => payload['service_sid'],
        'credential_sid' => payload['credential_sid'],
        'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
        'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
        'notification_protocol_version' => payload['notification_protocol_version'],
        'endpoint' => payload['endpoint'],
        'identity' => payload['identity'],
        'binding_type' => payload['binding_type'],
        'address' => payload['address'],
        'tags' => payload['tags'],
        'url' => payload['url'],
        'links' => payload['links'],
    }

    # Context
    @instance_context = nil
    @params = { 'service_sid' => service_sid  || @properties['service_sid']  ,'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 Binding resource.

Returns:



334
335
336
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 334

def 
    @properties['account_sid']
end

#addressString

Returns The channel-specific address. For APNS, the device token. For FCM and GCM, the registration token. For SMS, a phone number in E.164 format. For Facebook Messenger, the Messenger ID of the user or a phone number in E.164 format.

Returns:

  • (String)

    The channel-specific address. For APNS, the device token. For FCM and GCM, the registration token. For SMS, a phone number in E.164 format. For Facebook Messenger, the Messenger ID of the user or a phone number in E.164 format.



388
389
390
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 388

def address
    @properties['address']
end

#binding_typeString

Returns The transport technology to use for the Binding. Can be: ‘apn`, `fcm`, `gcm`, `sms`, or `facebook-messenger`.

Returns:

  • (String)

    The transport technology to use for the Binding. Can be: ‘apn`, `fcm`, `gcm`, `sms`, or `facebook-messenger`.



382
383
384
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 382

def binding_type
    @properties['binding_type']
end

#contextBindingContext

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

Returns:



319
320
321
322
323
324
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 319

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

#credential_sidString

Returns The SID of the [Credential](www.twilio.com/docs/notify/api/credential-resource) resource to be used to send notifications to this Binding. If present, this overrides the Credential specified in the Service resource. Applicable only to ‘apn`, `fcm`, and `gcm` type Bindings.

Returns:

  • (String)

    The SID of the [Credential](www.twilio.com/docs/notify/api/credential-resource) resource to be used to send notifications to this Binding. If present, this overrides the Credential specified in the Service resource. Applicable only to ‘apn`, `fcm`, and `gcm` type Bindings.



346
347
348
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 346

def credential_sid
    @properties['credential_sid']
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:



352
353
354
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 352

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:



358
359
360
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 358

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the BindingInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



413
414
415
416
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 413

def delete

    context.delete
end

#endpointString

Returns Deprecated.

Returns:

  • (String)

    Deprecated.



370
371
372
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 370

def endpoint
    @properties['endpoint']
end

#fetchBindingInstance

Fetch the BindingInstance

Returns:



421
422
423
424
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 421

def fetch

    context.fetch
end

#identityString

Returns The ‘identity` value that uniquely identifies the resource’s [User](www.twilio.com/docs/chat/rest/user-resource) within the [Service](www.twilio.com/docs/notify/api/service-resource). Up to 20 Bindings can be created for the same Identity in a given Service.

Returns:



376
377
378
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 376

def identity
    @properties['identity']
end

#inspectObject

Provide a detailed, user friendly representation



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

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

Returns The URLs of related resources.

Returns:

  • (Hash)

    The URLs of related resources.



406
407
408
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 406

def links
    @properties['links']
end

#notification_protocol_versionString

Returns The protocol version to use to send the notification. This defaults to the value of ‘default_xxxx_notification_protocol_version` in the [Service](www.twilio.com/docs/notify/api/service-resource) for the protocol. The current version is `"3"` for `apn`, `fcm`, and `gcm` type Bindings. The parameter is not applicable to `sms` and `facebook-messenger` type Bindings as the data format is fixed.

Returns:

  • (String)

    The protocol version to use to send the notification. This defaults to the value of ‘default_xxxx_notification_protocol_version` in the [Service](www.twilio.com/docs/notify/api/service-resource) for the protocol. The current version is `"3"` for `apn`, `fcm`, and `gcm` type Bindings. The parameter is not applicable to `sms` and `facebook-messenger` type Bindings as the data format is fixed.



364
365
366
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 364

def notification_protocol_version
    @properties['notification_protocol_version']
end

#service_sidString

Returns The SID of the [Service](www.twilio.com/docs/notify/api/service-resource) the resource is associated with.

Returns:



340
341
342
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 340

def service_sid
    @properties['service_sid']
end

#sidString

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

Returns:

  • (String)

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



328
329
330
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 328

def sid
    @properties['sid']
end

#tagsArray<String>

Returns The list of tags associated with this Binding. Tags can be used to select the Bindings to use when sending a notification. Maximum 20 tags are allowed.

Returns:

  • (Array<String>)

    The list of tags associated with this Binding. Tags can be used to select the Bindings to use when sending a notification. Maximum 20 tags are allowed.



394
395
396
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 394

def tags
    @properties['tags']
end

#to_sObject

Provide a user friendly representation



428
429
430
431
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 428

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

#urlString

Returns The absolute URL of the Binding resource.

Returns:

  • (String)

    The absolute URL of the Binding resource.



400
401
402
# File 'lib/twilio-ruby/rest/notify/v1/service/binding.rb', line 400

def url
    @properties['url']
end