Sha256: 617251182fe874655b4d35bd1efd30d25e2b2bfce4c4467ce4e2c5654f34dd75

Contents?: true

Size: 1.12 KB

Versions: 14

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module FriendlyShipping
  module Services
    class UpsFreight
      class LabelDocumentOptions
        attr_reader :format, :type, :length, :width, :thermal

        DOCUMENT_TYPES = {
          label: "30",
          ups_bol: "20",
          vics_bol: "21"
        }.freeze

        DOCUMENT_FORMATS = {
          pdf: "01"
        }.freeze

        THERMAL_CODE = {
          false => "01",
          true => "02"
        }.freeze

        def initialize(
          format: :pdf,
          type: :label,
          size: "4x6",
          thermal: false,
          labels_per_page: 1
        )
          @format = format
          @type = type
          @length, @width = size.split('x').sort
          @thermal = thermal
          @labels_per_page = labels_per_page
        end

        def format_code
          DOCUMENT_FORMATS.fetch(format)
        end

        def document_type_code
          DOCUMENT_TYPES.fetch(type)
        end

        def thermal_code
          THERMAL_CODE.fetch(thermal)
        end

        def labels_per_page
          @labels_per_page.to_s
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
friendly_shipping-0.9.0 lib/friendly_shipping/services/ups_freight/label_document_options.rb
friendly_shipping-0.8.1 lib/friendly_shipping/services/ups_freight/label_document_options.rb
friendly_shipping-0.8.0 lib/friendly_shipping/services/ups_freight/label_document_options.rb
friendly_shipping-0.7.3 lib/friendly_shipping/services/ups_freight/label_document_options.rb
friendly_shipping-0.7.2 lib/friendly_shipping/services/ups_freight/label_document_options.rb
friendly_shipping-0.7.1 lib/friendly_shipping/services/ups_freight/label_document_options.rb
friendly_shipping-0.7.0 lib/friendly_shipping/services/ups_freight/label_document_options.rb
friendly_shipping-0.6.5 lib/friendly_shipping/services/ups_freight/label_document_options.rb
friendly_shipping-0.6.4 lib/friendly_shipping/services/ups_freight/label_document_options.rb
friendly_shipping-0.6.3 lib/friendly_shipping/services/ups_freight/label_document_options.rb
friendly_shipping-0.6.2 lib/friendly_shipping/services/ups_freight/label_document_options.rb
friendly_shipping-0.6.1 lib/friendly_shipping/services/ups_freight/label_document_options.rb
friendly_shipping-0.6.0 lib/friendly_shipping/services/ups_freight/label_document_options.rb
friendly_shipping-0.5.3 lib/friendly_shipping/services/ups_freight/label_document_options.rb