Class: Twilio::REST::Api::V2010::AccountContext::IncomingPhoneNumberContext::AssignedAddOnContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb,
lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on/assigned_add_on_extension.rb

Defined Under Namespace

Classes: AssignedAddOnExtensionContext, AssignedAddOnExtensionInstance, AssignedAddOnExtensionInstanceMetadata, AssignedAddOnExtensionList, AssignedAddOnExtensionListResponse, AssignedAddOnExtensionPage, AssignedAddOnExtensionPageMetadata

Instance Method Summary collapse

Constructor Details

#initialize(version, account_sid, resource_sid, sid) ⇒ AssignedAddOnContext

Initialize the AssignedAddOnContext

Parameters:

  • version (Version)

    Version that contains the resource

  • account_sid (String)

    The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the resource to fetch.

  • resource_sid (String)

    The SID of the Phone Number to which the Add-on is assigned.

  • sid (String)

    The Twilio-provided string that uniquely identifies the resource to fetch.



224
225
226
227
228
229
230
231
232
233
234
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb', line 224

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

    # Path Solution
    @solution = { account_sid: , resource_sid: resource_sid, sid: sid,  }
    @uri = "/Accounts/#{@solution[:account_sid]}/IncomingPhoneNumbers/#{@solution[:resource_sid]}/AssignedAddOns/#{@solution[:sid]}.json"

    # Dependents
    @extensions = nil
end

Instance Method Details

#deleteBoolean

Delete the AssignedAddOnInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



238
239
240
241
242
243
244
245
246
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb', line 238

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 AssignedAddOnInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb', line 251

def 

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

#extensions(sid = :unset) ⇒ AssignedAddOnExtensionList, AssignedAddOnExtensionContext

Access the extensions

Returns:

Raises:

  • (ArgumentError)


319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb', line 319

def extensions(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return AssignedAddOnExtensionContext.new(@version, @solution[:account_sid], @solution[:resource_sid], @solution[:sid],sid )
    end

    unless @extensions
        @extensions = AssignedAddOnExtensionList.new(
            @version, account_sid: @solution[:account_sid], resource_sid: @solution[:resource_sid], assigned_add_on_sid: @solution[:sid], )
    end

 @extensions
end

#fetchAssignedAddOnInstance

Fetch the AssignedAddOnInstance

Returns:



270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb', line 270

def fetch

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

#fetch_with_metadataAssignedAddOnInstance

Fetch the AssignedAddOnInstanceMetadata

Returns:



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb', line 291

def 

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

#inspectObject

Provide a detailed, user friendly representation



344
345
346
347
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb', line 344

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

#to_sObject

Provide a user friendly representation



337
338
339
340
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb', line 337

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