lib/panoptes/endpoints/base_endpoint.rb in panoptes-client-0.2.12 vs lib/panoptes/endpoints/base_endpoint.rb in panoptes-client-0.2.13

- old
+ new

@@ -3,26 +3,27 @@ require 'faraday/panoptes' module Panoptes module Endpoints class BaseEndpoint - attr_reader :auth, :url, :prefix + attr_reader :auth, :url, :prefix, :params # @param auth [Hash<token: String, client_id: String, client_secret: String>] Authentication details # * either nothing, # * a hash with +:token+ (an existing OAuth user token), # * or a hash with +:client_id+ and +:client_secret+ # (a keypair for an OAuth Application). # @param url [String] API location to use. # @param prefix [String] An optional API url prefix # @yield Allows an optional block to configure the faraday connection # @yieldparam faraday [Faraday::Connection] The faraday connection - def initialize(auth: {}, url: nil, prefix: nil, &config) + def initialize(auth: {}, url: nil, prefix: nil, params: nil, &config) @auth = auth @url = url @prefix = prefix @config = config + @params = params end def connection @connection ||= Faraday.new(url) do |faraday| auth_request faraday, auth @@ -80,9 +81,12 @@ else faraday.request :panoptes_api_v1 faraday.request :json faraday.response :json faraday.adapter Faraday.default_adapter + if @params + faraday.params = @params + end end end def auth_request(faraday, auth) if auth[:token]