Sha256: c941781086cf82b3d7aa815d0e65c0002a6060cd0a5e539b7c1e79fa55897972

Contents?: true

Size: 671 Bytes

Versions: 2

Compression:

Stored size: 671 Bytes

Contents

# encoding: UTF-8

require "faraday"
require "faraday_middleware"
require "json"

module Dandelionapi

  class Base

    protected

    def call(endpoint, params)
      begin
        params = params.merge(
          :$app_id => Dandelionapi.config.app_id,
          :$app_key => Dandelionapi.config.app_key
        )
        conn = Faraday.new(url: Dandelionapi.config.endpoint) do |faraday|
          faraday.request  :url_encoded
          faraday.adapter  Faraday.default_adapter
        end
        response = conn.post endpoint, params
        JSON.parse response.body
      rescue Exception => e
        raise Dandelionapi::BadResponse
      end
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dandelionapi-0.0.3 lib/dandelionapi/base.rb
dandelionapi-0.0.2 lib/dandelionapi/base.rb