Sha256: 9e67574c896357659de7d44c3e9d420a7a3f28fb977f02822fa8855ea600b792

Contents?: true

Size: 1.26 KB

Versions: 41

Compression:

Stored size: 1.26 KB

Contents

module Datahen
  module Client
    class AuthToken < Datahen::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}).merge(opts)
        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

41 entries across 41 versions & 1 rubygems

Version Path
datahen-0.14.15 lib/datahen/client/auth_token.rb