documents method

Future<List<DocumentSnapshot>> documents([
  1. String? studyId
])

Get all documents for a study.

Can only be accessed by users who are authenticated as researchers.

Note that this might return a very long list of documents and the request may time out.

Implementation

Future<List<DocumentSnapshot>> documents([String? studyId]) async {
  http.Response response = await _get(
    Uri.encodeFull(getDocumentEndpointUri(studyId)),
  );

  // we expect a list of documents in the response
  List<dynamic> documentsJson = _handleResponse(response) as List<dynamic>;
  List<DocumentSnapshot> documents = [];
  for (var item in documentsJson) {
    Map<String, dynamic> documentJson = item as Map<String, dynamic>;
    String key = documentJson["name"].toString();
    documents.add(DocumentSnapshot._(key, documentJson));
  }
  return documents;
}