lib/openbd/client.rb in openbd_api-0.4.3 vs lib/openbd/client.rb in openbd_api-0.4.4

- old
+ new

@@ -3,10 +3,15 @@ API_BASE_URL = 'http://api.openbd.jp/'.freeze PATH_TO_GET = 'v1/get' PATH_TO_COVERAGE = 'v1/coverage' PATH_TO_SCHEMA = 'v1/schema' + def initialize(adapter: :net_http, response_parser: :json) + @adapter = adapter + @response_parser = response_parser + end + def get(isbns) get_request( method: PATH_TO_GET, params: { isbn: normalize_isbns(isbns) }, response_class: ::OpenBD::Responses::Get @@ -37,11 +42,11 @@ ) end def connection @connection ||= ::Faraday::Connection.new(url: API_BASE_URL) do |connection| - connection.adapter :net_http - connection.response :json + connection.adapter @adapter + connection.response @response_parser end end def get_request(method:, params:, response_class:) faraday_response = connection.get(method, params)