Module: Auth0::Api::V2::ClientGrants

Included in:
Auth0::Api::V2
Defined in:
lib/auth0/api/v2/client_grants.rb

Overview

Methods to use the client grants endpoints

Instance Method Summary collapse

Instance Method Details

#client_grants(page: nil, per_page: nil) ⇒ json Also known as: get_all_client_grants

Retrieves a list of all client grants.

Parameters:

  • page (int)

    Page number to get, 0-based.

  • per_page (int)

    Results per page if also passing a page number.

Returns:

  • (json)

    Returns the client grants.

See Also:


13
14
15
16
17
18
19
# File 'lib/auth0/api/v2/client_grants.rb', line 13

def client_grants (page: nil, per_page: nil)
  request_params = {
    page: page,
    per_page: per_page
  }
  get(client_grants_path, request_params)
end

#create_client_grant(options = {}) ⇒ json

Creates a new client grant.

Parameters:

  • options (hash) (defaults to: {})

    The Hash options used to define the client grant's properties.

Returns:

  • (json)

    Returns the created client grant.

See Also:


27
28
29
30
# File 'lib/auth0/api/v2/client_grants.rb', line 27

def create_client_grant(options = {})
  request_params = Hash[options.map { |(k, v)| [k.to_sym, v] }]
  post(client_grants_path, request_params)
end

#delete_client_grant(client_grant_id) ⇒ Object

Deletes a client grant given its id.

Parameters:

  • client_grant_id (string)

    The id of the client grant to delete.

Raises:

See Also:


35
36
37
38
39
# File 'lib/auth0/api/v2/client_grants.rb', line 35

def delete_client_grant(client_grant_id)
  raise Auth0::InvalidParameter, 'Must specify a client grant id' if client_grant_id.to_s.empty?
  path = "#{client_grants_path}/#{client_grant_id}"
  delete(path)
end

#patch_client_grant(client_grant_id, options) ⇒ Object Also known as: update_client_grant

Updates a client grant.

Parameters:

  • client_grant_id (string)

    The id of the client grant to update.

  • options (hash)

    The Hash options used to define the client grant's properties.

Raises:

See Also:


45
46
47
48
49
50
# File 'lib/auth0/api/v2/client_grants.rb', line 45

def patch_client_grant(client_grant_id, options)
  raise Auth0::InvalidParameter, 'Must specify a client grant id' if client_grant_id.to_s.empty?
  raise Auth0::InvalidParameter, 'Must specify a valid body' if options.to_s.empty?
  path = "#{client_grants_path}/#{client_grant_id}"
  patch(path, options)
end