Sha256: efce8da509bf19fd8b274365d91fe6e6cde3eb05be9329d0a758027fc7a63c9f

Contents?: true

Size: 1.08 KB

Versions: 16

Compression:

Stored size: 1.08 KB

Contents

require 'json'
module Oauth
  module Models
    module Consumers
      # This is just a simple
      class SimpleClient
        attr_reader :token
  
        def initialize(token)
          @token = token
        end
  
  
        def put(path,params={})
          parse(token.put(path,params, {'Accept' => 'application/json'}))
        end

        def delete(path)
          parse(token.delete(path, {'Accept' => 'application/json'}))
        end

        def post(path,params={})
          parse(token.post(path,params, {'Accept' => 'application/json'}))
        end

        def get(path)
          parse(token.get(path, {'Accept' => 'application/json'}))
        end

        protected

        def parse(response)
          return false unless response
          if ["200","201"].include? response.code
            unless response.body.blank?
              JSON.parse(response.body)
            else
              true
            end
          else
            logger.debug "Got Response code: #{response.code}"
            false
          end
          
        end
        
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
oauth-plugin-0.4.0.rc2 lib/oauth/models/consumers/simple_client.rb
oauth-plugin-0.4.0.rc1 lib/oauth/models/consumers/simple_client.rb
oauth-plugin-0.4.0.pre7 lib/oauth/models/consumers/simple_client.rb
oauth-plugin-0.4.0.pre6 lib/oauth/models/consumers/simple_client.rb
oauth-plugin-0.4.0.pre5 lib/oauth/models/consumers/simple_client.rb
insrc-oauth-plugin-0.4.0.pre6 lib/oauth/models/consumers/simple_client.rb
insrc-oauth-plugin-0.4.0.pre5 lib/oauth/models/consumers/simple_client.rb
le1t0-oauth-plugin-0.3.14.001 lib/oauth/models/consumers/simple_client.rb
le1t0-oauth-plugin-0.4.0.pre4.001 lib/oauth/models/consumers/simple_client.rb
oauth-plugin-0.4.0.pre4 lib/oauth/models/consumers/simple_client.rb
oauth-plugin-0.4.0.pre3 lib/oauth/models/consumers/simple_client.rb
oauth-plugin-0.4.0.pre2 lib/oauth/models/consumers/simple_client.rb
oauth-plugin-0.4.0.pre1 lib/oauth/models/consumers/simple_client.rb
oauth-plugin-0.3.14 lib/oauth/models/consumers/simple_client.rb
oauth-plugin-0.3.13 lib/oauth/models/consumers/simple_client.rb
oauth-plugin-0.3.12 lib/oauth/models/consumers/simple_client.rb