class SynergyWholesale::Types::AuContact

Public Class Methods

build(attributes) click to toggle source
# File lib/synergy_wholesale/types/au_contact.rb, line 18
def self.build(attributes)
  new(
    {
      firstname:    attributes[:firstname],
      lastname:     attributes[:lastname],
      organisation: attributes[:organisation],
      address:      attributes[:address],
      suburb:       attributes[:suburb],
      state:        { state: attributes[:state] },
      country:      { country_code: attributes[:country] },
      postcode:     { postcode: attributes[:postcode] },
      phone:        { phone: attributes[:phone] },
      fax:          attributes[:fax] ? { phone: attributes[:fax] } : nil,
      email:        { email: attributes[:email] },
      type:         attributes[:type]
    }
  )
end

Public Instance Methods

to_param() click to toggle source
# File lib/synergy_wholesale/types/au_contact.rb, line 37
def to_param
  {
    prefixed(:lastname)     => lastname,
    prefixed(:firstname)    => firstname,
    prefixed(:organisation) => organisation,
    prefixed(:address)      => { item: address, '@xsi:type' => 'enc:Array' },
    prefixed(:suburb)       => suburb,
    prefixed(:state)        => state.to_s,
    prefixed(:country)      => country.to_s,
    prefixed(:postcode)     => postcode.to_s,
    prefixed(:phone)        => phone.to_s,
    prefixed(:fax)          => fax.to_s,
    prefixed(:email)        => email.to_s
  }
end

Protected Instance Methods

prefixed(attr) click to toggle source
# File lib/synergy_wholesale/types/au_contact.rb, line 55
def prefixed(attr)
  "#{type}_#{attr}"
end