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

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/events/v1/subscription.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) ⇒ SubscriptionInstance

Initialize the SubscriptionInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • sid (String) (defaults to: nil)

    A 34 character string that uniquely identifies this Subscription.


269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 269

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 Account SID.

Returns:

  • (String)

    Account SID.


302
303
304
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 302

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:


293
294
295
296
297
298
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 293

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

#date_createdTime

Returns The date this Subscription was created.

Returns:

  • (Time)

    The date this Subscription was created


314
315
316
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 314

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date this Subscription was updated.

Returns:

  • (Time)

    The date this Subscription was updated


320
321
322
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 320

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Delete the SubscriptionInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


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

def delete
  context.delete
end

#descriptionString

Returns Subscription description.

Returns:

  • (String)

    Subscription description


326
327
328
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 326

def description
  @properties['description']
end

#fetchSubscriptionInstance

Fetch the SubscriptionInstance

Returns:


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

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation


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

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

Returns Nested resource URLs.

Returns:

  • (String)

    Nested resource URLs.


344
345
346
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 344

def links
  @properties['links']
end

#sidString

Returns A string that uniquely identifies this Subscription.

Returns:

  • (String)

    A string that uniquely identifies this Subscription.


308
309
310
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 308

def sid
  @properties['sid']
end

#sink_sidString

Returns Sink SID.

Returns:

  • (String)

    Sink SID.


332
333
334
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 332

def sink_sid
  @properties['sink_sid']
end

#subscribed_eventssubscribed_events

Access the subscribed_events

Returns:


376
377
378
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 376

def subscribed_events
  context.subscribed_events
end

#to_sObject

Provide a user friendly representation


382
383
384
385
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 382

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:


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

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.


338
339
340
# File 'lib/twilio-ruby/rest/events/v1/subscription.rb', line 338

def url
  @properties['url']
end