Class: Connfu::Provisioning::Phone
- Inherits:
-
Object
- Object
- Connfu::Provisioning::Phone
- Defined in:
- lib/connfu/provisioning/phone.rb
Overview
connFu Phone (belongs to a Voice channel)
Instance Attribute Summary collapse
-
#country ⇒ Object
specific country where the phone is allocated.
-
#phone_number ⇒ Object
phone number.
-
#voice ⇒ Object
readonly
voice channel unique identifier.
Class Method Summary collapse
-
.unmarshal(voice, data) ⇒ Object
Creates a Phone object using the raw data from the provisioning API.
Instance Method Summary collapse
-
#[](value) ⇒ Object
Hash way to retrieve attributes.
-
#initialize(voice, phone_number, country = "") ⇒ Phone
constructor
A new instance of Phone.
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(voice, phone_number, country = "") ⇒ Phone
Returns a new instance of Phone.
22 23 24 25 26 |
# File 'lib/connfu/provisioning/phone.rb', line 22 def initialize(voice, phone_number, country = "") @voice = voice @phone_number = phone_number @country = country end |
Instance Attribute Details
#country ⇒ Object
specific country where the phone is allocated
11 12 13 |
# File 'lib/connfu/provisioning/phone.rb', line 11 def country @country end |
#phone_number ⇒ Object
phone number
14 15 16 |
# File 'lib/connfu/provisioning/phone.rb', line 14 def phone_number @phone_number end |
#voice ⇒ Object (readonly)
voice channel unique identifier
17 18 19 |
# File 'lib/connfu/provisioning/phone.rb', line 17 def voice @voice end |
Class Method Details
.unmarshal(voice, data) ⇒ Object
Creates a Phone object using the raw data from the provisioning API
45 46 47 48 49 50 51 |
# File 'lib/connfu/provisioning/phone.rb', line 45 def self.unmarshal(voice, data) if data.is_a?(Array) data.map{|item| Phone.new(voice, item["phone_number"], item["country"])} else Phone.new(voice, data["phone_number"], data["country"]) end end |
Instance Method Details
#[](value) ⇒ Object
Hash way to retrieve attributes
29 30 31 |
# File 'lib/connfu/provisioning/phone.rb', line 29 def [](value) self.respond_to?(value.to_sym) ? self.send(value.to_sym) : nil end |
#to_hash ⇒ Object
33 34 35 |
# File 'lib/connfu/provisioning/phone.rb', line 33 def to_hash {"country" => country, "phone_number" => phone_number} end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/connfu/provisioning/phone.rb', line 37 def to_s "#{self.class.to_s}: #{to_hash}" end |