Sha256: b45487c8f73b6600c6fcd08bfbda68353a0e3bb62ce9b92033a28aa801ba0546

Contents?: true

Size: 895 Bytes

Versions: 2

Compression:

Stored size: 895 Bytes

Contents

module DHLEcommerceAPI
  # Component item
  class Shipment::ShipmentItem < Base
    self.element_name = ""

    # add some validations?
    DEFAULT_ATTRIBUTES = { 
      shipment_id: nil,
      package_desc: "",
      total_weight: nil,
      total_weight_uom: "G",
      dimension_uom: "CM",
      height: nil,
      length: nil,
      width: nil,
      product_code: "PDO",
      cod_value: nil,
      insurance_value: nil,
      total_value: 300,
      currency: "MYR",
      remarks: nil,
      is_routing_info_required: "Y",
      consignee_address: {}
    }

    def initialize(attributes = {}, persisted = false)
      status = attributes["response_status"]
      if status.present? && status["code"] != "200"
        error_messages = status["message_details"].map{|err| err["message_detail"]}
        handle_errors(status["code"], error_messages) 
      end
      super
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dhl_ecommerce_api-0.1.11 lib/dhl_ecommerce_api/resources/shipment/shipment_item.rb
dhl_ecommerce_api-0.1.9 lib/dhl_ecommerce_api/resources/shipment/shipment_item.rb