diff --git a/lib/auth0/api/v2/device_credentials.rb b/lib/auth0/api/v2/device_credentials.rb index 5ba81db6..7a1d36e8 100644 --- a/lib/auth0/api/v2/device_credentials.rb +++ b/lib/auth0/api/v2/device_credentials.rb @@ -13,6 +13,9 @@ module DeviceCredentials # * :include_fields [boolean] True if the fields specified are to be included in the result, false otherwise. # * :user_id [string] The user_id of the devices to retrieve. # * :type [string] Type of credentials to retrieve. Must be 'public_key', 'refresh_token' or 'rotating_refresh_token' + # * :page [integer] The page number. Zero based + # * :per_page [integer] The amount of entries per page + # * :include_totals [boolean] Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). # # @return [json] Returns the list of existing devices for the specified client_id. # rubocop:disable Metrics/AbcSize @@ -22,7 +25,10 @@ def device_credentials(client_id, options = {}) include_fields: options.fetch(:include_fields, nil), user_id: options.fetch(:user_id, nil), client_id: client_id, - type: options.fetch(:type, nil) + type: options.fetch(:type, nil), + page: options.fetch(:page, nil), + per_page: options.fetch(:per_page, nil), + include_totals: options.fetch(:include_totals, nil) } raise Auth0::InvalidParameter, 'Must supply a valid client_id' if client_id.to_s.empty? if !request_params[:type].nil? && !%w(public_key refresh_token rotating_refresh_token).include?(request_params[:type]) diff --git a/spec/lib/auth0/api/v2/device_credentials_spec.rb b/spec/lib/auth0/api/v2/device_credentials_spec.rb index 7d9ef636..e690c496 100644 --- a/spec/lib/auth0/api/v2/device_credentials_spec.rb +++ b/spec/lib/auth0/api/v2/device_credentials_spec.rb @@ -18,10 +18,27 @@ include_fields: nil, user_id: nil, client_id: client_id, - type: nil + type: nil, + page: nil, + per_page: nil, + include_totals: nil }) expect { @instance.device_credentials(client_id) }.not_to raise_error end + it 'is expected to send get request with options to /api/v2/device-credentials' do + expect(@instance).to receive(:get).with( + '/api/v2/device-credentials', { + fields: 'name', + include_fields: true, + user_id: '1', + client_id: client_id, + type: 'rotating_refresh_token', + page: 1, + per_page: 10, + include_totals: true + }) + expect { @instance.device_credentials(client_id, fields: 'name', include_fields: true, user_id: '1', type: 'rotating_refresh_token', page: 1, per_page: 10, include_totals: true) }.not_to raise_error + end it 'is expect to raise an error when type is not one of \'public_key\', \'refresh_token\', \'rotating_refresh_token\'' do expect { @instance.device_credentials(client_id, type: 'invalid_type') }.to raise_error( 'Type must be one of \'public_key\', \'refresh_token\', \'rotating_refresh_token\''