Sha256: b18a6684a0df0eacb3b99d55b13e151de3f632ee5ea2aa61d0d84a087586712f

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

require 'duty_calculator'
module DutyCalculator
  class Client
    def self.new
      ::Faraday.new(url: DutyCalculator.configuration.api_root) do |faraday|
        # middleware
        faraday.use FaradayMiddleware::FollowRedirects
        faraday.use FaradayMiddleware::EncodeJson
        # request defs
        faraday.use Faraday::Request::UrlEncoded
        # response defs
        faraday.use Faraday::Response::ParseXml
        faraday.use Faraday::Response::Mashify
        faraday.use Faraday::Response::RaiseError unless DutyCalculator.configuration.debug
        faraday.response :logger if DutyCalculator.configuration.debug

        faraday.adapter ::Faraday.default_adapter
      end
    end

    def self.api_base
      if DutyCalculator.configuration.sandbox
        return "#{DutyCalculator.configuration.api_version}/sandbox/#{DutyCalculator.configuration.api_key}"
      else
        return "#{DutyCalculator.configuration.api_version}/#{DutyCalculator.configuration.api_key}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
duty_calculator-0.0.4 lib/duty_calculator/client.rb
duty_calculator-0.0.3 lib/duty_calculator/client.rb
duty_calculator-0.0.2 lib/duty_calculator/client.rb
duty_calculator-0.0.1 lib/duty_calculator/client.rb