getEstimatePdf method

Future<Uint8List> getEstimatePdf({
  1. required String estimateId,
  2. String? realmId,
  3. String? authToken,
})

This resource returns the specified object in the response body as an Adobe Portable Document Format (PDF) file. The resulting PDF file is formatted according to custom form styles in the company settings.

Implementation

Future<Uint8List> getEstimatePdf({
  required String estimateId,
  String? realmId,
  String? authToken,
}) async {

  authToken ??= authenticationService.getCachedToken()?.access_token;
  realmId ??= authenticationService.getCachedRealmId();

  Map<String, String> headers = {
    "Authorization": "Bearer ${authToken ?? ""}",
    'Content-Type': 'application/json; charset=UTF-8',
    //'Accept': 'application/json',

  };

  Map<String, String> params = {
    "minorversion": minorVersion.toString()
  };


  Uri endpoint = Uri.https(
      baseUrl, "/v3/company/$realmId/estimate/$estimateId/pdf", params);

  //print (endpoint.toString());

  var response = await
  http.get(endpoint, headers: headers);

  if (response.statusCode == 200) {
    return response.bodyBytes;
  }
  else {
    throw EstimateException(statusCode: response.statusCode, message: response.body);
  }
}