Class: Twi::Phone

Inherits:
Resource show all
Defined in:
lib/twi/phone.rb

Overview

The representation of a phone number associated to the default messaging service.

Direct Known Subclasses

Mock::Phone

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Twi::Resource

Instance Attribute Details

#idString (readonly)

Returns unique identifier of the phone.

Returns:

  • (String)

    unique identifier of the phone.



16
17
18
# File 'lib/twi/phone.rb', line 16

def id
  @id
end

#numberString (readonly)

Returns 10-digit number.

Returns:

  • (String)

    10-digit number.



19
20
21
# File 'lib/twi/phone.rb', line 19

def number
  @number
end

Instance Method Details

#createObject

Create an incoming phone number within the area code and friendly name.



6
7
8
9
10
11
12
13
# File 'lib/twi/phone.rb', line 6

def create
  phone = client.incoming_phone_numbers.create area_code: @params[:area_code],
    emergency_address_sid: Twi.lio.emergency_address_sid, friendly_name: @params[:friendly_name]
  messaging_service.phone_numbers.create phone_number_sid: phone.sid

  @id = phone.sid
  @number = remove_prefix_from phone.phone_number
end