Sha256: bc08a9e6d1ea685697e18a39ac819ec6901afbd4316fcff6973048bc25289dd7

Contents?: true

Size: 765 Bytes

Versions: 1

Compression:

Stored size: 765 Bytes

Contents

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

module Tumblr
  module Connection
    def connection(options={})
      default_options = {
        :headers => {
          :accept => "application/json",
          :user_agent => "Tumblr v1.0"
        },
        :url => "http://#{api_host}/"
      }
      Faraday.new("http://#{api_host}/", default_options.merge(options)) do |builder|
        data = { :api_host => api_host }.merge(credentials)
        builder.use Tumblr::Request::TumblrOAuth, data unless credentials.empty?
        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

1 entries across 1 versions & 1 rubygems

Version Path
tumblr_client-0.6.11 lib/tumblr/connection.rb