Class: FriendlyShipping::Services::UpsFreight::GenerateReferenceHash

Inherits:
Object
  • Object
show all
Defined in:
lib/friendly_shipping/services/ups_freight/generate_reference_hash.rb

Class Method Summary collapse

Class Method Details

.call(reference_numbers:) ⇒ Hash

Returns Reference hash suitable for JSON request.

Parameters:

  • reference_numbers (Array)

    Reference numbers for the Bill of Lading

Returns:

  • (Hash)

    Reference hash suitable for JSON request



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/friendly_shipping/services/ups_freight/generate_reference_hash.rb', line 10

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