Class: Twilio::REST::Events::V1::SubscriptionInstance

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

Instance Method Summary collapse

Constructor Details

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

Initialize the SubscriptionInstance

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

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 316

def initialize(version, payload , sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'account_sid' => payload['account_sid'],
        'sid' => payload['sid'],
        'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
        'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
        'description' => payload['description'],
        'sink_sid' => payload['sink_sid'],
        'url' => payload['url'],
        'links' => payload['links'],
    }

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

Instance Method Details

#account_sidString

Returns The unique SID identifier of the Account.

Returns:

  • (String)

    The unique SID identifier of the Account.



349
350
351
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 349

def 
    @properties['account_sid']
end

#contextSubscriptionContext

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

Returns:



340
341
342
343
344
345
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 340

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

#date_createdTime

Returns The date that this Subscription was created, given in ISO 8601 format.

Returns:

  • (Time)

    The date that this Subscription was created, given in ISO 8601 format.



361
362
363
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 361

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns The date that this Subscription was updated, given in ISO 8601 format.

Returns:

  • (Time)

    The date that this Subscription was updated, given in ISO 8601 format.



367
368
369
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 367

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the SubscriptionInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



398
399
400
401
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 398

def delete

    context.delete
end

#descriptionString

Returns A human readable description for the Subscription.

Returns:

  • (String)

    A human readable description for the Subscription



373
374
375
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 373

def description
    @properties['description']
end

#fetchSubscriptionInstance

Fetch the SubscriptionInstance

Returns:



406
407
408
409
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 406

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



443
444
445
446
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 443

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

Returns Contains a dictionary of URL links to nested resources of this Subscription.

Returns:

  • (Hash)

    Contains a dictionary of URL links to nested resources of this Subscription.



391
392
393
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 391

def links
    @properties['links']
end

#sidString

Returns A 34 character string that uniquely identifies this Subscription.

Returns:

  • (String)

    A 34 character string that uniquely identifies this Subscription.



355
356
357
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 355

def sid
    @properties['sid']
end

#sink_sidString

Returns The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created.

Returns:

  • (String)

    The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created.



379
380
381
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 379

def sink_sid
    @properties['sink_sid']
end

#subscribed_eventssubscribed_events

Access the subscribed_events

Returns:



430
431
432
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 430

def subscribed_events
    context.subscribed_events
end

#to_sObject

Provide a user friendly representation



436
437
438
439
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 436

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

#update(description: :unset, sink_sid: :unset) ⇒ SubscriptionInstance

Update the SubscriptionInstance

Parameters:

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

    A human readable description for the Subscription.

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

    The SID of the sink that events selected by this subscription should be sent to. Sink must be active for the subscription to be created.

Returns:



416
417
418
419
420
421
422
423
424
425
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 416

def update(
    description: :unset, 
    sink_sid: :unset
)

    context.update(
        description: description, 
        sink_sid: sink_sid, 
    )
end

#urlString

Returns The URL of this resource.

Returns:

  • (String)

    The URL of this resource.



385
386
387
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 385

def url
    @properties['url']
end