Class: Dhl::Intraship::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/dhl-intraship/address.rb

Direct Known Subclasses

CompanyAddress, PersonAddress

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Address

Returns a new instance of Address.



7
8
9
10
11
12
13
14
# File 'lib/dhl-intraship/address.rb', line 7

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/dhl-intraship/address.rb', line 4

def city
  @city
end

#contact_personObject

Returns the value of attribute contact_person.



4
5
6
# File 'lib/dhl-intraship/address.rb', line 4

def contact_person
  @contact_person
end

#country_codeObject

Returns the value of attribute country_code.



4
5
6
# File 'lib/dhl-intraship/address.rb', line 4

def country_code
  @country_code
end

#emailObject

Returns the value of attribute email.



4
5
6
# File 'lib/dhl-intraship/address.rb', line 4

def email
  @email
end

#house_numberObject

Returns the value of attribute house_number.



4
5
6
# File 'lib/dhl-intraship/address.rb', line 4

def house_number
  @house_number
end

#phoneObject

Returns the value of attribute phone.



4
5
6
# File 'lib/dhl-intraship/address.rb', line 4

def phone
  @phone
end

#streetObject

Returns the value of attribute street.



4
5
6
# File 'lib/dhl-intraship/address.rb', line 4

def street
  @street
end

#street_additionalObject

Returns the value of attribute street_additional.



4
5
6
# File 'lib/dhl-intraship/address.rb', line 4

def street_additional
  @street_additional
end

#zipObject

Returns the value of attribute zip.



4
5
6
# File 'lib/dhl-intraship/address.rb', line 4

def zip
  @zip
end

Instance Method Details

#append_to_xml(xml) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/dhl-intraship/address.rb', line 25

def append_to_xml(xml)
  xml.Company do |xml|
    company_xml(xml)
  end
  xml.Address do |xml|
    xml.cis(:streetName, street)
    xml.cis(:streetNumber, house_number)
    xml.cis(:careOfName, street_additional) unless street_additional.blank?
    xml.cis(:Zip) do |xml|
      if country_code == 'DE'
        xml.cis(:germany, zip)
      elsif ['GB','UK'].include?(country_code)
        xml.cis(:england, zip)
      else
        xml.cis(:other, zip)
      end
    end
    xml.cis(:city, city)
    xml.cis(:Origin) do |xml|
      xml.cis(:countryISOCode, country_code)
    end
  end
  xml.Communication do |xml|
    xml.cis(:phone, self.phone) unless self.phone.blank?
    xml.cis(:email, self.email) unless self.email.blank?
    xml.cis(:contactPerson, contact_person.blank? ? "" : contact_person)
  end
end

#company?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/dhl-intraship/address.rb', line 16

def company?
  !self.company.blank?
end