Class: SynergyWholesale::Types::Contact

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/synergy_wholesale/types/contact.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(attributes) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/synergy_wholesale/types/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:        attributes[:state],
      country:      { country_code: attributes[:country] },
      postcode:     attributes[:postcode],
      phone:        { phone: attributes[:phone] },
      fax:          attributes[:fax] ? { phone: attributes[:fax] } : nil,
      email:        { email: attributes[:email] },
      type:         attributes[:type]
    }
  )
end

Instance Method Details

#to_paramObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/synergy_wholesale/types/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