read method

List<HttpInteraction> read()

Returns a list of all HttpInteractions in the cassette.

Implementation

List<HttpInteraction> read() {
  List<HttpInteraction> interactions = [];

  if (!_exists()) {
    return interactions;
  }

  File file = File(_filePath);
  String fileContents = file.readAsStringSync();

  if (fileContents.isNotEmpty) {
    List<dynamic> json = jsonDecode(fileContents);

    interactions = json.map((e) => HttpInteraction.fromJson(e)).toList();
  }

  return interactions;
}