Class: Twilio::REST::Routes::V2::PhoneNumberInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/routes/v2/phone_number.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, phone_number: nil) ⇒ PhoneNumberInstance

Initialize the PhoneNumberInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String)

    The SID of the Account that created this PhoneNumber resource.

  • sid (String)

    The SID of the Call resource to fetch.



330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 330

def initialize(version, payload , phone_number: nil)
    super(version)
    
    
    # Marshaled Properties
    @properties = { 
        'phone_number' => payload['phone_number'],
        'url' => payload['url'],
        'sid' => payload['sid'],
        'account_sid' => payload['account_sid'],
        'friendly_name' => payload['friendly_name'],
        'voice_region' => payload['voice_region'],
        'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
        'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
    }

    # Context
    @instance_context = nil
    @params = { 'phone_number' => phone_number  || @properties['phone_number']  , }
end

Instance Method Details

#account_sidString

Returns The unique SID identifier of the Account.

Returns:

  • (String)

    The unique SID identifier of the Account.



382
383
384
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 382

def 
    @properties['account_sid']
end

#contextPhoneNumberContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



355
356
357
358
359
360
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 355

def context
    unless @instance_context
        @instance_context = PhoneNumberContext.new(@version , @params['phone_number'])
    end
    @instance_context
end

#date_createdTime

Returns The date that this phone number was assigned an Inbound Processing Region, given in ISO 8601 format.

Returns:

  • (Time)

    The date that this phone number was assigned an Inbound Processing Region, given in ISO 8601 format.



400
401
402
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 400

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns The date that the Inbound Processing Region was updated for this phone number, given in ISO 8601 format.

Returns:

  • (Time)

    The date that the Inbound Processing Region was updated for this phone number, given in ISO 8601 format.



406
407
408
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 406

def date_updated
    @properties['date_updated']
end

#fetchPhoneNumberInstance

Fetch the PhoneNumberInstance

Returns:



413
414
415
416
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 413

def fetch

    context.fetch
end

#friendly_nameString

Returns A human readable description of the Inbound Processing Region assignments for this phone number, up to 64 characters.

Returns:

  • (String)

    A human readable description of the Inbound Processing Region assignments for this phone number, up to 64 characters.



388
389
390
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 388

def friendly_name
    @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



443
444
445
446
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 443

def inspect
    values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Routes.V2.PhoneNumberInstance #{values}>"
end

#phone_numberString

Returns The phone number in E.164 format.

Returns:

  • (String)

    The phone number in E.164 format



364
365
366
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 364

def phone_number
    @properties['phone_number']
end

#sidString

Returns A 34 character string that uniquely identifies the Inbound Processing Region assignments for this phone number.

Returns:

  • (String)

    A 34 character string that uniquely identifies the Inbound Processing Region assignments for this phone number.



376
377
378
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 376

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



436
437
438
439
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 436

def to_s
    values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Routes.V2.PhoneNumberInstance #{values}>"
end

#update(voice_region: :unset, friendly_name: :unset) ⇒ PhoneNumberInstance

Update the PhoneNumberInstance

Parameters:

  • voice_region (String) (defaults to: :unset)

    The Inbound Processing Region used for this phone number for voice

  • friendly_name (String) (defaults to: :unset)

    A human readable description of this resource, up to 64 characters.

Returns:



423
424
425
426
427
428
429
430
431
432
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 423

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

    context.update(
        voice_region: voice_region, 
        friendly_name: friendly_name, 
    )
end

#urlString

Returns The absolute URL of the resource.

Returns:

  • (String)

    The absolute URL of the resource.



370
371
372
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 370

def url
    @properties['url']
end

#voice_regionString

Returns The Inbound Processing Region used for this phone number for voice.

Returns:

  • (String)

    The Inbound Processing Region used for this phone number for voice.



394
395
396
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 394

def voice_region
    @properties['voice_region']
end