Class: FriendlyShipping::Services::TForceFreight::GenerateReferenceHash
- Inherits:
-
Object
- Object
- FriendlyShipping::Services::TForceFreight::GenerateReferenceHash
- Defined in:
- lib/friendly_shipping/services/tforce_freight/generate_reference_hash.rb
Overview
Generates a reference hash for JSON serialization.
Class Method Summary collapse
-
.call(reference_numbers:) ⇒ Hash
Reference hash suitable for JSON request.
Class Method Details
.call(reference_numbers:) ⇒ Hash
Returns reference hash suitable for JSON request.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/friendly_shipping/services/tforce_freight/generate_reference_hash.rb', line 11 def call(reference_numbers:) return {} unless reference_numbers references = reference_numbers.map do |reference_number| { number: reference_number[:value], type: reference_number[:code], quantity: reference_number[:quantity], weight: reference_number[:weight] }.compact end references.any? ? { references: references } : {} end |