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-1.6.3 lib/datahen/client/auth_token.rb
datahen-1.6.2 lib/datahen/client/auth_token.rb
datahen-1.6.1 lib/datahen/client/auth_token.rb
datahen-1.6.0 lib/datahen/client/auth_token.rb
datahen-1.5.3 lib/datahen/client/auth_token.rb
datahen-1.5.2 lib/datahen/client/auth_token.rb
datahen-1.5.1 lib/datahen/client/auth_token.rb
datahen-1.4.0 lib/datahen/client/auth_token.rb
datahen-1.3.2 lib/datahen/client/auth_token.rb
datahen-1.3.1 lib/datahen/client/auth_token.rb
datahen-1.3.0 lib/datahen/client/auth_token.rb
datahen-1.2.3 lib/datahen/client/auth_token.rb
datahen-1.2.2 lib/datahen/client/auth_token.rb
datahen-1.2.1 lib/datahen/client/auth_token.rb
datahen-1.1.2 lib/datahen/client/auth_token.rb
datahen-1.1.1 lib/datahen/client/auth_token.rb
datahen-1.0.3 lib/datahen/client/auth_token.rb
datahen-1.0.2 lib/datahen/client/auth_token.rb
datahen-1.0.1 lib/datahen/client/auth_token.rb
datahen-1.0.0 lib/datahen/client/auth_token.rb