Sha256: b9000ea576084bdc018d43b1b9c04ef19386cab101026b88c85b11f12bcbc95c
Contents?: true
Size: 1.99 KB
Versions: 15
Compression:
Stored size: 1.99 KB
Contents
# frozen_string_literal: true module PriceHubble module Client # The base API client class definition. It bundles all the separated # application logic on a low level. class Base include PriceHubble::Client::Utils::Request include PriceHubble::Client::Utils::Response include PriceHubble::Utils::Decision include PriceHubble::Utils::Bangers # Configure the connection instance in a generic manner. Each client can # modify the connection in a specific way, when the application requires # special handling. Just overwrite the +configure+ method, and call # +super(con)+. Here is a full example: # # def configure(con) # super(con) # con.request :url_encoded # con.response :logger # con.adapter Faraday.default_adapter # end # # @param con [Faraday::Connection] the connection object # # rubocop:disable Metrics/MethodLength because of the middleware list def configure(con) con.use :instrumentation # The definition order is execution order con.request :ph_data_sanitization con.request :ph_default_headers con.request :json con.request :multipart con.request :url_encoded # The definition order is reverse to the execution order con.response :ph_recursive_open_struct con.response :ph_data_sanitization con.response :dates con.response :json, content_type: /\bjson$/ con.response :follow_redirects con.adapter Faraday.default_adapter end # rubocop:enable Metrics/MethodLength # Create a new Faraday connection on the first shot, and pass the cached # connection object on subsequent calls. # # @return [Faraday::Connection] the connection object def connection @connection ||= Faraday.new(url: PriceHubble.configuration.base_url, &method(:configure)) end end end end
Version data entries
15 entries across 15 versions & 1 rubygems