Class: Twilio::REST::Preview::DeployedDevices::FleetContext::KeyContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, fleet_sid, sid) ⇒ KeyContext

Initialize the KeyContext



167
168
169
170
171
172
173
174
175
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 167

def initialize(version, fleet_sid, sid)
    super(version)

    # Path Solution
    @solution = { fleet_sid: fleet_sid, sid: sid,  }
    @uri = "/Fleets/#{@solution[:fleet_sid]}/Keys/#{@solution[:sid]}"

    
end

Instance Method Details

#deleteBoolean

Delete the KeyInstance



179
180
181
182
183
184
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 179

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    @version.delete('DELETE', @uri, headers: headers)
end

#fetchKeyInstance

Fetch the KeyInstance



189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 189

def fetch

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

#inspectObject

Provide a detailed, user friendly representation



238
239
240
241
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 238

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

#to_sObject

Provide a user friendly representation



231
232
233
234
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 231

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

#update(friendly_name: :unset, device_sid: :unset) ⇒ KeyInstance

Update the KeyInstance



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 207

def update(
    friendly_name: :unset, 
    device_sid: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'DeviceSid' => device_sid,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    KeyInstance.new(
        @version,
        payload,
        fleet_sid: @solution[:fleet_sid],
        sid: @solution[:sid],
    )
end