Sha256: c6a4662bb9b014a6fd09a02d8870a773f0f449855cc75da1f279b33ee8a419fb

Contents?: true

Size: 802 Bytes

Versions: 2

Compression:

Stored size: 802 Bytes

Contents

require 'faraday'
require 'faraday_middleware'

module Tumblr
  module Connection

    def connection(options={})
      
      default_options = {
        :headers => {
          :accept => 'application/json',
          :user_agent => "tumblr_client (ruby) - #{Tumblr::VERSION}"
        },
        :url => "http://#{api_host}/"
      }

      client = options[:client] ||= Faraday.default_adapter

      Faraday.new("http://#{api_host}/", default_options.merge(options)) do |conn|
        data = { :api_host => api_host }.merge(credentials)
        unless credentials.empty?
          conn.request :oauth, data
        end
        conn.request :multipart
        conn.request :url_encoded
        conn.response :json, :content_type => /\bjson$/
        conn.adapter client
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tumblr_client-0.8.2 lib/tumblr/connection.rb
tumblr_client-0.8.1 lib/tumblr/connection.rb