Sha256: 97900db948d610d6dc39bf5f3328ff89c808a7058fa8afc1b33f8f0d88eec8c9

Contents?: true

Size: 542 Bytes

Versions: 3

Compression:

Stored size: 542 Bytes

Contents

module Firmapi
  class API

    def get(url, params)
      params = default_params.merge params

      connexion.get api_url(url), params
    end

    private

      def connexion
        @connexion ||= Faraday.new(url: 'https://firmapi.com') do |faraday|
          faraday.response :json, content_type: /\bjson$/
          faraday.adapter  Faraday.default_adapter
        end
      end

      def default_params
        { api_key: Firmapi.configuration.api_key }
      end

      def api_url(url)
        "/api/v1#{url}"
      end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
firmapi-0.1.4 lib/firmapi/api.rb
firmapi-0.1.3 lib/firmapi/api.rb
firmapi-0.1.2 lib/firmapi/api.rb