Class: Dhl::Bcs::V2::ExportDocPosition

Inherits:
Object
  • Object
show all
Includes:
Buildable
Defined in:
lib/dhl/bcs/v2/export_document.rb

Constant Summary collapse

PROPERTIES =
%i(description country_code_origin customs_tariff_number amount net_weight_in_kg customs_value).freeze

Instance Method Summary collapse

Methods included from Buildable

included

Constructor Details

#initialize(**attributes) ⇒ ExportDocPosition

Returns a new instance of ExportDocPosition.



63
64
65
66
67
# File 'lib/dhl/bcs/v2/export_document.rb', line 63

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

Instance Method Details

#to_soap_hashObject

Raises:



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/dhl/bcs/v2/export_document.rb', line 69

def to_soap_hash
  raise Dhl::Bcs::Error, 'export doc position description must be set' unless description
  raise Dhl::Bcs::Error, 'export doc position country_code_origin must be set'  unless country_code_origin
  raise Dhl::Bcs::Error, 'export doc position customs_tariff_number must be set' unless customs_tariff_number
  raise Dhl::Bcs::Error, 'export doc position amount must be set' unless amount
  raise Dhl::Bcs::Error, 'export doc position net_weight_in_kg must be set' unless net_weight_in_kg
  raise Dhl::Bcs::Error, 'export doc position customs_value must be set' unless customs_value
  {
    'description' => description,
    'countryCodeOrigin' => country_code_origin,
    'customsTariffNumber' => customs_tariff_number,
    'amount' => amount,
    'netWeightInKG' => net_weight_in_kg,
    'customsValue' => customs_value
  }
end