getSubmissions method

Stream<JotformSubmission> getSubmissions(
  1. String id, {
  2. int offset = 0,
  3. int limit = 20,
  4. String? filter,
  5. JotformOrderBy? orderBy,
})

Implementation

Stream<JotformSubmission> getSubmissions(String id,
    {int offset = 0,
    int limit = 20,
    String? filter,
    JotformOrderBy? orderBy}) async* {
  yield* await http
      .get(getUrl("form/$id/submissions", params: {
    "offset": offset.toString(),
    "limit": limit.toString(),
    if (filter != null) "filter": filter,
    if (orderBy != null) "orderBy": orderBy.name.replaceAll("_", "")
  }))
      .then((value) {
    Map<String, dynamic> body = jsonDecode(value.body);
    if (body["limit-left"] is int) {
      limitLeft = body["limit-left"];
    }
    return Stream.fromIterable((body["content"] as List<dynamic>)
        .whereType<Map<String, dynamic>>()
        .map((i) => JotformSubmissionMapper.fromMap(i)));
  });
}