module Medlink class Client def initialize(api_key) @api_key = api_key end attr_reader :api_key def get(url, params = {}) params[:api_key] = api_key client.get(api_url(url), params) end private def client @client ||= Faraday.new(url: site) do |faraday| faraday.request :url_encoded # form-encode POST params faraday.adapter Faraday.default_adapter # make requests with Net::HTTP end end def site Medlink.configuration.site end def api_url(url) "/api/#{url}" end end end