Sha256: 108d0f9fce87ca34765951fd8e3e7fb122ad8c7bae8ae35e3eecb6b1819be913

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'fifthgear'
module Fifthgear
  class Client
    def self.new
      Faraday.new(:url => Fifthgear.configuration.api_root ) do |faraday|
        # middleware
        faraday.use FaradayMiddleware::FollowRedirects
        faraday.use FaradayMiddleware::EncodeJson
        # request defs
        faraday.use Faraday::Request::BasicAuthentication, Fifthgear.configuration.username, Fifthgear.configuration.password
        faraday.use Faraday::Request::UrlEncoded
        # response defs
        faraday.use Faraday::Response::ParseJson
        faraday.use Faraday::Response::Mashify
        faraday.use Faraday::Response::RaiseError if Fifthgear.configuration.raise_errors
        faraday.response :logger if Fifthgear.configuration.debug

        faraday.headers['Content-Type'] = Fifthgear.configuration.content_type
        faraday.adapter ::Faraday.default_adapter

        # timeout options are in seconds
        faraday.options.timeout = Fifthgear.configuration.timeout
        faraday.options.open_timeout = Fifthgear.configuration.open_timeout
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fifthgear-0.0.8 lib/fifthgear/client.rb