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(client_id: nil, audience: nil, page: nil, per_page: nil) ⇒ json Also known as: get_all_client_grants

Retrieves a list of all client grants.

Parameters:

  • client_id (string) (defaults to: nil)

    The client_id of the client grant to retrieve.

  • audience (string) (defaults to: nil)

    The audience of the client grant to retrieve.

  • page (int) (defaults to: nil)

    Page number to get, 0-based.

  • per_page (int) (defaults to: nil)

    Results per page if also passing a page number.

Returns:

  • (json)

    Returns the client grants.

See Also:



15
16
17
18
19
20
21
22
23
# File 'lib/auth0/api/v2/client_grants.rb', line 15

def client_grants (client_id: nil, audience: nil, page: nil, per_page: nil)
  request_params = {
    client_id: client_id,
    audience: audience,
    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:



31
32
33
34
# File 'lib/auth0/api/v2/client_grants.rb', line 31

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:



39
40
41
42
43
# File 'lib/auth0/api/v2/client_grants.rb', line 39

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:



49
50
51
52
53
54
# File 'lib/auth0/api/v2/client_grants.rb', line 49

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