Sha256: 35bb0c44d4df01a692a3b8bb0d1d7f178dddae1e53b92d007eeab263fbd25698

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

module Bushido
  class Command
    class << self
      def get_command(url, params={})
        params.merge!({:auth_token => Bushido::User.authentication_token}) if params[:auth_token].nil? unless Bushido::User.authentication_token.nil?

        raw = RestClient.get(url, {:params => params, :accept => :json})
        response = JSON.parse raw    
      end

      def post_command(url, params)
        params.merge!({:auth_token => Bushido::User.authentication_token}) if params[:auth_token].nil? unless Bushido::User.authentication_token.nil?

        raw = RestClient.post(url, params.to_json, :content_type => :json, :accept => :json)
        response = JSON.parse raw    
      end

      def put_command(url, params)
        Bushido::Utils.while_authorized do
          params.merge!({:auth_token => Bushido::User.authentication_token}) if params[:auth_token].nil? unless Bushido::User.authentication_token.nil?

          raw = RestClient.put(url, params.to_json,  :content_type => :json)
          response = JSON.parse raw
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bushido-0.0.3 lib/bushido/command.rb
bushido-0.0.2 lib/bushido/command.rb
bushido-0.0.1 lib/bushido/command.rb