Class: Dpd::Shipping::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/dpd_shipping/address.rb

Constant Summary collapse

VALID_SEX =
[:NoSexCode, :Male, :Female]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Address

Returns a new instance of Address.



8
9
10
11
12
13
14
15
# File 'lib/dpd_shipping/address.rb', line 8

def initialize(attributes = {})
  attributes.each do |key, value|
    setter = :"#{key.to_s}="
    if self.respond_to?(setter)
      self.send(setter, value)
    end
  end
end

Instance Attribute Details

#cityObject

Returns the value of attribute city.



4
5
6
# File 'lib/dpd_shipping/address.rb', line 4

def city
  @city
end

#companyObject

Returns the value of attribute company.



4
5
6
# File 'lib/dpd_shipping/address.rb', line 4

def company
  @company
end

#country_codeObject

Returns the value of attribute country_code.



4
5
6
# File 'lib/dpd_shipping/address.rb', line 4

def country_code
  @country_code
end

#emailObject

Returns the value of attribute email.



4
5
6
# File 'lib/dpd_shipping/address.rb', line 4

def email
  @email
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/dpd_shipping/address.rb', line 4

def name
  @name
end

#phoneObject

Returns the value of attribute phone.



4
5
6
# File 'lib/dpd_shipping/address.rb', line 4

def phone
  @phone
end

#sexObject

Returns the value of attribute sex.



4
5
6
# File 'lib/dpd_shipping/address.rb', line 4

def sex
  @sex
end

#stateObject

Returns the value of attribute state.



4
5
6
# File 'lib/dpd_shipping/address.rb', line 4

def state
  @state
end

#streetObject

Returns the value of attribute street.



4
5
6
# File 'lib/dpd_shipping/address.rb', line 4

def street
  @street
end

#zipObject

Returns the value of attribute zip.



4
5
6
# File 'lib/dpd_shipping/address.rb', line 4

def zip
  @zip
end

Instance Method Details

#append_to_xml(xml) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/dpd_shipping/address.rb', line 31

def append_to_xml(xml)
  xml.tns :ShipAddress do |xml|
    xml.tns :Company, company if company?
    xml.tns :SexCode, sex || :NoSexCode
    xml.tns :Name, name
    xml.tns :Street, street
    xml.tns :ZipCode, zip
    xml.tns :City, city
    xml.tns :State, state || ""
    xml.tns :Country, country_code
    xml.tns :Phone, phone || ""
    xml.tns :Mail, email || ""
  end
end

#company?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/dpd_shipping/address.rb', line 17

def company?
  !self.company.blank?
end