Class: FriendlyShipping::Services::RL::SerializeLocation

Inherits:
Object
  • Object
show all
Defined in:
lib/friendly_shipping/services/rl/serialize_location.rb

Overview

Serialize a physical location for use in an R+L API call.

Class Method Summary collapse

Class Method Details

.call(location) ⇒ Hash

Parameters:

  • location (Physical::Location)

Returns:

  • (Hash)


11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/friendly_shipping/services/rl/serialize_location.rb', line 11

def call(location)
  {
    CompanyName: location.company_name.presence || location.name,
    AddressLine1: truncate(location.address1),
    AddressLine2: truncate(location.address2),
    City: clean_city(location.city),
    StateOrProvince: location.region.code,
    ZipOrPostalCode: location.zip,
    CountryCode: location.country.alpha_3_code,
    PhoneNumber: clean_phone(location.phone),
    EmailAddress: location.email
  }.compact
end