Class: Twilio::REST::Events::V1::SchemaInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/events/v1/schema.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, id: nil) ⇒ SchemaInstance

Initialize the SchemaInstance

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

  • sid (String) —

    The SID of the Call resource to fetch.



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

def initialize(version, payload , id: nil)
    super(version)
    
    
    # Marshaled Properties
    @properties = { 
        'id' => payload['id'],
        'url' => payload['url'],
        'links' => payload['links'],
        'latest_version_date_created' => Twilio.deserialize_iso8601_datetime(payload['latest_version_date_created']),
        'latest_version' => payload['latest_version'] == nil ? payload['latest_version'] : payload['latest_version'].to_i,
    }

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

Instance Method Details

#context ⇒ SchemaContext

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

Returns:



249
250
251
252
253
254
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 249

def context
    unless @instance_context
        @instance_context = SchemaContext.new(@version , @params['id'])
    end
    @instance_context
end

#fetch ⇒ SchemaInstance

Fetch the SchemaInstance

Returns:



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

def fetch

    context.fetch
end

#id ⇒ String

Returns The unique identifier of the schema. Each schema can have multiple versions, that share the same id.

Returns:

  • (String) —

    The unique identifier of the schema. Each schema can have multiple versions, that share the same id.



258
259
260
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 258

def id
    @properties['id']
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



310
311
312
313
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 310

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

#latest_version ⇒ String

Returns The latest version published of this schema.

Returns:

  • (String) —

    The latest version published of this schema.



282
283
284
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 282

def latest_version
    @properties['latest_version']
end

#latest_version_date_created ⇒ Time

Returns The date that the latest schema version was created, given in ISO 8601 format.

Returns:

  • (Time) —

    The date that the latest schema version was created, given in ISO 8601 format.



276
277
278
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 276

def latest_version_date_created
    @properties['latest_version_date_created']
end

Returns Contains a dictionary of URL links to nested resources of this schema.

Returns:

  • (Hash) —

    Contains a dictionary of URL links to nested resources of this schema.



270
271
272
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 270

def links
    @properties['links']
end

#to_s ⇒ Object

Provide a user friendly representation



303
304
305
306
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 303

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

#url ⇒ String

Returns The URL of this resource.

Returns:

  • (String) —

    The URL of this resource.



264
265
266
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 264

def url
    @properties['url']
end

#versions ⇒ versions

Access the versions

Returns:



297
298
299
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 297

def versions
    context.versions
end