Sha256: 0f16abf29a5c54388a70feb2d40f26d9e09f89d1a4e37c10adb9c2981893a73b

Contents?: true

Size: 983 Bytes

Versions: 5

Compression:

Stored size: 983 Bytes

Contents

module GnipApi
  module Adapters
    class HTTPartyAdapter < GnipApi::Adapters::BaseAdapter
      def post request
        data = HTTParty.post request.uri, :basic_auth => auth, :body => request.payload
        return response(request, data)
      end
      
      def delete request
        data = HTTParty.delete request.uri, :basic_auth => auth, :body => request.payload
        return response(request, data)
      end
      
      def get request
        data = HTTParty.get request.uri, :basic_auth => auth
        return response(request, data)
      end

      def stream_get request
        HTTParty.get request.uri, :headers => request.headers, :basic_auth => auth do |data|
          yield(data)
        end
      end

      def auth
        {
          :username => username,
          :password => password
        }
      end
      
      def response request, data
        create_response request, data.code, data.body, data.headers
      end
      
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gnip_api-0.0.6 lib/gnip_api/adapters/httparty_adapter.rb
gnip_api-0.0.5 lib/gnip_api/adapters/httparty_adapter.rb
gnip_api-0.0.4 lib/gnip_api/adapters/httparty_adapter.rb
gnip_api-0.0.3 lib/gnip_api/adapters/httparty_adapter.rb
gnip_api-0.0.2 lib/gnip_api/adapters/httparty_adapter.rb