module IntacctRuby::ContactsHelper

methods to avoid duplication when creating and updating contact records

Public Instance Methods

contact_params(attributes, id, person_type) click to toggle source
# File lib/intacct_ruby/helpers/contacts_helper.rb, line 4
def contact_params(attributes, id, person_type)
  xml = Builder::XmlMarkup.new

  name = full_name(attributes)

  xml.contact do
    xml.contactname contactname(name, id, person_type)
    xml.printas     full_name(attributes)
    xml.firstname   attributes[:first_name]
    xml.lastname    attributes[:last_name]
    xml.email1      attributes[:email1]
  end

  xml.target!
end
contactname(name, id, person_type) click to toggle source
# File lib/intacct_ruby/helpers/contacts_helper.rb, line 20
def contactname(name, id, person_type)
  # a unique identifier for a contact, to be used for Intacct's
  # contactname field. Person Type required to ensure that there aren't
  # duplicates (e.g. a customer and employee w/ ID 1 both named
  # 'John Smith')
  "#{name} (#{person_type} \##{id})"
end
full_name(attrs = {}) click to toggle source
# File lib/intacct_ruby/helpers/contacts_helper.rb, line 28
def full_name(attrs = {})
  "#{attrs[:first_name]} #{attrs[:last_name]}"
end