Sha256: c5d5c1cb23640cf85d0c2490f3c328ab0e51d7e83d728bd2c049188e8260e475

Contents?: true

Size: 766 Bytes

Versions: 7

Compression:

Stored size: 766 Bytes

Contents

# frozen_string_literal: true

module FriendlyShipping
  module Services
    class UpsFreight
      class GenerateReferenceHash
        class << self
          # @param [Array] reference_numbers Reference numbers for the Bill of Lading
          # @return [Hash] Reference hash suitable for JSON request
          def call(reference_numbers:)
            return {} unless reference_numbers

            references = reference_numbers.map do |reference_number|
              {
                Number: {
                  Code: reference_number[:code],
                  Value: reference_number[:value]
                }
              }
            end
            references.any? ? { Reference: references } : {}
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
friendly_shipping-0.9.0 lib/friendly_shipping/services/ups_freight/generate_reference_hash.rb
friendly_shipping-0.8.1 lib/friendly_shipping/services/ups_freight/generate_reference_hash.rb
friendly_shipping-0.8.0 lib/friendly_shipping/services/ups_freight/generate_reference_hash.rb
friendly_shipping-0.7.3 lib/friendly_shipping/services/ups_freight/generate_reference_hash.rb
friendly_shipping-0.7.2 lib/friendly_shipping/services/ups_freight/generate_reference_hash.rb
friendly_shipping-0.7.1 lib/friendly_shipping/services/ups_freight/generate_reference_hash.rb
friendly_shipping-0.7.0 lib/friendly_shipping/services/ups_freight/generate_reference_hash.rb