confirmDevice method

Future<ConfirmDeviceResponse> confirmDevice({
  1. required String accessToken,
  2. required String deviceKey,
  3. String? deviceName,
  4. DeviceSecretVerifierConfigType? deviceSecretVerifierConfig,
})

Confirms tracking of the device. This API call is the call that begins device tracking.

May throw ResourceNotFoundException. May throw InvalidParameterException. May throw NotAuthorizedException. May throw InvalidPasswordException. May throw InvalidLambdaResponseException. May throw UsernameExistsException. May throw InvalidUserPoolConfigurationException. May throw TooManyRequestsException. May throw PasswordResetRequiredException. May throw UserNotFoundException. May throw UserNotConfirmedException. May throw InternalErrorException.

Parameter accessToken : The access token.

Parameter deviceKey : The device key.

Parameter deviceName : The device name.

Parameter deviceSecretVerifierConfig : The configuration of the device secret verifier.

Implementation

Future<ConfirmDeviceResponse> confirmDevice({
  required String accessToken,
  required String deviceKey,
  String? deviceName,
  DeviceSecretVerifierConfigType? deviceSecretVerifierConfig,
}) async {
  ArgumentError.checkNotNull(accessToken, 'accessToken');
  ArgumentError.checkNotNull(deviceKey, 'deviceKey');
  _s.validateStringLength(
    'deviceKey',
    deviceKey,
    1,
    55,
    isRequired: true,
  );
  _s.validateStringLength(
    'deviceName',
    deviceName,
    1,
    1024,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSCognitoIdentityProviderService.ConfirmDevice'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'AccessToken': accessToken,
      'DeviceKey': deviceKey,
      if (deviceName != null) 'DeviceName': deviceName,
      if (deviceSecretVerifierConfig != null)
        'DeviceSecretVerifierConfig': deviceSecretVerifierConfig,
    },
  );

  return ConfirmDeviceResponse.fromJson(jsonResponse.body);
}