Class: Twilio::REST::Voice::V2::TypeContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/voice/v2/type.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, type, id_or_unique_name) ⇒ TypeContext

Initialize the TypeContext

Parameters:

  • version (Version)

    Version that contains the resource

  • type (String)
  • id_or_unique_name (String)


71
72
73
74
75
76
77
78
79
80
# File 'lib/twilio-ruby/rest/voice/v2/type.rb', line 71

def initialize(version, type, id_or_unique_name)
    super(version)
    

    # Path Solution
    @solution = { type: type, id_or_unique_name: id_or_unique_name,  }
    @uri = "/Configurations/#{@solution[:type]}/#{@solution[:id_or_unique_name]}"

    
end

Instance Method Details

#deleteBoolean

Delete the TypeInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



84
85
86
87
88
89
90
91
92
# File 'lib/twilio-ruby/rest/voice/v2/type.rb', line 84

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadataBoolean

Delete the TypeInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/twilio-ruby/rest/voice/v2/type.rb', line 97

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      type_instance = TypeInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      TypeInstanceMetadata.new(@version, type_instance, response.headers, response.status_code)
end

#fetchTypeInstance

Fetch the TypeInstance

Returns:



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/twilio-ruby/rest/voice/v2/type.rb', line 116

def fetch

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

#fetch_with_metadataTypeInstance

Fetch the TypeInstanceMetadata

Returns:



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/twilio-ruby/rest/voice/v2/type.rb', line 136

def 

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

#inspectObject

Provide a detailed, user friendly representation



219
220
221
222
# File 'lib/twilio-ruby/rest/voice/v2/type.rb', line 219

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

#to_sObject

Provide a user friendly representation



212
213
214
215
# File 'lib/twilio-ruby/rest/voice/v2/type.rb', line 212

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

#update(voice_v2_configuration_request: :unset) ⇒ TypeInstance

Update the TypeInstance

Parameters:

  • voice_v2_configuration_request (VoiceV2ConfigurationRequest) (defaults to: :unset)

Returns:



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/twilio-ruby/rest/voice/v2/type.rb', line 163

def update(voice_v2_configuration_request: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    payload = @version.update('PUT', @uri, headers: headers, data: voice_v2_configuration_request.to_json)
    TypeInstance.new(
        @version,
        payload,
        type: @solution[:type],
        id_or_unique_name: @solution[:id_or_unique_name],
    )
end

#update_with_metadata(voice_v2_configuration_request: :unset) ⇒ TypeInstance

Update the TypeInstanceMetadata

Parameters:

  • voice_v2_configuration_request (VoiceV2ConfigurationRequest) (defaults to: :unset)

Returns:



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/twilio-ruby/rest/voice/v2/type.rb', line 185

def (voice_v2_configuration_request: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    response = @version.('PUT', @uri, headers: headers, data: voice_v2_configuration_request.to_json)
    type_instance = TypeInstance.new(
        @version,
        response.body,
        type: @solution[:type],
        id_or_unique_name: @solution[:id_or_unique_name],
    )
    TypeInstanceMetadata.new(
        @version,
        type_instance,
        response.headers,
        response.status_code
    )
end