class Dhl::Bcs::V2::ExportDocument

Constants

EXPORT_TYPES
PROPERTIES
TERMS_OF_TRADES

Public Class Methods

build(export_doc_positions = [], **attributes) click to toggle source
# 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
new(**attributes) click to toggle source
# 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

Public Instance Methods

export_type=(export_type) click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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