Sha256: 28f9b55b09e3c0f75f74de52eae23d0cee68db3f922bff14b0eca75f9f74eb12
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
# frozen_string_literal: true module FriendlyShipping module Services class RL # Serialize a physical location for use in an R+L API call. class SerializeLocation class << self # @param [Physical::Location] location # @return [Hash] def call(location) { CompanyName: location.company_name.presence || location.name, AddressLine1: location.address1, AddressLine2: 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 private # R+L does not support periods in city names. # # @param city [String] # @return [String] def clean_city(city) city.delete(".").strip end # R+L does not support leading country codes in phone numbers. # # @param [String] phone # @return [String] def clean_phone(phone) phone.gsub(/^1-/, "").strip end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
friendly_shipping-0.9.0 | lib/friendly_shipping/services/rl/serialize_location.rb |