Class: AvaTax::API
- Inherits:
-
Object
- Object
- AvaTax::API
- Includes:
- Connection, Request
- Defined in:
- lib/avatax/api.rb
Direct Known Subclasses
Instance Method Summary collapse
- #config ⇒ Object
-
#initialize(options = {}) ⇒ API
constructor
A new instance of API.
Methods included from Request
#delete, #get, #post, #put, #request
Constructor Details
#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 |
Instance Method Details
#config ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/avatax/api.rb', line 30 def config conf = {} Configuration::VALID_OPTIONS_KEYS.each do |key| conf[key] = send key end conf end |