getDevice method

Future<GetDeviceResponse> getDevice({
  1. required String deviceKey,
  2. String? accessToken,
})

Gets the device.

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

Parameter deviceKey : The device key.

Parameter accessToken : The access token.

Implementation

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

  return GetDeviceResponse.fromJson(jsonResponse.body);
}