Method: AvaTax::API#initialize
- Defined in:
- lib/avatax/api.rb
#initialize(options = {}) ⇒ API
Returns a new instance of API.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/avatax/api.rb', line 11 def initialize(={}) = AvaTax..merge() # The default logger in Faraday is configured exactly the same as this one, but we cannot get a reference to it, so we will instantiate our own. default_logger = Logger.new(STDOUT) Configuration::VALID_OPTIONS_KEYS.each do |key| send("#{key}=", [key]) end ActiveSupport::Notifications.subscribe("request.faraday") do |name, starts, ends, _, env| url = env[:url] duration = (ends - starts) * 1000 if custom_logger custom_logger.info "The request to #{url} took #{duration} ms." elsif logger default_logger.info "The request to #{url} took #{duration} ms." end end end |