fetchPostReports method

Future<List<ReportModel>> fetchPostReports(
  1. dynamic postId
)

Implementation

Future<List<ReportModel>> fetchPostReports(postId) {
  Log(
    logName: 'FetchPostReports',
    className: 'Report',
    methodName: 'fetchPostReports',
    type: 'INFO',
    text:
        '{event: Fetch Post Reports, user: ${currentUser?.userPayloadId}, user is ${currentUser?.firstName} ${currentUser?.lastName}, post id: $postId',
  );
  return _httpService.fetchReportByPostId(postId).then((data) async {
    if (data.statusCode == 200) {
      List<dynamic> reports = json.decode(data.body);
      List<ReportModel> reportsList =
          reports.map((i) => ReportModel.fromJson(i)).toList();
      return reportsList;
    } else {
      return List<ReportModel>.from([]);
    }
  });
}