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

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.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, 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

  • subscription_sid (String) (defaults to: nil)

    The unique SID identifier of the Subscription.

  • type (String) (defaults to: nil)

    Type of event being subscribed to.


243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 243

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'].to_i,
      'subscription_sid' => payload['subscription_sid'],
      'url' => payload['url'],
  }

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

Instance Method Details

#account_sidString

Returns Account SID.

Returns:

  • (String)

    Account SID.


277
278
279
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 277

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:


264
265
266
267
268
269
270
271
272
273
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 264

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


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

def delete
  context.delete
end

#fetchSubscribedEventInstance

Fetch the SubscribedEventInstance

Returns:


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

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation


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

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.


289
290
291
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 289

def schema_version
  @properties['schema_version']
end

#subscription_sidString

Returns Subscription SID.

Returns:

  • (String)

    Subscription SID.


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

def subscription_sid
  @properties['subscription_sid']
end

#to_sObject

Provide a user friendly representation


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

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.


283
284
285
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 283

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:


317
318
319
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 317

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.


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

def url
  @properties['url']
end