Sha256: 0d9a9150c749c20fa64573e2cded95e86c4b21f1c44ce0d8e93e01a20fa4a303
Contents?: true
Size: 720 Bytes
Versions: 2
Compression:
Stored size: 720 Bytes
Contents
# frozen_string_literal: true require 'base64' require 'codat/version' require 'codat/errors' module Codat class FaradayCodatAuth < Faraday::Middleware def initialize(app, api_key = '', options = {}) super() @app = app @api_key = api_key @options = options end def call(env) unless @api_key&.size&.positive? raise APIKeyError, 'Missing api_key! Use a Codat.configure block to add your key.' end env[:request_headers]['Authorization'] = "Basic #{Base64.encode64(@api_key)}" env[:request_headers]['Content-Type'] = 'application/json' env[:request_headers]['User-Agent'] = "finpoint/#{Codat::VERSION}" @app.call(env) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
codat-0.1.8 | lib/codat/faraday_codat_auth.rb |
codat-0.1.7 | lib/codat/faraday_codat_auth.rb |