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 preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected].

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 subscription_sid

  • type (String) (defaults to: nil)

    The type



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 227

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 The account_sid.

Returns:

  • (String)

    The account_sid



261
262
263
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 261

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:



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

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



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

def delete
  context.delete
end

#inspectObject

Provide a detailed, user friendly representation



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

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

#subscription_sidString

Returns The subscription_sid.

Returns:

  • (String)

    The subscription_sid



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

def subscription_sid
  @properties['subscription_sid']
end

#to_sObject

Provide a user friendly representation



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

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

#typeString

Returns The type.

Returns:

  • (String)

    The type



267
268
269
# File 'lib/twilio-ruby/rest/events/v1/subscription/subscribed_event.rb', line 267

def type
  @properties['type']
end

#update(version: nil) ⇒ SubscribedEventInstance

Update the SubscribedEventInstance

Parameters:

  • version (String) (defaults to: nil)

    The version

Returns:



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

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

#urlString

Returns The url.

Returns:

  • (String)

    The url



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

def url
  @properties['url']
end

#versionString

Returns The version.

Returns:

  • (String)

    The version



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

def version
  @properties['version']
end