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.



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

def initialize(version, payload, subscription_sid: nil, type: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'type' => payload['type'],
      'version' => payload['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.



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

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:



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

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



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

def delete
  context.delete
end

#fetchSubscribedEventInstance

Fetch the SubscribedEventInstance

Returns:



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

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



334
335
336
337
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 334

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

#subscription_sidString

Returns Subscription SID.

Returns:

  • (String)

    Subscription SID.



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

def subscription_sid
  @properties['subscription_sid']
end

#to_sObject

Provide a user friendly representation



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

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.



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

def type
  @properties['type']
end

#update(version: :unset) ⇒ SubscribedEventInstance

Update the SubscribedEventInstance

Parameters:

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

    The schema version that the subscription should use.

Returns:



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

def update(version: :unset)
  context.update(version: version, )
end

#urlString

Returns The URL of this resource.

Returns:

  • (String)

    The URL of this resource.



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

def url
  @properties['url']
end

#versionString

Returns The schema version that the subscription should use.

Returns:

  • (String)

    The schema version that the subscription should use.



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

def version
  @properties['version']
end