Sha256: 8b2ae64d6ad97c2975cca29aae6f5c0260dd9dc2f8b603145f387951b95c856c

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

require 'friendly_shipping/item_options'

module FriendlyShipping
  module Services
    class UpsJson
      class LabelItemOptions < FriendlyShipping::ItemOptions
        PRODUCT_UNIT_OF_MEASURE_CODES = {
          barrel: 'BA',
          bundle: 'BE',
          bag: 'BG',
          bunch: 'BH',
          box: 'BOX',
          bolt: 'BT',
          butt: 'BU',
          canister: 'CI',
          centimeter: 'CM',
          container: 'CON',
          crate: 'CR',
          case: 'CS',
          carton: 'CT',
          cylinder: 'CY',
          dozen: 'DOZ',
          each: 'EA',
          envelope: 'EN',
          feet: 'FT',
          kilogram: 'KG',
          kilograms: 'KGS',
          pound: 'LB',
          pounds: 'LBS',
          liter: 'L',
          meter: 'M',
          number: 'NMB',
          packet: 'PA',
          pallet: 'PAL',
          piece: 'PC',
          pieces: 'PCS',
          proof_liters: 'PF',
          package: 'PKG',
          pair: 'PR',
          pairs: 'PRS',
          roll: 'RL',
          set: 'SET',
          square_meters: 'SME',
          square_yards: 'SYD',
          tube: 'TU',
          yard: 'YD',
          other: 'OTH'
        }.freeze

        attr_reader :commodity_code,
                    :country_of_origin

        def initialize(
          commodity_code: nil,
          country_of_origin: nil,
          product_unit_of_measure: :number,
          **kwargs
        )
          @commodity_code = commodity_code
          @country_of_origin = country_of_origin
          @product_unit_of_measure = product_unit_of_measure
          super(**kwargs)
        end

        def product_unit_of_measure_code
          PRODUCT_UNIT_OF_MEASURE_CODES[product_unit_of_measure]
        end

        private

        attr_reader :product_unit_of_measure
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
friendly_shipping-0.9.0 lib/friendly_shipping/services/ups_json/label_item_options.rb