# frozen_string_literal: true module GoPuff module TaxService class Configuration attr_writer :base_url, :user_agent_header attr_accessor :authentication, :logger, :requests def initialize @base_url = nil @authentication = Struct.new(:token_provider, :on_unauthorized).new @requests = Struct.new( :max_retries, :retry_wait_time, :retryable_exceptions ).new(3, 0.5, [EOFError, Errno::ECONNRESET]) @logger = ::Rails.logger if defined?(::Rails) && ::Rails&.logger end def user_agent_header return @user_agent_header if @user_agent_header.present? raise "Missing configuration 'user_agent_header' for TaxService gem" end def base_url return @base_url if @base_url.present? raise "Missing configuration 'base_url' for TaxService gem" end def token_provider return @authentication.token_provider if @authentication.token_provider.is_a?(Proc) raise "Missing configuration 'authentication.token_provider' for TaxService gem" end def on_unauthorized return -> {} unless @authentication.on_unauthorized.is_a?(Proc) @authentication.on_unauthorized end end end end