formatUri static method

Uri formatUri({
  1. required String protocol,
  2. required String version,
  3. required String topic,
  4. required String symKey,
  5. required Relay relay,
  6. required List<List<String>>? methods,
  7. int? expiry,
})

Implementation

static Uri formatUri({
  required String protocol,
  required String version,
  required String topic,
  required String symKey,
  required Relay relay,
  required List<List<String>>? methods,
  int? expiry,
}) {
  Map<String, String> params = formatRelayParams(relay);
  params['symKey'] = symKey;
  if (methods != null) {
    final uriMethods = methods.expand((e) => e).toList();
    params['methods'] =
        uriMethods.map((e) => jsonEncode(e)).join(',').replaceAll('"', '');
  }

  if (expiry != null) {
    params['expiryTimestamp'] = expiry.toString();
  }

  return Uri(
    scheme: protocol,
    path: '$topic@$version',
    queryParameters: params,
  );
}