Sha256: 1ed88ea85812a929b7b182c24260b06f90e140a0c73e251b6e221a080356a12b

Contents?: true

Size: 829 Bytes

Versions: 6

Compression:

Stored size: 829 Bytes

Contents

require 'faraday'
require 'faraday_middleware'
require 'tumblr/request/oauth'

module Tumblr
  module Connection

    def connection(options={})
      host = api_host
      default_options = {
        :headers => {
          :accept => 'application/json',
          :user_agent => "tumblr_client (ruby) - #{Tumblr::VERSION}"
        },
        :url => "http://#{host}/"
      }
      Faraday.new("http://#{host}/", default_options.merge(options)) do |builder|
        data = { :api_host => host }.merge(credentials)
        unless credentials.empty?
          builder.use Tumblr::Request::TumblrOAuth, data
        end
        builder.use Faraday::Request::UrlEncoded
        builder.use FaradayMiddleware::ParseJson, :content_type => 'application/json'
        builder.use Faraday::Adapter::NetHttp
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tumblr_client-0.7.5 lib/tumblr/connection.rb
tumblr_client-0.7.4 lib/tumblr/connection.rb
tumblr_client-0.7.3 lib/tumblr/connection.rb
tumblr_client-0.7.2 lib/tumblr/connection.rb
tumblr_client-0.7.1 lib/tumblr/connection.rb
tumblr_client-0.7.0 lib/tumblr/connection.rb