Module: Auth0::Api::V2::DeviceCredentials
- Included in:
- Auth0::Api::V2
- Defined in:
- lib/auth0/api/v2/device_credentials.rb
Overview
Methods to use the device credentials endpoints
Instance Method Summary collapse
-
#create_device_credential(device_name, value, device_id, client_id) ⇒ json
(also: #create_device_public_key)
Creates a new device public key.
-
#delete_device_credential(id) ⇒ Object
Deletes a single device credential given its id.
-
#device_credentials(client_id = nil, options = {}) ⇒ json
(also: #list_device_credentials)
Retrieves log entries that match the specified search criteria.
Instance Method Details
#create_device_credential(device_name, value, device_id, client_id) ⇒ json Also known as: create_device_public_key
Creates a new device public key.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/auth0/api/v2/device_credentials.rb', line 48 def create_device_credential(device_name, value, device_id, client_id) raise Auth0::InvalidParameter, 'Must supply a valid device_name' if device_name.to_s.empty? raise Auth0::InvalidParameter, 'Must supply a valid value' if value.to_s.empty? raise Auth0::InvalidParameter, 'Must supply a valid device_id' if device_id.to_s.empty? raise Auth0::InvalidParameter, 'Must supply a valid client_id' if client_id.to_s.empty? request_params = { device_name: device_name, type: 'public_key', value: value, device_id: device_id, client_id: client_id } post(device_credentials_path, request_params) end |
#delete_device_credential(id) ⇒ Object
Deletes a single device credential given its id.
67 68 69 70 71 |
# File 'lib/auth0/api/v2/device_credentials.rb', line 67 def delete_device_credential(id) raise Auth0::InvalidParameter, 'Must supply a valid id' if id.to_s.empty? path = "#{device_credentials_path}/#{id}" delete(path) end |
#device_credentials(client_id = nil, options = {}) ⇒ json Also known as: list_device_credentials
Retrieves log entries that match the specified search criteria. rubocop:disable Metrics/AbcSize
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/auth0/api/v2/device_credentials.rb', line 22 def device_credentials(client_id = nil, = {}) request_params = { fields: .fetch(:fields, nil), include_fields: .fetch(:include_fields, nil), user_id: .fetch(:user_id, nil), client_id: client_id, type: .fetch(:type, nil), page: .fetch(:page, nil), per_page: .fetch(:per_page, nil), include_totals: .fetch(:include_totals, nil) } if !request_params[:type].nil? && !%w(public_key refresh_token rotating_refresh_token).include?(request_params[:type]) raise Auth0::InvalidParameter, 'Type must be one of \'public_key\', \'refresh_token\', \'rotating_refresh_token\'' end get(device_credentials_path, request_params) end |