callRPCv1 method

  1. @override
Future<JRPC1Response> callRPCv1(
  1. JRPC1Request req, {
  2. String? pathSuffix,
  3. Uri? uri,
})
override

Implementation

@override
Future<JRPC1Response> callRPCv1(JRPC1Request req,
    {String? pathSuffix, Uri? uri}) async {
  uri ??= this.uri;
  if (pathSuffix != null) {
    uri = uri.replace(path: uri.path + pathSuffix);
  }
  final body = json.encode(req.toJson());
  final headers = {
    HttpHeaders.contentTypeHeader: 'application/json-rpc',
    HttpHeaders.acceptHeader: 'application/json-rpc'
  };
  if (basicAuth != null) {
    headers[HttpHeaders.authorizationHeader] = 'Basic $basicAuth';
  }
  final resp = await client.post(uri, headers: headers, body: body);
  return JRPC1Response.fromMap(json.decode(resp.body));
}