postLoginDId method

Future<SDNDIDLoginResponse> postLoginDId({
  1. required String type,
  2. required String updated,
  3. Map<String, dynamic>? identifier,
  4. String? random,
  5. String? random_server,
  6. ClientPublicKey? client_key,
})
inherited

Implementation

Future<SDNDIDLoginResponse> postLoginDId(
    {required String type,
    required String updated,
    Map<String, dynamic>? identifier,
    String? random,
    String? random_server,
    ClientPublicKey? client_key}) async {
  final requestUri = Uri(path: '_api/client/unstable/did/login');
  final request = Request('POST', baseUri!.resolveUri(requestUri));
  print("url: ${baseUri!.resolveUri(requestUri)}");
  request.headers['content-type'] = 'application/json';
  var jsonNew = jsonEncode({
    if (type != null) 'type': type,
    if (updated != null) 'updated': updated,
    if (identifier != null) 'identifier': identifier,
    if (random != null) 'random': random,
    if (random_server != null) 'random_server': random_server,
    if (client_key != null) 'client_key': client_key.toJson(),
  });
  request.bodyBytes = utf8.encode(jsonNew);
  print("body:$jsonNew");
  final response = await httpClient.send(request);
  print("response=$response");
  final responseBody = await response.stream.toBytes();
  print("response=$responseBody");
  final responseString = utf8.decode(responseBody);
  print("responseString=$responseString");
  if (response.statusCode != 200) unexpectedResponse(response, responseBody);
  final json = jsonDecode(responseString);
  return SDNDIDLoginResponse.fromJson(json as Map<String, Object?>);
}