Sha256: 2f0a50e459b7456c5870a27f335b1659f559bbaade5d8e826e72cc766889899f
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
# frozen_string_literal: true module SolidusEasypost class AddressBuilder class << self def from_address(address) attributes = { street1: address.address1, street2: address.address2, city: address.city, zip: address.zipcode, phone: address.phone } attributes[:company] = address.company if address.respond_to?(:company) attributes[:name] = if address.respond_to?(:name) address.name elsif respond_to?(:full_name) address.full_name end attributes[:state] = address.state ? address.state.abbr : address.state_name attributes[:country] = address.country&.iso ::EasyPost::Address.create attributes end def from_stock_location(stock_location) attributes = { street1: stock_location.address1, street2: stock_location.address2, city: stock_location.city, zip: stock_location.zipcode, phone: stock_location.phone, name: stock_location.name, company: stock_location.name } attributes[:state] = stock_location.state ? stock_location.state.abbr : stock_location.state_name attributes[:country] = stock_location.country&.iso ::EasyPost::Address.create attributes end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solidus_easypost-3.0.0 | lib/solidus_easypost/address_builder.rb |