getConsentDocument method

Future<ConsentDocument> getConsentDocument(
  1. int id
)

Get a previously uploaded (signed) ConsentDocument based on its id.

Implementation

Future<ConsentDocument> getConsentDocument(int id) async {
  String url = "$consentDocumentEndpointUri/$id";

  // GET the consent document from the CARP web service
  http.Response response =
      await httpr.get(Uri.encodeFull(url), headers: headers);

  int httpStatusCode = response.statusCode;
  Map<String, dynamic> responseJson =
      json.decode(response.body) as Map<String, dynamic>;

  if (httpStatusCode == HttpStatus.ok) return ConsentDocument._(responseJson);

  // All other cases are treated as an error.
  throw CarpServiceException(
    httpStatus: HTTPStatus(httpStatusCode, response.reasonPhrase),
    message: responseJson["message"].toString(),
    path: responseJson["path"].toString(),
  );
}