Class: Twilio::REST::Events::V1::SchemaContext

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

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Defined Under Namespace

Classes: SchemaVersionContext, SchemaVersionInstance, SchemaVersionList, SchemaVersionPage

Instance Method Summary collapse

Constructor Details

#initialize(version, id) ⇒ SchemaContext

Initialize the SchemaContext

Parameters:

  • version (Version)

    Version that contains the resource

  • id (String)

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


74
75
76
77
78
79
80
81
82
83
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 74

def initialize(version, id)
  super(version)

  # Path Solution
  @solution = {id: id, }
  @uri = "/Schemas/#{@solution[:id]}"

  # Dependents
  @versions = nil
end

Instance Method Details

#fetchSchemaInstance

Fetch the SchemaInstance

Returns:


88
89
90
91
92
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 88

def fetch
  payload = @version.fetch('GET', @uri)

  SchemaInstance.new(@version, payload, id: @solution[:id], )
end

#inspectObject

Provide a detailed, user friendly representation


121
122
123
124
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 121

def inspect
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Events.V1.SchemaContext #{context}>"
end

#to_sObject

Provide a user friendly representation


114
115
116
117
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 114

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Events.V1.SchemaContext #{context}>"
end

#versions(schema_version = :unset) ⇒ SchemaVersionList, SchemaVersionContext

Access the versions

Returns:

Raises:

  • (ArgumentError)

98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 98

def versions(schema_version=:unset)
  raise ArgumentError, 'schema_version cannot be nil' if schema_version.nil?

  if schema_version != :unset
    return SchemaVersionContext.new(@version, @solution[:id], schema_version, )
  end

  unless @versions
    @versions = SchemaVersionList.new(@version, id: @solution[:id], )
  end

  @versions
end