Class: XeroGateway::ContactPerson

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ ContactPerson

Returns a new instance of ContactPerson.



5
6
7
8
9
# File 'lib/xero_gateway/contact_person.rb', line 5

def initialize(params = {})
  params.each do |k,v|
    self.send("#{k}=", v)
  end
end

Instance Attribute Details

#email_addressObject

Returns the value of attribute email_address.



3
4
5
# File 'lib/xero_gateway/contact_person.rb', line 3

def email_address
  @email_address
end

#first_nameObject

Returns the value of attribute first_name.



3
4
5
# File 'lib/xero_gateway/contact_person.rb', line 3

def first_name
  @first_name
end

#include_in_emailsObject

Returns the value of attribute include_in_emails.



3
4
5
# File 'lib/xero_gateway/contact_person.rb', line 3

def include_in_emails
  @include_in_emails
end

#last_nameObject

Returns the value of attribute last_name.



3
4
5
# File 'lib/xero_gateway/contact_person.rb', line 3

def last_name
  @last_name
end

Class Method Details

.from_xml(contact_person_element) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/xero_gateway/contact_person.rb', line 20

def self.from_xml(contact_person_element)
  contact_person = ContactPerson.new
  contact_person_element.children.each do |element|
    case(element.name)
      when "FirstName"       then contact_person.first_name = element.text
      when "LastName"        then contact_person.last_name = element.text
      when "EmailAddress"    then contact_person.email_address = element.text
      when "IncludeInEmails" then contact_person.include_in_emails = (element.text == "true")
    end
  end
  contact_person
end

Instance Method Details

#to_xml(b = Builder::XmlMarkup.new) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/xero_gateway/contact_person.rb', line 11

def to_xml(b = Builder::XmlMarkup.new)
  b.ContactPerson {
    b.FirstName first_name if first_name
    b.LastName last_name if last_name
    b.EmailAddress email_address if email_address
    b.IncludeInEmails include_in_emails if include_in_emails
  }
end