Sha256: 39e52e92e178d0dc2f6420457c90d16910e56866c55c93bcf9fefc2082c41135

Contents?: true

Size: 761 Bytes

Versions: 1

Compression:

Stored size: 761 Bytes

Contents

# frozen_string_literal: true

module SolidusEasypost
  module Spree
    module AddressDecorator
      def easypost_address
        attributes = {
          street1: address1,
          street2: address2,
          city: city,
          zip: zipcode,
          phone: phone
        }

        attributes[:company] = company if respond_to?(:company)
        attributes[:name] = if respond_to?(:name)
                              name
                            elsif respond_to?(:full_name)
                              full_name
        end
        attributes[:state] = state ? state.abbr : state_name
        attributes[:country] = country&.iso

        ::EasyPost::Address.create attributes
      end

      ::Spree::Address.prepend self
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_easypost-2.0.0 app/decorators/models/solidus_easypost/spree/address_decorator.rb