-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.go
More file actions
476 lines (446 loc) · 14.6 KB
/
Copy pathclient.go
File metadata and controls
476 lines (446 loc) · 14.6 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
// Code generated by Fern. DO NOT EDIT.
package docuseal
import (
context "context"
http "net/http"
time "time"
core "github.com/docusealco/docuseal-go/core"
internal "github.com/docusealco/docuseal-go/internal"
)
type Client struct {
WithRawResponse *RawClient
options *core.RequestOptions
baseURL string
caller *internal.Caller
}
func NewClient(apiKey string, opts ...RequestOption) *Client {
opts = append([]RequestOption{WithAPIKey(apiKey)}, opts...)
options := core.NewRequestOptions(opts...)
if options.HTTPHeader.Get("User-Agent") == "" {
options.HTTPHeader.Set("User-Agent", "DocuSeal Go v1.0.0")
}
if options.HTTPClient == nil {
options.HTTPClient = &http.Client{Timeout: 30 * time.Second}
}
return &Client{
WithRawResponse: NewRawClient(options),
options: options,
baseURL: options.BaseURL,
caller: internal.NewCaller(
&internal.CallerParams{
Client: options.HTTPClient,
MaxAttempts: options.MaxAttempts,
DisableRetries: options.DisableRetries,
},
),
}
}
// The API endpoint provides the ability to retrieve a list of available document templates.
func (c *Client) GetTemplates(
ctx context.Context,
request *GetTemplatesParams,
opts ...RequestOption,
) (*TemplateList, error) {
response, err := c.WithRawResponse.GetTemplates(
ctx,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint provides the functionality to retrieve information about a document template.
func (c *Client) GetTemplate(
ctx context.Context,
// The unique identifier of the document template.
id int,
opts ...RequestOption,
) (*Template, error) {
response, err := c.WithRawResponse.GetTemplate(
ctx,
id,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint provides the functionality to move a document template to a different folder and update the name of the template.
func (c *Client) UpdateTemplate(
ctx context.Context,
// The unique identifier of the document template.
id int,
request *UpdateTemplateParams,
opts ...RequestOption,
) (*TemplateUpdateResult, error) {
response, err := c.WithRawResponse.UpdateTemplate(
ctx,
id,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint allows you to archive a document template.
func (c *Client) ArchiveTemplate(
ctx context.Context,
// The unique identifier of the document template.
id int,
opts ...RequestOption,
) (*TemplateArchiveResult, error) {
response, err := c.WithRawResponse.ArchiveTemplate(
ctx,
id,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint provides the ability to retrieve a list of available submissions.
func (c *Client) GetSubmissions(
ctx context.Context,
request *GetSubmissionsParams,
opts ...RequestOption,
) (*SubmissionList, error) {
response, err := c.WithRawResponse.GetSubmissions(
ctx,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint provides the functionality to retrieve information about a submission.
func (c *Client) GetSubmission(
ctx context.Context,
// The unique identifier of the submission.
id int,
opts ...RequestOption,
) (*Submission, error) {
response, err := c.WithRawResponse.GetSubmission(
ctx,
id,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint allows you to update a submission: change its name, expiration date, and archive or unarchive it.
func (c *Client) UpdateSubmission(
ctx context.Context,
// The unique identifier of the submission.
id int,
request *UpdateSubmissionParams,
opts ...RequestOption,
) (*SubmissionUpdateResult, error) {
response, err := c.WithRawResponse.UpdateSubmission(
ctx,
id,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint allows you to archive a submission.
func (c *Client) ArchiveSubmission(
ctx context.Context,
// The unique identifier of the submission.
id int,
opts ...RequestOption,
) (*SubmissionArchiveResult, error) {
response, err := c.WithRawResponse.ArchiveSubmission(
ctx,
id,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// This endpoint returns a list of partially filled documents for a submission. If the submission has been completed, the final signed documents are returned.
func (c *Client) GetSubmissionDocuments(
ctx context.Context,
// The unique identifier of the submission.
id int,
request *GetSubmissionDocumentsParams,
opts ...RequestOption,
) (*SubmissionDocuments, error) {
response, err := c.WithRawResponse.GetSubmissionDocuments(
ctx,
id,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint provides the functionality to create one-off submission request from a PDF. Use <code>{{Field Name;role=Signer1;type=date}}</code> text tags to define fillable fields in the document. See <a href="https://www.docuseal.com/examples/fieldtags.pdf" target="_blank" class="link font-bold">https://www.docuseal.com/examples/fieldtags.pdf</a> for more text tag formats. Or specify the exact pixel coordinates of the document fields using `fields` param.<br><b>Related Guides</b><br><a href="https://www.docuseal.com/guides/use-embedded-text-field-tags-in-the-pdf-to-create-a-fillable-form" class="link">Use embedded text field tags to create a fillable form</a>
func (c *Client) CreateSubmissionFromPdf(
ctx context.Context,
request *CreateSubmissionFromPdfParams,
opts ...RequestOption,
) (*SubmissionCreateOneoffResult, error) {
response, err := c.WithRawResponse.CreateSubmissionFromPdf(
ctx,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint provides functionality to create a one-off submission request from a DOCX file with dynamic content variables. Use <code>[[variable_name]]</code> text tags to define dynamic content variables in the document. See <a href="https://www.docuseal.com/examples/demo_template.docx" target="_blank" class="link font-bold">https://www.docuseal.com/examples/demo_template.docx</a> for the specific text variable syntax, including dynamic content tables and lists. You can also use the <code>{{signature}}</code> field syntax to define fillable fields, as in a PDF.<br><b>Related Guides</b><br><a href="https://www.docuseal.com/guides/use-dynamic-content-variables-in-docx-to-create-personalized-documents" class="link">Use dynamic content variables in DOCX to create personalized documents</a>
func (c *Client) CreateSubmissionFromDocx(
ctx context.Context,
request *CreateSubmissionFromDocxParams,
opts ...RequestOption,
) (*SubmissionCreateOneoffResult, error) {
response, err := c.WithRawResponse.CreateSubmissionFromDocx(
ctx,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// This API endpoint allows you to create a one-off submission request document using the provided HTML content, with special field tags rendered as a fillable and signable form.<br><b>Related Guides</b><br><a href="https://www.docuseal.com/guides/create-pdf-document-fillable-form-with-html-api" class="link">Create PDF document fillable form with HTML</a>
func (c *Client) CreateSubmissionFromHtml(
ctx context.Context,
request *CreateSubmissionFromHtmlParams,
opts ...RequestOption,
) (*SubmissionCreateOneoffResult, error) {
response, err := c.WithRawResponse.CreateSubmissionFromHtml(
ctx,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint provides functionality to retrieve information about a submitter, along with the submitter documents and field values.
func (c *Client) GetSubmitter(
ctx context.Context,
// The unique identifier of the submitter.
id int,
opts ...RequestOption,
) (*Submitter, error) {
response, err := c.WithRawResponse.GetSubmitter(
ctx,
id,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint allows you to update submitter details, pre-fill or update field values and re-send emails.<br><b>Related Guides</b><br><a href="https://www.docuseal.com/guides/pre-fill-pdf-document-form-fields-with-api#automatically_sign_documents_via_api" class="link">Automatically sign documents via API</a>
func (c *Client) UpdateSubmitter(
ctx context.Context,
// The unique identifier of the submitter.
id int,
request *UpdateSubmitterParams,
opts ...RequestOption,
) (*SubmitterUpdateResult, error) {
response, err := c.WithRawResponse.UpdateSubmitter(
ctx,
id,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint provides the ability to retrieve a list of submitters.
func (c *Client) GetSubmitters(
ctx context.Context,
request *GetSubmittersParams,
opts ...RequestOption,
) (*SubmitterList, error) {
response, err := c.WithRawResponse.GetSubmitters(
ctx,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint allows you to add, remove or replace documents in the template with provided PDF/DOCX file or HTML content.
func (c *Client) UpdateTemplateDocuments(
ctx context.Context,
// The unique identifier of the document template.
id int,
request *UpdateTemplateDocumentsParams,
opts ...RequestOption,
) (*Template, error) {
response, err := c.WithRawResponse.UpdateTemplateDocuments(
ctx,
id,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint allows you to clone an existing template into a new template.
func (c *Client) CloneTemplate(
ctx context.Context,
// The unique identifier of the document template.
id int,
request *CloneTemplateParams,
opts ...RequestOption,
) (*Template, error) {
response, err := c.WithRawResponse.CloneTemplate(
ctx,
id,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint provides the functionality to seamlessly generate a PDF document template by utilizing the provided HTML content while incorporating pre-defined fields.<br><b>Related Guides</b><br><a href="https://www.docuseal.com/guides/create-pdf-document-fillable-form-with-html-api" class="link">Create PDF document fillable form with HTML</a>
func (c *Client) CreateTemplateFromHtml(
ctx context.Context,
request *CreateTemplateFromHtmlParams,
opts ...RequestOption,
) (*Template, error) {
response, err := c.WithRawResponse.CreateTemplateFromHtml(
ctx,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint provides the functionality to create a fillable document template for an existing Microsoft Word document. Use <code>{{Field Name;role=Signer1;type=date}}</code> text tags to define fillable fields in the document. See <a href="https://www.docuseal.com/examples/fieldtags.docx" target="_blank" class="link font-bold" >https://www.docuseal.com/examples/fieldtags.docx</a> for more text tag formats. Or specify the exact pixel coordinates of the document fields using `fields` param.<br><b>Related Guides</b><br><a href="https://www.docuseal.com/guides/use-embedded-text-field-tags-in-the-pdf-to-create-a-fillable-form" class="link">Use embedded text field tags to create a fillable form</a>
func (c *Client) CreateTemplateFromDocx(
ctx context.Context,
request *CreateTemplateFromDocxParams,
opts ...RequestOption,
) (*Template, error) {
response, err := c.WithRawResponse.CreateTemplateFromDocx(
ctx,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint provides the functionality to create a fillable document template for a PDF file. Use <code>{{Field Name;role=Signer1;type=date}}</code> text tags to define fillable fields in the document. See <a href="https://www.docuseal.com/examples/fieldtags.pdf" target="_blank" class="link font-bold">https://www.docuseal.com/examples/fieldtags.pdf</a> for more text tag formats. Or specify the exact pixel coordinates of the document fields using `fields` param.<br><b>Related Guides</b><br><a href="https://www.docuseal.com/guides/use-embedded-text-field-tags-in-the-pdf-to-create-a-fillable-form" class="link">Use embedded text field tags to create a fillable form</a>
func (c *Client) CreateTemplateFromPdf(
ctx context.Context,
request *CreateTemplateFromPdfParams,
opts ...RequestOption,
) (*Template, error) {
response, err := c.WithRawResponse.CreateTemplateFromPdf(
ctx,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint allows you to merge multiple templates with documents and fields into a new combined template.
func (c *Client) MergeTemplate(
ctx context.Context,
request *MergeTemplateParams,
opts ...RequestOption,
) (*Template, error) {
response, err := c.WithRawResponse.MergeTemplate(
ctx,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// This API endpoint allows you to create signature requests (submissions) for a document template and send them to the specified submitters (signers).<br><b>Related Guides</b><br><a href="https://www.docuseal.com/guides/send-documents-for-signature-via-api" class="link">Send documents for signature via API</a><br><a href="https://www.docuseal.com/guides/pre-fill-pdf-document-form-fields-with-api" class="link">Pre-fill PDF document form fields with API</a>
func (c *Client) CreateSubmission(
ctx context.Context,
request *CreateSubmissionParams,
opts ...RequestOption,
) (*SubmissionCreateResult, error) {
response, err := c.WithRawResponse.CreateSubmission(
ctx,
request,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint allows you to permanently delete a document template and all of its submissions.
func (c *Client) PermanentlyDeleteTemplate(
ctx context.Context,
// The unique identifier of the document template.
id int,
opts ...RequestOption,
) (*TemplatePermanentlyDeleteResult, error) {
response, err := c.WithRawResponse.PermanentlyDeleteTemplate(
ctx,
id,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}
// The API endpoint allows you to permanently delete a submission and all of its submitters and documents.
func (c *Client) PermanentlyDeleteSubmission(
ctx context.Context,
// The unique identifier of the submission.
id int,
opts ...RequestOption,
) (*SubmissionPermanentlyDeleteResult, error) {
response, err := c.WithRawResponse.PermanentlyDeleteSubmission(
ctx,
id,
opts...,
)
if err != nil {
return nil, err
}
return response.Body, nil
}