Sha256: b12d56e5d00160a3b2dad05b21f4ed07d8aaa85eb0f6f63353969b61215a0965
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
#encoding: utf-8 module HH class Client include API include Request # @param options [Hash] def default_middleware(options={}) Proc.new do |conn| conn.request :multipart conn.adapter :net_http conn.response :logger if ENV['DEBUG'] end end @stack = nil # Exposes middleware builder to facilitate custom stacks # @param options [Hash] # @return [Faraday::RackBuilder] def stack(options={}, &block) @stack ||= begin if block_given? Faraday::RackBuilder.new(&block) else Faraday::RackBuilder.new(&default_middleware(options)) end end end # @param options [Hash] # @return [Faraday::Connection] def connection(options={}) conn_options = default_options(options) puts "OPTIONS:#{conn_options.inspect}" if ENV['DEBUG'] @connection ||= Faraday.new(conn_options.merge(builder: stack(options))) end private # @param options [Hash] # @return [Hash] def default_options(options={}) { headers: { accept: "application/json;q=0.1", accept_charset: "utf-8", user_agent: "Ruby gem HH version #{HH::VERSION}", content_type: "application/json" }, url: API_URL }.merge(options) end end end #HH
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hh-0.0.7 | lib/hh/client.rb |
hh-0.0.6 | lib/hh/client.rb |