Class: Dhl::Bcs::V2::Receiver

Inherits:
Object
  • Object
show all
Defined in:
lib/dhl/bcs/v2/receiver.rb

Constant Summary collapse

PROPERTIES =

a location is one of Address, Packstation, Postfiliale or ParcelShop

i(name communication location).freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attributes) ⇒ Receiver

Returns a new instance of Receiver.



15
16
17
18
19
# File 'lib/dhl/bcs/v2/receiver.rb', line 15

def initialize(**attributes)
  attributes.each do |property, value|
    send("#{property}=", value) if PROPERTIES.include?(property)
  end
end

Class Method Details

.build(name: nil, **attributes) ⇒ Object



9
10
11
12
13
# File 'lib/dhl/bcs/v2/receiver.rb', line 9

def self.build(name: nil, **attributes)
  communication = Communication.build(attributes)
  location = Locator.for(attributes)
  new(attributes.merge(name: name, communication: communication, location: location))
end

Instance Method Details

#to_soap_hashObject



21
22
23
24
25
26
27
# File 'lib/dhl/bcs/v2/receiver.rb', line 21

def to_soap_hash
  {
    'cis:name1' => name,
    'Communication' => communication.to_soap_hash,
    location.class.name.split('::').last => location.to_soap_hash
  }
end