@veloceapps/api 9.0.0-9 → 10.0.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -868,8 +868,8 @@ class DocumentTemplatesApiService {
868
868
  this.fileDownloadService = fileDownloadService;
869
869
  this.documentAttachmentService = documentAttachmentService;
870
870
  this.http = http;
871
- this.DOCGEN_TAG = 'docgen';
872
871
  this.SERVICE_URL = '/templates';
872
+ this.DOCGEN_TAG = 'docgen';
873
873
  this.DOC_GEN_URL_FALLBACK = `${window.VELO_API}/docgen`;
874
874
  this.mapSfQueryResult = (limit) => map((records) => {
875
875
  if (!records.length) {
@@ -981,6 +981,29 @@ class DocumentTemplatesApiService {
981
981
  responseType: 'arraybuffer',
982
982
  });
983
983
  }
984
+ generateDocumentV2(body, quoteId, isAsync) {
985
+ body['docgenURL'] = window.VELO_DOCGEN_API ?? '';
986
+ const params = {};
987
+ if (isAsync) {
988
+ params['async'] = 'true';
989
+ }
990
+ return this.service
991
+ .api({
992
+ method: 'post',
993
+ url: `/docgen/${quoteId}/generate`,
994
+ body,
995
+ params,
996
+ responseType: 'arraybuffer',
997
+ })
998
+ .pipe(map(pdf => {
999
+ const blob = new Blob([pdf]);
1000
+ const documentName = body.parameters['documentName'] ?? 'Veloce Proposal';
1001
+ if (!isAsync) {
1002
+ this.fileDownloadService.processDownload(blob, `${documentName}.${body.documentFormat.toLowerCase()}`);
1003
+ }
1004
+ return blob;
1005
+ }));
1006
+ }
984
1007
  getAttachments(searchRequest) {
985
1008
  return this.documentAttachmentService.getAttachments(searchRequest);
986
1009
  }