Sha256: 9186e58467a095757650d6f8cf643bead5a1fc910edb3403fd9d3e60770b1906

Contents?: true

Size: 915 Bytes

Versions: 3

Compression:

Stored size: 915 Bytes

Contents

require 'faraday_middleware'
require 'faraday/response/raise_reshape_api_error'

module Reshape
  module Connection
    private
    def oauth_data
      {
        consumer_key: @consumer_token,
        consumer_secret: @consumer_secret,
        token: @oauth_token,
        token_secret: @oauth_secret
      }
    end
    
    def connection(raw=false, force_urlencoded=false)
      url = "#{Reshape.api_endpoint}"

      options = {
        url: url,
        proxy: proxy,
        ssl: { verify: false },
      }
      
      connection = Faraday.new(options) do |builder|
        builder.use Faraday::Response::RaiseReshapeApiError
        builder.request :json
        builder.request :oauth, oauth_data
        unless raw
          builder.use FaradayMiddleware::Mashify
          builder.use FaradayMiddleware::ParseJson
        end
        builder.adapter *adapter
      end
      connection
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reshape-0.2 lib/reshape/connection.rb
reshape-0.1.1 lib/reshape/connection.rb
reshape-0.1 lib/reshape/connection.rb