map method

Returns the mock which answers the request of call with its response, or null when canMap is false. The mock has no id until it is saved by NetLensMockRecorder.

Implementation

NetLensMock? map(NetLensHttpCall call) {
  if (!canMap(call)) {
    return null;
  }
  final NetLensReplayRequest request = NetLensReplayRequest.fromCall(call);
  final Uri? url = Uri.tryParse(request.url);
  if (url == null) {
    return null;
  }
  return NetLensMock(
    id: '',
    method: request.method,
    url: url,
    requestBody: request.body,
    requestHeaders: request.headers,
    response: _mapResponse(call),
    createdTime: _clock(),
  );
}