Sha256: 042eb2cfdd21655d9cef388398d1235f5b1a2f24948e8bdc0358d46dcb02d406

Contents?: true

Size: 939 Bytes

Versions: 6

Compression:

Stored size: 939 Bytes

Contents

require 'faraday'
require 'flattr/core_ext/hash'
require 'flattr/request/oauth2'
require 'flattr/response/parse_json'
require 'flattr/response/raise_client_error'
require 'flattr/response/raise_server_error'

module Flattr
  module Connection
  private
    def connection(connection_options={})
      default_options = {
        :headers => {
          :accept => 'application/json',
          :user_agent => user_agent,
        },
        :proxy => proxy,
        :ssl => {:verify => false},
        :url => endpoint,
      }
      Faraday.new(default_options.deep_merge(connection_options)) do |builder|

        builder.use Flattr::Request::FlattrOAuth2, credentials if credentials?
        builder.use Flattr::Response::RaiseClientError
        builder.use Flattr::Response::ParseJson unless connection_options[:raw]
        builder.use Flattr::Response::RaiseServerError

        builder.adapter(adapter)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
flattr-0.3.7 lib/flattr/connection.rb
flattr-0.3.6 lib/flattr/connection.rb
flattr-0.3.5 lib/flattr/connection.rb
flattr-0.3.4 lib/flattr/connection.rb
flattr-0.3.3 lib/flattr/connection.rb
flattr-0.3.2 lib/flattr/connection.rb