Class: FriendlyShipping::Services::TForceFreight::GenerateLocationHash

Inherits:
Object
  • Object
show all
Defined in:
lib/friendly_shipping/services/tforce_freight/generate_location_hash.rb

Overview

Generates a location hash for JSON serialization.

Class Method Summary collapse

Class Method Details

.call(location:) ⇒ Hash

Returns location hash suitable for JSON request.

Parameters:

  • location (Physical::Location)

    the location

Returns:

  • (Hash)

    location hash suitable for JSON request



11
12
13
14
15
16
17
18
19
20
# File 'lib/friendly_shipping/services/tforce_freight/generate_location_hash.rb', line 11

def call(location:)
  {
    address: {
      city: location.city,
      stateProvinceCode: location.region&.code,
      postalCode: location.zip&.strip&.[](0..4),
      country: location.country&.code
    }.compact
  }
end