deleteDevices method

Future<void> deleteDevices(
  1. List<String> devices, {
  2. AuthenticationData? auth,
})
inherited

This API endpoint uses the User-Interactive Authentication API.

Deletes the given devices, and invalidates any access token associated with them.

auth Additional authentication information for the user-interactive authentication API.

devices The list of device IDs to delete.

Implementation

Future<void> deleteDevices(List<String> devices,
    {AuthenticationData? auth}) async {
  final requestUri = Uri(path: '_api/client/v3/delete_devices');
  final request = Request('POST', baseUri!.resolveUri(requestUri));
  request.headers['authorization'] = 'Bearer ${bearerToken!}';
  request.headers['content-type'] = 'application/json';
  request.bodyBytes = utf8.encode(jsonEncode({
    if (auth != null) 'auth': auth.toJson(),
    'devices': devices.map((v) => v).toList(),
  }));
  final response = await httpClient.send(request);
  final responseBody = await response.stream.toBytes();
  if (response.statusCode != 200) unexpectedResponse(response, responseBody);
  final responseString = utf8.decode(responseBody);
  final json = jsonDecode(responseString);
  return ignore(json);
}