Class: Dhl::Bcs::V2::ExportDocument
- Inherits:
-
Object
- Object
- Dhl::Bcs::V2::ExportDocument
- Includes:
- Buildable
- Defined in:
- lib/dhl/bcs/v2/export_document.rb
Constant Summary collapse
- PROPERTIES =
%i(invoice_number export_type export_type_description terms_of_trade place_of_commital additional_fee permit_number attestation_number with_electronic_export_notification export_doc_positions).freeze
- EXPORT_TYPES =
%w(OTHER PRESENT COMMERCIAL_SAMPLE DOCUMENT RETURN_OF_GOODS).freeze
- TERMS_OF_TRADES =
%w(DDP DXV DDU DDX).freeze
Class Method Summary collapse
Instance Method Summary collapse
- #export_type=(export_type) ⇒ Object
-
#initialize(**attributes) ⇒ ExportDocument
constructor
A new instance of ExportDocument.
- #terms_of_trade=(terms_of_trade) ⇒ Object
- #to_soap_hash ⇒ Object
Methods included from Buildable
Constructor Details
#initialize(**attributes) ⇒ ExportDocument
Returns a new instance of ExportDocument.
19 20 21 22 23 |
# File 'lib/dhl/bcs/v2/export_document.rb', line 19 def initialize(**attributes) attributes.each do |property, value| send("#{property}=", value) if PROPERTIES.include?(property) end end |
Class Method Details
.build(export_doc_positions = [], **attributes) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/dhl/bcs/v2/export_document.rb', line 11 def self.build(export_doc_positions = [], **attributes) array_of_export_doc_positions = [] export_doc_positions.each do |export_doc_position| array_of_export_doc_positions << ExportDocPosition.build(export_doc_position) if export_doc_position.is_a?(Hash) end new({ export_doc_positions: array_of_export_doc_positions }.merge(attributes)) end |
Instance Method Details
#export_type=(export_type) ⇒ Object
25 26 27 28 |
# File 'lib/dhl/bcs/v2/export_document.rb', line 25 def export_type=(export_type) raise Dhl::Bcs::Error, "No Valid export_type #{export_type}, Please use one of these: #{EXPORT_TYPES.join(',')}" unless EXPORT_TYPES.include?(export_type) @export_type = export_type end |
#terms_of_trade=(terms_of_trade) ⇒ Object
30 31 32 33 |
# File 'lib/dhl/bcs/v2/export_document.rb', line 30 def terms_of_trade=(terms_of_trade) raise Dhl::Bcs::Error, "No Valid terms_of_trade #{terms_of_trade}, Please use one of these: #{TERMS_OF_TRADES.join(',')}" unless TERMS_OF_TRADES.include?(terms_of_trade) @terms_of_trade = terms_of_trade end |
#to_soap_hash ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/dhl/bcs/v2/export_document.rb', line 35 def to_soap_hash raise Dhl::Bcs::Error, "export_doc_position must be set as an array." unless export_doc_positions raise Dhl::Bcs::Error, "export_type_desription must be set, as export_type is set to OTHER." unless !((export_type == 'OTHER') ^ export_type_description) raise Dhl::Bcs::Error, "place_of_commital must be set" unless place_of_commital h = {} h['invoiceNumber'] = invoice_number if invoice_number h['exportType'] = export_type h['exportTypeDescription'] = export_type_description if export_type_description h['termsOfTrade'] = terms_of_trade if terms_of_trade h['placeOfCommital'] = place_of_commital h['additionalFee'] = additional_fee if additional_fee h['permitNumber'] = permit_number if permit_number h['attestationNumber'] = attestation_number if attestation_number h['WithElectronicExportNtfctn/'] = {'@active': 1} if with_electronic_export_notification h['ExportDocPosition'] = self.export_doc_positions.map { |e| e.to_soap_hash } h end |