postPreLoginDID method

Future<SDNLoginResponse> postPreLoginDID({
  1. String? did,
  2. String? address,
  3. String? random,
  4. String? device_id,
  5. ClientPublicKey? client_key,
})
inherited

Implementation

Future<SDNLoginResponse> postPreLoginDID(
    {String? did,
    String? address,
    String? random,
    String? device_id,
    ClientPublicKey? client_key}) async {
  final requestUri = Uri(path: '_api/client/unstable/did/pre_login1');
  final request = Request('POST', baseUri!.resolveUri(requestUri));
  request.headers['content-type'] = 'application/json';
  request.bodyBytes = utf8.encode(jsonEncode({
    if (did != null) 'did': did,
    if (address != null) 'address': address,
    if (random != null) 'random': random,
    if (client_key != null) 'device_id': client_key,
    if (device_id != null) 'device_id': device_id,
    if (client_key != null) 'client_key': client_key.toJson(),
  }));
  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);
  var responseNew = SDNLoginResponse.fromJson(json as Map<String, Object?>);
  return responseNew;
}