Class: XeroKiwi::Accounting::ContactPerson

Inherits:
Object
  • Object
show all
Defined in:
lib/xero_kiwi/accounting/contact_person.rb

Overview

Represents a contact person nested within a Xero Contact.

See: developer.xero.com/documentation/api/accounting/contacts

Constant Summary collapse

ATTRIBUTES =
{
  first_name:        "FirstName",
  last_name:         "LastName",
  email_address:     "EmailAddress",
  include_in_emails: "IncludeInEmails"
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ ContactPerson

Returns a new instance of ContactPerson.



18
19
20
21
22
23
24
# File 'lib/xero_kiwi/accounting/contact_person.rb', line 18

def initialize(attrs)
  attrs              = attrs.transform_keys(&:to_s)
  @first_name        = attrs["FirstName"]
  @last_name         = attrs["LastName"]
  @email_address     = attrs["EmailAddress"]
  @include_in_emails = attrs["IncludeInEmails"]
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



32
33
34
# File 'lib/xero_kiwi/accounting/contact_person.rb', line 32

def ==(other)
  other.is_a?(ContactPerson) && to_h == other.to_h
end

#hashObject



37
# File 'lib/xero_kiwi/accounting/contact_person.rb', line 37

def hash = to_h.hash

#include_in_emails?Boolean

Returns:

  • (Boolean)


26
# File 'lib/xero_kiwi/accounting/contact_person.rb', line 26

def include_in_emails? = include_in_emails == true

#inspectObject



39
40
41
42
# File 'lib/xero_kiwi/accounting/contact_person.rb', line 39

def inspect
  "#<#{self.class} first_name=#{first_name.inspect} " \
    "last_name=#{last_name.inspect} email_address=#{email_address.inspect}>"
end

#to_hObject



28
29
30
# File 'lib/xero_kiwi/accounting/contact_person.rb', line 28

def to_h
  ATTRIBUTES.keys.to_h { |key| [key, public_send(key)] }
end