Sha256: d77e8098fd32fd98d1e98b6f5bd63e6cfdaf657deffa85c9c51d236ffaddd7ba

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

module AnswersEngine
  module Client
    class AuthToken < AnswersEngine::Client::Base

      def find(token)
        self.class.get("/auth_tokens/#{token}", @options)
      end

      def all(opts={})
        self.class.get("/auth_tokens", @options)
      end

      def create(role, description, opts={})
        body = {
            role: role,
            description: description}

        @options.merge!({body: body.to_json})
        self.class.post("/auth_tokens", @options)
      end

      def create_on_account(account_id, role, description)
        body = {
            role: role,
            description: description}

        @options.merge!({body: body.to_json})
        self.class.post("/accounts/#{account_id}/auth_tokens", @options)
      end

      def update(token, role, description="", opts={})
        body = {}

        body[:role] = role
        body[:description] = description if description.present?
        @options.merge!({body: body.to_json})

        self.class.put("/auth_tokens/#{token}", @options)
      end

      def delete(token, opts={})
        body = {}
        @options.merge!({body: body.to_json})

        self.class.delete("/auth_tokens/#{token}", @options)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
answersengine-0.4.1 lib/answersengine/client/auth_token.rb
answersengine-0.4.0 lib/answersengine/client/auth_token.rb
answersengine-0.3.3 lib/answersengine/client/auth_token.rb
answersengine-0.3.2 lib/answersengine/client/auth_token.rb
answersengine-0.3.1 lib/answersengine/client/auth_token.rb
answersengine-0.3.0 lib/answersengine/client/auth_token.rb