Class: Dhl::Bcs::V2::Shipper
- Inherits:
-
Object
- Object
- Dhl::Bcs::V2::Shipper
- Defined in:
- lib/dhl/bcs/v2/shipper.rb
Constant Summary collapse
- PROPERTIES =
%i(name company company_addition address communication).freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**attributes) ⇒ Shipper
constructor
A new instance of Shipper.
- #to_soap_hash ⇒ Object
Constructor Details
#initialize(**attributes) ⇒ Shipper
Returns a new instance of Shipper.
14 15 16 17 18 |
# File 'lib/dhl/bcs/v2/shipper.rb', line 14 def initialize(**attributes) attributes.each do |property, value| send("#{property}=", value) if PROPERTIES.include?(property) end end |
Class Method Details
.build(company: nil, **attributes) ⇒ Object
8 9 10 11 12 |
# File 'lib/dhl/bcs/v2/shipper.rb', line 8 def self.build(company: nil, **attributes) address = Address.build(attributes) communication = Communication.build(attributes) new(attributes.merge(address: address, communication: communication, company: company)) end |
Instance Method Details
#to_soap_hash ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dhl/bcs/v2/shipper.rb', line 20 def to_soap_hash { 'Name' => { 'cis:name1' => name }.tap { |h| h['cis:name2'] = company if company h['cis:name3'] = company_addition if company_addition }, 'Address' => address.to_soap_hash, 'Communication' => communication.to_soap_hash } end |