Class: XeroKiwi::Accounting::Phone
- Inherits:
-
Object
- Object
- XeroKiwi::Accounting::Phone
- Defined in:
- lib/xero_kiwi/accounting/phone.rb
Overview
A Xero phone number. Used by Organisation, Contact, and other resources.
See: developer.xero.com/documentation/api/accounting/types#phones
Constant Summary collapse
- ATTRIBUTES =
{ phone_type: "PhoneType", phone_number: "PhoneNumber", phone_area_code: "PhoneAreaCode", phone_country_code: "PhoneCountryCode" }.freeze
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #default? ⇒ Boolean
- #fax? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(attrs) ⇒ Phone
constructor
A new instance of Phone.
- #inspect ⇒ Object
- #mobile? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(attrs) ⇒ Phone
Returns a new instance of Phone.
18 19 20 21 22 23 24 |
# File 'lib/xero_kiwi/accounting/phone.rb', line 18 def initialize(attrs) attrs = attrs.transform_keys(&:to_s) @phone_type = attrs["PhoneType"] @phone_number = attrs["PhoneNumber"] @phone_area_code = attrs["PhoneAreaCode"] @phone_country_code = attrs["PhoneCountryCode"] end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
34 35 36 |
# File 'lib/xero_kiwi/accounting/phone.rb', line 34 def ==(other) other.is_a?(Phone) && to_h == other.to_h end |
#default? ⇒ Boolean
26 |
# File 'lib/xero_kiwi/accounting/phone.rb', line 26 def default? = phone_type == "DEFAULT" |
#fax? ⇒ Boolean
28 |
# File 'lib/xero_kiwi/accounting/phone.rb', line 28 def fax? = phone_type == "FAX" |
#hash ⇒ Object
39 |
# File 'lib/xero_kiwi/accounting/phone.rb', line 39 def hash = to_h.hash |
#inspect ⇒ Object
41 42 43 |
# File 'lib/xero_kiwi/accounting/phone.rb', line 41 def inspect "#<#{self.class} type=#{phone_type.inspect} number=#{phone_number.inspect}>" end |
#mobile? ⇒ Boolean
27 |
# File 'lib/xero_kiwi/accounting/phone.rb', line 27 def mobile? = phone_type == "MOBILE" |
#to_h ⇒ Object
30 31 32 |
# File 'lib/xero_kiwi/accounting/phone.rb', line 30 def to_h ATTRIBUTES.keys.to_h { |key| [key, public_send(key)] } end |