Module: Auth0::Api::V2::Clients
- Included in:
- Auth0::Api::V2
- Defined in:
- lib/auth0/api/v2/clients.rb
Overview
Methods to use the client endpoints
Instance Method Summary collapse
-
#client(client_id, fields: nil, include_fields: nil) ⇒ json
Retrieves a client by its id.
-
#clients(fields: nil, include_fields: nil) ⇒ json
(also: #get_clients)
Retrieves a list of all client applications.
-
#create_client(name, options = {}) ⇒ json
Creates a new client application.
-
#delete_client(client_id) ⇒ Object
Deletes a client and all its related assets (like rules, connections, etc) given its id.
-
#patch_client(client_id, options) ⇒ Object
Updates a client.
Instance Method Details
#client(client_id, fields: nil, include_fields: nil) ⇒ json
Retrieves a client by its id.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/auth0/api/v2/clients.rb', line 42 def client(client_id, fields: nil, include_fields: nil) raise Auth0::MissingClientId, 'Must specify a client id' if client_id.to_s.empty? include_fields = true if !fields.nil? && include_fields.nil? request_params = { fields: fields, include_fields: include_fields } path = "#{clients_path}/#{client_id}" get(path, request_params) end |
#clients(fields: nil, include_fields: nil) ⇒ json Also known as: get_clients
Retrieves a list of all client applications. Accepts a list of fields to include or exclude.
14 15 16 17 18 19 20 21 |
# File 'lib/auth0/api/v2/clients.rb', line 14 def clients(fields: nil, include_fields: nil) include_fields = true if !fields.nil? && include_fields.nil? request_params = { fields: fields, include_fields: include_fields } get(clients_path, request_params) end |
#create_client(name, options = {}) ⇒ json
Creates a new client application.
29 30 31 32 33 34 |
# File 'lib/auth0/api/v2/clients.rb', line 29 def create_client(name, = {}) raise Auth0::MissingParameter, 'Must specify a valid client name' if name.to_s.empty? request_params = Hash[.map { |(k, v)| [k.to_sym, v] }] request_params[:name] = name post(clients_path, request_params) end |
#delete_client(client_id) ⇒ Object
Deletes a client and all its related assets (like rules, connections, etc) given its id.
56 57 58 59 60 |
# File 'lib/auth0/api/v2/clients.rb', line 56 def delete_client(client_id) raise Auth0::MissingClientId, 'Must specify a client id' if client_id.to_s.empty? path = "#{clients_path}/#{client_id}" delete(path) end |
#patch_client(client_id, options) ⇒ Object
Updates a client.
66 67 68 69 70 71 |
# File 'lib/auth0/api/v2/clients.rb', line 66 def patch_client(client_id, ) raise Auth0::MissingClientId, 'Must specify a client id' if client_id.to_s.empty? raise Auth0::MissingParameter, 'Must specify a valid body' if .to_s.empty? path = "#{clients_path}/#{client_id}" patch(path, ) end |