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/schema_version.rb

Defined Under Namespace

Classes: SchemaVersionContext, SchemaVersionInstance, SchemaVersionInstanceMetadata, SchemaVersionList, SchemaVersionListResponse, SchemaVersionPage, SchemaVersionPageMetadata

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.



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 50

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:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 64

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    SchemaInstance.new(
        @version,
        payload,
        id: @solution[:id],
    )
end

#fetch_with_metadataSchemaInstance

Fetch the SchemaInstanceMetadata

Returns:



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 83

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    schema_instance = SchemaInstance.new(
        @version,
        response.body,
        id: @solution[:id],
    )
    .new(
        @version,
        schema_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



134
135
136
137
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 134

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

#to_sObject

Provide a user friendly representation



127
128
129
130
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 127

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)


109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/twilio-ruby/rest/events/v1/schema.rb', line 109

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