Sha256: 6e0f9c441a04635349e5400415b1c4021d3a28f1d5b42a5bad5554798ce64c47

Contents?: true

Size: 972 Bytes

Versions: 1

Compression:

Stored size: 972 Bytes

Contents

require 'oauth'

class TwoPerformant
  class OAuth
    attr_accessor :access_token, :consumer

    def initialize(options, host)
      consumer = ::OAuth::Consumer.new(options[:consumer_token], options[:consumer_secret], {:site => host})
      @access_token = ::OAuth::AccessToken.new(consumer, options[:access_token], options[:access_secret])
    end

    def get(path, params) 
      params ||= {}
      response = access_token.get("#{path}?#{params.to_params}")
      Crack::XML.parse(response.body)
    end

    def post(path, params) 
      params ||= {}
      response = access_token.post(path, params)
      Crack::XML.parse(response.body)
    end

    def put(path, params) 
      params ||= {}
      response = access_token.put(path, params)
      Crack::XML.parse(response.body)
    end

    def delete(path, params) 
      params ||= {}
      response = access_token.delete("#{path}?#{params.to_params}")
      Crack::XML.parse(response.body)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
2Performant-0.0.1 lib/two_performant/oauth.rb