Sha256: ac8860ed1bad03a9c6e97d5b32f55fe2f75feaf2c4f9d24e325366b359aa1063

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 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={})
        params = @options.merge(opts)
        self.class.get("/auth_tokens", params)
      end

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

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

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

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

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

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

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

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

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
answersengine-0.10.1 lib/answersengine/client/auth_token.rb
answersengine-0.10.0 lib/answersengine/client/auth_token.rb
answersengine-0.9.1 lib/answersengine/client/auth_token.rb
answersengine-0.9.0 lib/answersengine/client/auth_token.rb
answersengine-0.8.0 lib/answersengine/client/auth_token.rb
answersengine-0.7.0 lib/answersengine/client/auth_token.rb
answersengine-0.6.0 lib/answersengine/client/auth_token.rb
answersengine-0.5.0 lib/answersengine/client/auth_token.rb