Class: Twilio::REST::Api::V2010::AccountContext::KeyInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/api/v2010/account/key.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, account_sid: nil, sid: nil) ⇒ KeyInstance

Initialize the KeyInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String) (defaults to: nil)

    A 34 character string that uniquely identifies this resource.

  • sid (String) (defaults to: nil)

    The sid



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 215

def initialize(version, payload, account_sid: nil, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'friendly_name' => payload['friendly_name'],
      'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
      'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
  }

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

Instance Method Details

#contextKeyContext

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

Returns:

  • (KeyContext)

    KeyContext for this KeyInstance



235
236
237
238
239
240
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 235

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

#date_createdTime

Returns The date_created.

Returns:

  • (Time)

    The date_created



256
257
258
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 256

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date_updated.

Returns:

  • (Time)

    The date_updated



262
263
264
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 262

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the KeyInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



284
285
286
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 284

def delete
  context.delete
end

#fetchKeyInstance

Fetch a KeyInstance

Returns:



269
270
271
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 269

def fetch
  context.fetch
end

#friendly_nameString

Returns The friendly_name.

Returns:

  • (String)

    The friendly_name



250
251
252
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 250

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



297
298
299
300
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 297

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

#sidString

Returns The sid.

Returns:

  • (String)

    The sid



244
245
246
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 244

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation



290
291
292
293
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 290

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

#update(friendly_name: :unset) ⇒ KeyInstance

Update the KeyInstance

Parameters:

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

    The friendly_name

Returns:



277
278
279
# File 'lib/twilio-ruby/rest/api/v2010/account/key.rb', line 277

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