-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClient.js
More file actions
1948 lines (1775 loc) · 82.8 KB
/
Client.js
File metadata and controls
1948 lines (1775 loc) · 82.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* DocSpring API
* Use DocSpring's API to programmatically fill out PDF forms, convert HTML to PDFs, merge PDFs, or request legally binding e-signatures.
*
* The version of the OpenAPI document: v1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*
*/
import ApiClient from "../ApiClient";
import AddFieldsData from '../model/AddFieldsData';
import BatchGeneratePdfs201Response from '../model/BatchGeneratePdfs201Response';
import CombinePdfsData from '../model/CombinePdfsData';
import CombinedSubmission from '../model/CombinedSubmission';
import CopyTemplateOptions from '../model/CopyTemplateOptions';
import CreateCombinedSubmissionResponse from '../model/CreateCombinedSubmissionResponse';
import CreateCustomFileData from '../model/CreateCustomFileData';
import CreateCustomFileResponse from '../model/CreateCustomFileResponse';
import CreateFolderData from '../model/CreateFolderData';
import CreateHtmlTemplate from '../model/CreateHtmlTemplate';
import CreatePdfSubmissionData from '../model/CreatePdfSubmissionData';
import CreatePdfTemplate from '../model/CreatePdfTemplate';
import CreateSubmissionDataRequestEventRequest from '../model/CreateSubmissionDataRequestEventRequest';
import CreateSubmissionDataRequestEventResponse from '../model/CreateSubmissionDataRequestEventResponse';
import CreateSubmissionDataRequestResponse from '../model/CreateSubmissionDataRequestResponse';
import CreateSubmissionDataRequestTokenResponse from '../model/CreateSubmissionDataRequestTokenResponse';
import CreateSubmissionResponse from '../model/CreateSubmissionResponse';
import ErrorOrMultipleErrorsResponse from '../model/ErrorOrMultipleErrorsResponse';
import ErrorResponse from '../model/ErrorResponse';
import Folder from '../model/Folder';
import JsonSchema from '../model/JsonSchema';
import ListSubmissionsResponse from '../model/ListSubmissionsResponse';
import MoveFolderData from '../model/MoveFolderData';
import MoveTemplateData from '../model/MoveTemplateData';
import MultipleErrorsResponse from '../model/MultipleErrorsResponse';
import PublishVersionData from '../model/PublishVersionData';
import RenameFolderData from '../model/RenameFolderData';
import RestoreVersionData from '../model/RestoreVersionData';
import Submission from '../model/Submission';
import Submission422Response from '../model/Submission422Response';
import SubmissionBatchData from '../model/SubmissionBatchData';
import SubmissionBatchWithSubmissions from '../model/SubmissionBatchWithSubmissions';
import SubmissionDataRequestShow from '../model/SubmissionDataRequestShow';
import SubmissionPreview from '../model/SubmissionPreview';
import SuccessErrorResponse from '../model/SuccessErrorResponse';
import SuccessMultipleErrorsResponse from '../model/SuccessMultipleErrorsResponse';
import Template from '../model/Template';
import TemplateAddFieldsResponse from '../model/TemplateAddFieldsResponse';
import TemplateDeleteResponse from '../model/TemplateDeleteResponse';
import TemplatePreview from '../model/TemplatePreview';
import TemplatePublishVersionResponse from '../model/TemplatePublishVersionResponse';
import UpdateHtmlTemplate from '../model/UpdateHtmlTemplate';
import UpdatePdfTemplate from '../model/UpdatePdfTemplate';
import UpdateSubmissionDataRequestData from '../model/UpdateSubmissionDataRequestData';
import UploadPresignResponse from '../model/UploadPresignResponse';
/**
* Client service.
* @module api/Client
* @version 3.0.0
*/
export default class Client {
/**
* Constructs a new Client.
* @alias module:api/Client
* @class
* @param {module:ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
constructor(options = {}) {
// Support both old style (apiClient) and new style (options object)
if (options && options.constructor && options.constructor.name === 'ApiClient') {
this.apiClient = options;
} else {
const apiClient = options.apiClient || ApiClient.instance;
const env = (typeof process !== 'undefined' && process.env) ? process.env : {};
const apiTokenId = options.apiTokenId !== undefined ? options.apiTokenId : env.DOCSPRING_TOKEN_ID ?? null;
const apiTokenSecret = options.apiTokenSecret !== undefined ? options.apiTokenSecret : env.DOCSPRING_TOKEN_SECRET ?? null;
if (apiTokenId != null && apiTokenSecret != null) {
apiClient.authentications['api_token_basic'].username = apiTokenId;
apiClient.authentications['api_token_basic'].password = apiTokenSecret;
}
// Resolve host from options.host, DOCSPRING_HOST, or region (options.region/DOCSPRING_REGION)
let host = options.host || env.DOCSPRING_HOST || null;
const region = options.region || env.DOCSPRING_REGION || null;
if (!host && region) {
const r = String(region).trim().toUpperCase();
if (r === 'US') host = 'sync.api.docspring.com';
else if (r === 'EU') host = 'sync.api-eu.docspring.com';
else throw new Error(`${region} is not a valid region. Valid regions: US, EU`);
}
if (host) {
let url = host;
if (!/^https?:\/\//i.test(url)) url = `https://${url}`;
if (!/\/api\/v1\/?$/i.test(url)) url = `${url.replace(/\/$/, '')}/api/v1`;
apiClient.basePath = url;
}
this.apiClient = apiClient;
}
}
/**
* Callback function to receive the result of the addFieldsToTemplate operation.
* @callback module:api/Client~addFieldsToTemplateCallback
* @param {String} error Error message, if any.
* @param {module:model/TemplateAddFieldsResponse} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Add new fields to a Template
* Adds fields to a PDF template. Configure field types, positions, defaults, and formatting options.
* @param {String} template_id
* @param {module:model/AddFieldsData} data
* @param {module:api/Client~addFieldsToTemplateCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/TemplateAddFieldsResponse}
*/
addFieldsToTemplate(template_id, data, callback) {
let postBody = data;
// verify the required parameter 'template_id' is set
if (template_id === undefined || template_id === null) {
throw new Error("Missing the required parameter 'template_id' when calling addFieldsToTemplate");
}
// verify the required parameter 'data' is set
if (data === undefined || data === null) {
throw new Error("Missing the required parameter 'data' when calling addFieldsToTemplate");
}
let pathParams = {
'template_id': template_id
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = TemplateAddFieldsResponse;
return this.apiClient.callApi(
'/templates/{template_id}/add_fields', 'PUT',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the batchGeneratePdfs operation.
* @callback module:api/Client~batchGeneratePdfsCallback
* @param {String} error Error message, if any.
* @param {module:model/BatchGeneratePdfs201Response} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Generate multiple PDFs
* Generates up to 50 PDFs in a single request. Each submission can use a different template and data. Supports both synchronous (wait for all PDFs) and asynchronous processing. More efficient than individual requests when creating multiple PDFs. See also: - [Batch and Combine PDFs](https://docspring.com/docs/api-guide/generate-pdfs/batch-generate-pdfs/) - Generate and merge PDFs in one request
* @param {module:model/SubmissionBatchData} data
* @param {Object} opts Optional parameters
* @param {Boolean} [wait = true)] Wait for submission batch to be processed before returning. Set to false to return immediately. Default: true (on sync.* subdomain)
* @param {module:api/Client~batchGeneratePdfsCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/BatchGeneratePdfs201Response}
*/
batchGeneratePdfs(data, opts, callback) {
opts = opts || {};
let postBody = data;
// verify the required parameter 'data' is set
if (data === undefined || data === null) {
throw new Error("Missing the required parameter 'data' when calling batchGeneratePdfs");
}
let pathParams = {
};
let queryParams = {
'wait': opts['wait']
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = BatchGeneratePdfs201Response;
return this.apiClient.callApi(
'/submissions/batches', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the combinePdfs operation.
* @callback module:api/Client~combinePdfsCallback
* @param {String} error Error message, if any.
* @param {module:model/CreateCombinedSubmissionResponse} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Merge submission PDFs, template PDFs, or custom files
* Combines multiple PDFs from various sources into a single PDF file. Supports merging submission PDFs, template PDFs, custom files, other merged PDFs, and PDFs from URLs. Merges the PDFs in the order provided.
* @param {module:model/CombinePdfsData} data
* @param {module:api/Client~combinePdfsCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/CreateCombinedSubmissionResponse}
*/
combinePdfs(data, callback) {
let postBody = data;
// verify the required parameter 'data' is set
if (data === undefined || data === null) {
throw new Error("Missing the required parameter 'data' when calling combinePdfs");
}
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = CreateCombinedSubmissionResponse;
return this.apiClient.callApi(
'/combined_submissions', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the copyTemplate operation.
* @callback module:api/Client~copyTemplateCallback
* @param {String} error Error message, if any.
* @param {module:model/TemplatePreview} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Copy a template
* Creates a copy of an existing template with all its fields and configuration. Optionally specify a new name and target folder. The copied template starts as a new draft that can be modified independently of the original.
* @param {String} template_id
* @param {Object} opts Optional parameters
* @param {module:model/CopyTemplateOptions} [options]
* @param {module:api/Client~copyTemplateCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/TemplatePreview}
*/
copyTemplate(template_id, opts, callback) {
opts = opts || {};
let postBody = opts['options'];
// verify the required parameter 'template_id' is set
if (template_id === undefined || template_id === null) {
throw new Error("Missing the required parameter 'template_id' when calling copyTemplate");
}
let pathParams = {
'template_id': template_id
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = TemplatePreview;
return this.apiClient.callApi(
'/templates/{template_id}/copy', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the createCustomFileFromUpload operation.
* @callback module:api/Client~createCustomFileFromUploadCallback
* @param {String} error Error message, if any.
* @param {module:model/CreateCustomFileResponse} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Create a new custom file from a cached S3 upload
* The Custom Files API endpoint allows you to upload PDFs to DocSpring and then merge them with other PDFs. First upload your file using the presigned URL endpoint, then use the returned cache_id to create the custom file.
* @param {module:model/CreateCustomFileData} data
* @param {module:api/Client~createCustomFileFromUploadCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/CreateCustomFileResponse}
*/
createCustomFileFromUpload(data, callback) {
let postBody = data;
// verify the required parameter 'data' is set
if (data === undefined || data === null) {
throw new Error("Missing the required parameter 'data' when calling createCustomFileFromUpload");
}
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = CreateCustomFileResponse;
return this.apiClient.callApi(
'/custom_files', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the createDataRequestEvent operation.
* @callback module:api/Client~createDataRequestEventCallback
* @param {String} error Error message, if any.
* @param {module:model/CreateSubmissionDataRequestEventResponse} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Create a new event for emailing a signee a request for signature
* Records user notification events for data requests. Use this to create an audit trail showing when and how users were notified about data request forms. Supports email, SMS, and other notification types. Records the notification time for compliance tracking. See also: - [Embedded Data Requests Guide](https://docspring.com/docs/guides/embedded-forms/embedded-data-requests/) - User notification workflow
* @param {String} data_request_id
* @param {module:model/CreateSubmissionDataRequestEventRequest} event
* @param {module:api/Client~createDataRequestEventCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/CreateSubmissionDataRequestEventResponse}
*/
createDataRequestEvent(data_request_id, event, callback) {
let postBody = event;
// verify the required parameter 'data_request_id' is set
if (data_request_id === undefined || data_request_id === null) {
throw new Error("Missing the required parameter 'data_request_id' when calling createDataRequestEvent");
}
// verify the required parameter 'event' is set
if (event === undefined || event === null) {
throw new Error("Missing the required parameter 'event' when calling createDataRequestEvent");
}
let pathParams = {
'data_request_id': data_request_id
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = CreateSubmissionDataRequestEventResponse;
return this.apiClient.callApi(
'/data_requests/{data_request_id}/events', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the createDataRequestToken operation.
* @callback module:api/Client~createDataRequestTokenCallback
* @param {String} error Error message, if any.
* @param {module:model/CreateSubmissionDataRequestTokenResponse} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Create a new data request token for form authentication
* Creates an authentication token for accessing a data request form. Tokens can be created for API access (1 hour expiration) or email links (30 day expiration). Returns a token and a pre-authenticated URL for the data request form. See also: - [Embedded Data Requests Guide](https://docspring.com/docs/guides/embedded-forms/embedded-data-requests/)
* @param {String} data_request_id
* @param {Object} opts Optional parameters
* @param {module:model/String} [type]
* @param {module:api/Client~createDataRequestTokenCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/CreateSubmissionDataRequestTokenResponse}
*/
createDataRequestToken(data_request_id, opts, callback) {
opts = opts || {};
let postBody = null;
// verify the required parameter 'data_request_id' is set
if (data_request_id === undefined || data_request_id === null) {
throw new Error("Missing the required parameter 'data_request_id' when calling createDataRequestToken");
}
let pathParams = {
'data_request_id': data_request_id
};
let queryParams = {
'type': opts['type']
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = CreateSubmissionDataRequestTokenResponse;
return this.apiClient.callApi(
'/data_requests/{data_request_id}/tokens', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the createFolder operation.
* @callback module:api/Client~createFolderCallback
* @param {String} error Error message, if any.
* @param {module:model/Folder} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Create a folder
* Creates a new folder for organizing templates. Folders can be nested within other folders by providing a `parent_folder_id`. Folder names must be unique within the same parent.
* @param {module:model/CreateFolderData} data
* @param {module:api/Client~createFolderCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/Folder}
*/
createFolder(data, callback) {
let postBody = data;
// verify the required parameter 'data' is set
if (data === undefined || data === null) {
throw new Error("Missing the required parameter 'data' when calling createFolder");
}
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = Folder;
return this.apiClient.callApi(
'/folders/', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the createHtmlTemplate operation.
* @callback module:api/Client~createHtmlTemplateCallback
* @param {String} error Error message, if any.
* @param {module:model/TemplatePreview} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Create a new HTML template
* Creates a new HTML template using HTML, CSS/SCSS, and Liquid templating. Allows complete control over PDF layout and styling. Supports headers, footers, and dynamic content using Liquid syntax for field values, conditions, loops, and filters.
* @param {module:model/CreateHtmlTemplate} data
* @param {module:api/Client~createHtmlTemplateCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/TemplatePreview}
*/
createHtmlTemplate(data, callback) {
let postBody = data;
// verify the required parameter 'data' is set
if (data === undefined || data === null) {
throw new Error("Missing the required parameter 'data' when calling createHtmlTemplate");
}
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = TemplatePreview;
return this.apiClient.callApi(
'/templates?endpoint_variant=create_html_template', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the createPdfTemplate operation.
* @callback module:api/Client~createPdfTemplateCallback
* @param {String} error Error message, if any.
* @param {module:model/TemplatePreview} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Create a new PDF template with a form POST file upload
* Creates a new PDF template by uploading a PDF file. The uploaded PDF becomes the foundation for your template, and you can then add fillable fields using the template editor. Use the wait parameter to control whether the request waits for document processing to complete.
* @param {File} template_document
* @param {String} template_name
* @param {Object} opts Optional parameters
* @param {Boolean} [wait = true)] Wait for template document to be processed before returning. Set to false to return immediately. Default: true (on sync.* subdomain)
* @param {String} [template_description]
* @param {String} [template_parent_folder_id]
* @param {module:api/Client~createPdfTemplateCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/TemplatePreview}
*/
createPdfTemplate(template_document, template_name, opts, callback) {
opts = opts || {};
let postBody = null;
// verify the required parameter 'template_document' is set
if (template_document === undefined || template_document === null) {
throw new Error("Missing the required parameter 'template_document' when calling createPdfTemplate");
}
// verify the required parameter 'template_name' is set
if (template_name === undefined || template_name === null) {
throw new Error("Missing the required parameter 'template_name' when calling createPdfTemplate");
}
let pathParams = {
};
let queryParams = {
'wait': opts['wait']
};
let headerParams = {
};
let formParams = {
'template[document]': template_document,
'template[name]': template_name,
'template[description]': opts['template_description'],
'template[parent_folder_id]': opts['template_parent_folder_id']
};
let authNames = ['api_token_basic'];
let contentTypes = ['multipart/form-data'];
let accepts = ['application/json'];
let returnType = TemplatePreview;
return this.apiClient.callApi(
'/templates', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the createPdfTemplateFromUpload operation.
* @callback module:api/Client~createPdfTemplateFromUploadCallback
* @param {String} error Error message, if any.
* @param {module:model/TemplatePreview} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Create a new PDF template from a cached S3 file upload
* Creates a new PDF template from a file previously uploaded to S3 using a presigned URL. This two-step process allows for more reliable large file uploads by first uploading the file to S3, then creating the template using the cached upload ID.
* @param {module:model/CreatePdfTemplate} data
* @param {module:api/Client~createPdfTemplateFromUploadCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/TemplatePreview}
*/
createPdfTemplateFromUpload(data, callback) {
let postBody = data;
// verify the required parameter 'data' is set
if (data === undefined || data === null) {
throw new Error("Missing the required parameter 'data' when calling createPdfTemplateFromUpload");
}
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = TemplatePreview;
return this.apiClient.callApi(
'/templates?endpoint_variant=create_template_from_cached_upload', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the deleteFolder operation.
* @callback module:api/Client~deleteFolderCallback
* @param {String} error Error message, if any.
* @param {module:model/Folder} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Delete a folder
* Deletes an empty folder. The folder must not contain any templates or subfolders. Move or delete all contents before attempting to delete the folder.
* @param {String} folder_id
* @param {module:api/Client~deleteFolderCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/Folder}
*/
deleteFolder(folder_id, callback) {
let postBody = null;
// verify the required parameter 'folder_id' is set
if (folder_id === undefined || folder_id === null) {
throw new Error("Missing the required parameter 'folder_id' when calling deleteFolder");
}
let pathParams = {
'folder_id': folder_id
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = Folder;
return this.apiClient.callApi(
'/folders/{folder_id}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the deleteTemplate operation.
* @callback module:api/Client~deleteTemplateCallback
* @param {String} error Error message, if any.
* @param {module:model/TemplateDeleteResponse} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Delete a template
* Deletes a template or a specific template version. When no version is specified, deletes the entire template including all versions. When a version is specified, deletes only that version while preserving others. Returns remaining version information.
* @param {String} template_id
* @param {Object} opts Optional parameters
* @param {String} [version]
* @param {module:api/Client~deleteTemplateCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/TemplateDeleteResponse}
*/
deleteTemplate(template_id, opts, callback) {
opts = opts || {};
let postBody = null;
// verify the required parameter 'template_id' is set
if (template_id === undefined || template_id === null) {
throw new Error("Missing the required parameter 'template_id' when calling deleteTemplate");
}
let pathParams = {
'template_id': template_id
};
let queryParams = {
'version': opts['version']
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = TemplateDeleteResponse;
return this.apiClient.callApi(
'/templates/{template_id}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the expireCombinedSubmission operation.
* @callback module:api/Client~expireCombinedSubmissionCallback
* @param {String} error Error message, if any.
* @param {module:model/CombinedSubmission} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Expire a combined submission
* Expiring a combined submission deletes the PDF from our system. This is useful for invalidating sensitive documents.
* @param {String} combined_submission_id
* @param {module:api/Client~expireCombinedSubmissionCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/CombinedSubmission}
*/
expireCombinedSubmission(combined_submission_id, callback) {
let postBody = null;
// verify the required parameter 'combined_submission_id' is set
if (combined_submission_id === undefined || combined_submission_id === null) {
throw new Error("Missing the required parameter 'combined_submission_id' when calling expireCombinedSubmission");
}
let pathParams = {
'combined_submission_id': combined_submission_id
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = CombinedSubmission;
return this.apiClient.callApi(
'/combined_submissions/{combined_submission_id}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the expireSubmission operation.
* @callback module:api/Client~expireSubmissionCallback
* @param {String} error Error message, if any.
* @param {module:model/SubmissionPreview} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Expire a PDF submission
* Expiring a PDF submission deletes the PDF and removes the data from our database. This is useful for invalidating sensitive documents after they've been downloaded. You can also [configure a data retention policy for your submissions](https://docspring.com/docs/template-editor/settings/#expire-submissions) so that they automatically expire.
* @param {String} submission_id
* @param {module:api/Client~expireSubmissionCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/SubmissionPreview}
*/
expireSubmission(submission_id, callback) {
let postBody = null;
// verify the required parameter 'submission_id' is set
if (submission_id === undefined || submission_id === null) {
throw new Error("Missing the required parameter 'submission_id' when calling expireSubmission");
}
let pathParams = {
'submission_id': submission_id
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = SubmissionPreview;
return this.apiClient.callApi(
'/submissions/{submission_id}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the generatePdf operation.
* @callback module:api/Client~generatePdfCallback
* @param {String} error Error message, if any.
* @param {module:model/CreateSubmissionResponse} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Generate a PDF
* Creates a PDF submission by filling in a template with data. Supports both synchronous (default) and asynchronous processing. Set `wait: false` to return immediately. See also: - [Customize the PDF Title and Filename](https://docspring.com/docs/api-guide/generate-pdfs/customize-pdf-title-and-filename/) - Set custom metadata - [Handling Truncated Text](https://docspring.com/docs/api-guide/generate-pdfs/handle-truncated-text/) - Handle text that doesn't fit in fields
* @param {String} template_id
* @param {module:model/CreatePdfSubmissionData} submission
* @param {Object} opts Optional parameters
* @param {Boolean} [wait = true)] Wait for submission to be processed before returning. Set to false to return immediately. Default: true (on sync.* subdomain)
* @param {module:api/Client~generatePdfCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/CreateSubmissionResponse}
*/
generatePdf(template_id, submission, opts, callback) {
opts = opts || {};
let postBody = submission;
// verify the required parameter 'template_id' is set
if (template_id === undefined || template_id === null) {
throw new Error("Missing the required parameter 'template_id' when calling generatePdf");
}
// verify the required parameter 'submission' is set
if (submission === undefined || submission === null) {
throw new Error("Missing the required parameter 'submission' when calling generatePdf");
}
let pathParams = {
'template_id': template_id
};
let queryParams = {
'wait': opts['wait']
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = ['application/json'];
let accepts = ['application/json'];
let returnType = CreateSubmissionResponse;
return this.apiClient.callApi(
'/templates/{template_id}/submissions', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the generatePreview operation.
* @callback module:api/Client~generatePreviewCallback
* @param {String} error Error message, if any.
* @param {module:model/SuccessErrorResponse} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Generate a preview PDF for partially completed data requests
* Generates a preview PDF for a submission with partially completed data requests. Useful for showing users what the final document will look like before all signatures or data have been collected. The preview includes any data collected so far.
* @param {String} submission_id
* @param {module:api/Client~generatePreviewCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/SuccessErrorResponse}
*/
generatePreview(submission_id, callback) {
let postBody = null;
// verify the required parameter 'submission_id' is set
if (submission_id === undefined || submission_id === null) {
throw new Error("Missing the required parameter 'submission_id' when calling generatePreview");
}
let pathParams = {
'submission_id': submission_id
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = SuccessErrorResponse;
return this.apiClient.callApi(
'/submissions/{submission_id}/generate_preview', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the getCombinedSubmission operation.
* @callback module:api/Client~getCombinedSubmissionCallback
* @param {String} error Error message, if any.
* @param {module:model/CombinedSubmission} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Check the status of a combined submission (merged PDFs)
* Retrieves the details and status of a combined submission. Returns processing state, download URL (if processed), metadata, and information about any integrated actions (e.g., S3 uploads).
* @param {String} combined_submission_id
* @param {module:api/Client~getCombinedSubmissionCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/CombinedSubmission}
*/
getCombinedSubmission(combined_submission_id, callback) {
let postBody = null;
// verify the required parameter 'combined_submission_id' is set
if (combined_submission_id === undefined || combined_submission_id === null) {
throw new Error("Missing the required parameter 'combined_submission_id' when calling getCombinedSubmission");
}
let pathParams = {
'combined_submission_id': combined_submission_id
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = CombinedSubmission;
return this.apiClient.callApi(
'/combined_submissions/{combined_submission_id}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the getDataRequest operation.
* @callback module:api/Client~getDataRequestCallback
* @param {String} error Error message, if any.
* @param {module:model/SubmissionDataRequestShow} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Look up a submission data request
* Retrieves the details and status of a data request. Returns information about the request state (pending, viewed, completed), authentication details, and metadata. Includes audit information like IP address, browseruser agent, and timestamps. See also: - [Embedded Data Requests Guide](https://docspring.com/docs/guides/embedded-forms/embedded-data-requests/) - Complete guide to data request workflow
* @param {String} data_request_id
* @param {module:api/Client~getDataRequestCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/SubmissionDataRequestShow}
*/
getDataRequest(data_request_id, callback) {
let postBody = null;
// verify the required parameter 'data_request_id' is set
if (data_request_id === undefined || data_request_id === null) {
throw new Error("Missing the required parameter 'data_request_id' when calling getDataRequest");
}
let pathParams = {
'data_request_id': data_request_id
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['api_token_basic'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = SubmissionDataRequestShow;
return this.apiClient.callApi(
'/data_requests/{data_request_id}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
/**
* Callback function to receive the result of the getFullTemplate operation.
* @callback module:api/Client~getFullTemplateCallback
* @param {String} error Error message, if any.
* @param {module:model/Template} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Fetch the full attributes for a PDF template
* Retrieves complete template information including fields, defaults, settings, and HTML/SCSS content. Use this to get all template data needed for automated updates or analysis. Returns more detailed information than the basic `getTemplate` endpoint.
* @param {String} template_id
* @param {module:api/Client~getFullTemplateCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/Template}
*/
getFullTemplate(template_id, callback) {
let postBody = null;
// verify the required parameter 'template_id' is set
if (template_id === undefined || template_id === null) {
throw new Error("Missing the required parameter 'template_id' when calling getFullTemplate");
}
let pathParams = {
'template_id': template_id
};
let queryParams = {
};