Class: Twilio::REST::Events::V1::SubscriptionContext::SubscribedEventInstance

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, subscription_sid: nil, type: nil) ⇒ SubscribedEventInstance

Initialize the SubscribedEventInstance

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

  • sid (String)

    The SID of the Call resource to fetch.



290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 290

def initialize(version, payload , subscription_sid: nil, type: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'account_sid' => payload['account_sid'],
        'type' => payload['type'],
        'schema_version' => payload['schema_version'] == nil ? payload['schema_version'] : payload['schema_version'].to_i,
        'subscription_sid' => payload['subscription_sid'],
        'url' => payload['url'],
    }

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

Instance Method Details

#account_sidString

Returns The unique SID identifier of the Account.

Returns:

  • (String)

    The unique SID identifier of the Account.



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

def 
    @properties['account_sid']
end

#contextSubscribedEventContext

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

Returns:



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

def context
    unless @instance_context
        @instance_context = SubscribedEventContext.new(@version , @params['subscription_sid'], @params['type'])
    end
    @instance_context
end

#deleteBoolean

Delete the SubscribedEventInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



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

def delete

    context.delete
end

#fetchSubscribedEventInstance

Fetch the SubscribedEventInstance

Returns:



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

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



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

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

#schema_versionString

Returns The schema version that the Subscription should use.

Returns:

  • (String)

    The schema version that the Subscription should use.



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

def schema_version
    @properties['schema_version']
end

#subscription_sidString

Returns The unique SID identifier of the Subscription.

Returns:

  • (String)

    The unique SID identifier of the Subscription.



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

def subscription_sid
    @properties['subscription_sid']
end

#to_sObject

Provide a user friendly representation



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

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

#typeString

Returns Type of event being subscribed to.

Returns:

  • (String)

    Type of event being subscribed to.



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

def type
    @properties['type']
end

#update(schema_version: :unset) ⇒ SubscribedEventInstance

Update the SubscribedEventInstance

Parameters:

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

    The schema version that the Subscription should use.

Returns:



368
369
370
371
372
373
374
375
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 368

def update(
    schema_version: :unset
)

    context.update(
        schema_version: schema_version, 
    )
end

#urlString

Returns The URL of this resource.

Returns:

  • (String)

    The URL of this resource.



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

def url
    @properties['url']
end