Class: Twilio::REST::Routes::V3::PhoneNumberInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/routes/v3/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.



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/twilio-ruby/rest/routes/v3/phone_number.rb', line 280

def initialize(version, payload , phone_number: nil)
    
    apiV1Version = ApiV1Version.new version.domain, version
    super(apiV1Version)
    
    # Marshaled Properties
    @properties = { 
        'phone_number' => payload['phone_number'],
        'url' => payload['url'],
        'account_sid' => payload['account_sid'],
        'friendly_name' => payload['friendly_name'],
        'voice_region' => payload['voice_region'],
        'messaging_region' => payload['messaging_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_sid ⇒ String

Returns The unique SID identifier of the Account.

Returns:

  • (String) —

    The unique SID identifier of the Account.



327
328
329
# File 'lib/twilio-ruby/rest/routes/v3/phone_number.rb', line 327

def 
    @properties['account_sid']
end

#context ⇒ PhoneNumberContext

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

Returns:



306
307
308
309
310
311
# File 'lib/twilio-ruby/rest/routes/v3/phone_number.rb', line 306

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

#date_created ⇒ Time

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.



351
352
353
# File 'lib/twilio-ruby/rest/routes/v3/phone_number.rb', line 351

def date_created
    @properties['date_created']
end

#date_updated ⇒ Time

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.



357
358
359
# File 'lib/twilio-ruby/rest/routes/v3/phone_number.rb', line 357

def date_updated
    @properties['date_updated']
end

#fetch ⇒ PhoneNumberInstance

Fetch the PhoneNumberInstance

Returns:



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

def fetch

    context.fetch
end

#friendly_name ⇒ String

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.



333
334
335
# File 'lib/twilio-ruby/rest/routes/v3/phone_number.rb', line 333

def friendly_name
    @properties['friendly_name']
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



397
398
399
400
# File 'lib/twilio-ruby/rest/routes/v3/phone_number.rb', line 397

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

#messaging_region ⇒ String

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

Returns:

  • (String) —

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



345
346
347
# File 'lib/twilio-ruby/rest/routes/v3/phone_number.rb', line 345

def messaging_region
    @properties['messaging_region']
end

#phone_number ⇒ String

Returns The phone number in E.164 format.

Returns:

  • (String) —

    The phone number in E.164 format



315
316
317
# File 'lib/twilio-ruby/rest/routes/v3/phone_number.rb', line 315

def phone_number
    @properties['phone_number']
end

#to_s ⇒ Object

Provide a user friendly representation



390
391
392
393
# File 'lib/twilio-ruby/rest/routes/v3/phone_number.rb', line 390

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

#update(voice_region: :unset, messaging_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

  • messaging_region (String) (defaults to: :unset) —

    The Inbound Processing Region used for this phone number for messaging

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

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

Returns:



375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/twilio-ruby/rest/routes/v3/phone_number.rb', line 375

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

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

#url ⇒ String

Returns The absolute URL of the resource.

Returns:

  • (String) —

    The absolute URL of the resource.



321
322
323
# File 'lib/twilio-ruby/rest/routes/v3/phone_number.rb', line 321

def url
    @properties['url']
end

#voice_region ⇒ String

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.



339
340
341
# File 'lib/twilio-ruby/rest/routes/v3/phone_number.rb', line 339

def voice_region
    @properties['voice_region']
end