toRequest method

Converts the request parameters to BlockforestRequestDetails with a unique identifier.

Implementation

BlockforestRequestDetails toRequest(int v) {
  final pathParams = BlockforestProviderUtils.extractParams(method);
  if (pathParams.length != pathParameters.length) {
    throw MessageException("Invalid Path Parameters.", details: {
      "pathParams": pathParameters,
      "ExceptedPathParametersLength": pathParams.length
    });
  }
  String params = method;
  for (int i = 0; i < pathParams.length; i++) {
    params = params.replaceFirst(pathParams[i], pathParameters[i]);
  }
  if (filter != null) {
    params = Uri.parse(params)
        .replace(queryParameters: filter!.toJson())
        .normalizePath()
        .toString();
  }
  return BlockforestRequestDetails(id: v, pathParams: params);
}