module Workarea::Avatax

Constants

VERSION

Public Class Methods

auto_configure_gateway() click to toggle source
# File lib/workarea/avatax.rb, line 32
def self.auto_configure_gateway
  if Rails.application.secrets.avatax.present?
    avatax_secrets = Rails.application.secrets.avatax.deep_symbolize_keys

    connection_options = {
      request: { timeout: avatax_secrets[:timeout] || 2 }
    }

    if ENV["HTTP_PROXY"].present?
      connection_options.merge!(proxy: ENV["HTTP_PROXY"])
    end

    ::AvaTax.configure do |config|
      if avatax_secrets[:endpoint].present?
        config.endpoint = avatax_secrets[:endpoint]
      end

      config.username = avatax_secrets[:username]
      config.password = avatax_secrets[:password]
      config.connection_options = connection_options
    end
    self.gateway = ::AvaTax.client
  elsif gateway.blank?
    self.gateway = Avatax::BogusGateway.new
  end
end
commit?() click to toggle source
# File lib/workarea/avatax.rb, line 20
def self.commit?
  config.order_handling == :commit
end
gateway() click to toggle source
# File lib/workarea/avatax.rb, line 28
def self.gateway
  Workarea.config.gateways.avatax
end
gateway=(gateway) click to toggle source
# File lib/workarea/avatax.rb, line 24
def self.gateway=(gateway)
  Workarea.config.gateways.avatax = gateway
end