-
Notifications
You must be signed in to change notification settings - Fork 26
/
powerforms.go
executable file
·358 lines (318 loc) · 10 KB
/
powerforms.go
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
// Copyright 2022 James Cote
// All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by gen-esign; DO NOT EDIT.
// Package powerforms implements the DocuSign SDK
// category PowerForms.
//
// The PowerForms category enables you to create and manage PowerForms that you can use for self service and email forms.
//
//
// Service Api documentation may be found at:
// https://developers.docusign.com/docs/esign-rest-api/reference/PowerForms
// Usage example:
//
// import (
// "github.com/jfcote87/esign"
// "github.com/jfcote87/esign/v2.1/model"
// )
// ...
// powerformsService := powerforms.New(esignCredential)
package powerforms // import "github.com/jfcote87/esignv2.1/powerforms"
import (
"context"
"fmt"
"net/url"
"strings"
"time"
"github.com/jfcote87/esign"
"github.com/jfcote87/esign/v2.1/model"
)
// Service implements DocuSign PowerForms API operations
type Service struct {
credential esign.Credential
}
// New initializes a powerforms service using cred to authorize ops.
func New(cred esign.Credential) *Service {
return &Service{credential: cred}
}
// DataList returns the data that users entered in a PowerForm.
//
// https://developers.docusign.com/docs/esign-rest-api/reference/powerforms/powerformdata/list
//
// SDK Method PowerForms::getPowerFormData
func (s *Service) DataList(powerFormID string) *DataListOp {
return &DataListOp{
Credential: s.credential,
Method: "GET",
Path: strings.Join([]string{"powerforms", powerFormID, "form_data"}, "/"),
Accept: "application/json",
QueryOpts: make(url.Values),
Version: esign.APIv21,
}
}
// DataListOp implements DocuSign API SDK PowerForms::getPowerFormData
type DataListOp esign.Op
// Do executes the op. A nil context will return error.
func (op *DataListOp) Do(ctx context.Context) (*model.PowerFormsFormDataResponse, error) {
var res *model.PowerFormsFormDataResponse
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// DataLayout is the layout in which to return the PowerForm data. Valid values are:
//
// - `Native`
// - `Csv_Classic`
// - `Csv_One_Envelope_Per_Line`
// - `Xml_Classic`
func (op *DataListOp) DataLayout(val string) *DataListOp {
if op != nil {
op.QueryOpts.Set("data_layout", val)
}
return op
}
// FromDate is the start date for a date range in UTC DateTime format.
//
// **Note:** If this property is null, no date filtering is applied.
func (op *DataListOp) FromDate(val time.Time) *DataListOp {
if op != nil {
op.QueryOpts.Set("from_date", val.Format(time.RFC3339))
}
return op
}
// ToDate is the end date of a date range in UTC DateTime format. The default value is `UtcNow`.
func (op *DataListOp) ToDate(val time.Time) *DataListOp {
if op != nil {
op.QueryOpts.Set("to_date", val.Format(time.RFC3339))
}
return op
}
// Create creates a new PowerForm
//
// https://developers.docusign.com/docs/esign-rest-api/reference/powerforms/powerforms/create
//
// SDK Method PowerForms::createPowerForm
func (s *Service) Create(powerForm *model.PowerForm) *CreateOp {
return &CreateOp{
Credential: s.credential,
Method: "POST",
Path: "powerforms",
Payload: powerForm,
QueryOpts: make(url.Values),
Version: esign.APIv21,
}
}
// CreateOp implements DocuSign API SDK PowerForms::createPowerForm
type CreateOp esign.Op
// Do executes the op. A nil context will return error.
func (op *CreateOp) Do(ctx context.Context) (*model.PowerForm, error) {
var res *model.PowerForm
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// Delete deletes a PowerForm.
//
// https://developers.docusign.com/docs/esign-rest-api/reference/powerforms/powerforms/delete
//
// SDK Method PowerForms::deletePowerForm
func (s *Service) Delete(powerFormID string) *DeleteOp {
return &DeleteOp{
Credential: s.credential,
Method: "DELETE",
Path: strings.Join([]string{"powerforms", powerFormID}, "/"),
QueryOpts: make(url.Values),
Version: esign.APIv21,
}
}
// DeleteOp implements DocuSign API SDK PowerForms::deletePowerForm
type DeleteOp esign.Op
// Do executes the op. A nil context will return error.
func (op *DeleteOp) Do(ctx context.Context) error {
return ((*esign.Op)(op)).Do(ctx, nil)
}
// DeleteList deletes one or more PowerForms.
//
// https://developers.docusign.com/docs/esign-rest-api/reference/powerforms/powerforms/deletelist
//
// SDK Method PowerForms::deletePowerForms
func (s *Service) DeleteList(powerFormsRequest *model.PowerFormsRequest) *DeleteListOp {
return &DeleteListOp{
Credential: s.credential,
Method: "DELETE",
Path: "powerforms",
Payload: powerFormsRequest,
Accept: "application/json",
QueryOpts: make(url.Values),
Version: esign.APIv21,
}
}
// DeleteListOp implements DocuSign API SDK PowerForms::deletePowerForms
type DeleteListOp esign.Op
// Do executes the op. A nil context will return error.
func (op *DeleteListOp) Do(ctx context.Context) (*model.PowerFormsResponse, error) {
var res *model.PowerFormsResponse
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// Get returns a single PowerForm.
//
// https://developers.docusign.com/docs/esign-rest-api/reference/powerforms/powerforms/get
//
// SDK Method PowerForms::getPowerForm
func (s *Service) Get(powerFormID string) *GetOp {
return &GetOp{
Credential: s.credential,
Method: "GET",
Path: strings.Join([]string{"powerforms", powerFormID}, "/"),
Accept: "application/json",
QueryOpts: make(url.Values),
Version: esign.APIv21,
}
}
// GetOp implements DocuSign API SDK PowerForms::getPowerForm
type GetOp esign.Op
// Do executes the op. A nil context will return error.
func (op *GetOp) Do(ctx context.Context) (*model.PowerForm, error) {
var res *model.PowerForm
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// List returns a list of PowerForms.
//
// https://developers.docusign.com/docs/esign-rest-api/reference/powerforms/powerforms/list
//
// SDK Method PowerForms::listPowerForms
func (s *Service) List() *ListOp {
return &ListOp{
Credential: s.credential,
Method: "GET",
Path: "powerforms",
Accept: "application/json",
QueryOpts: make(url.Values),
Version: esign.APIv21,
}
}
// ListOp implements DocuSign API SDK PowerForms::listPowerForms
type ListOp esign.Op
// Do executes the op. A nil context will return error.
func (op *ListOp) Do(ctx context.Context) (*model.PowerFormsResponse, error) {
var res *model.PowerFormsResponse
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// FromDate is the start date for a date range.
//
// **Note:** If no value is provided, no date filtering is applied.
func (op *ListOp) FromDate(val time.Time) *ListOp {
if op != nil {
op.QueryOpts.Set("from_date", val.Format(time.RFC3339))
}
return op
}
// Order is the order in which to sort the results.
//
// Valid values are:
//
//
// * `asc`: Ascending order.
// * `desc`: Descending order.
func (op *ListOp) Order(val string) *ListOp {
if op != nil {
op.QueryOpts.Set("order", val)
}
return op
}
// OrderBy is the file attribute to use to sort the results.
//
// Valid values are:
//
// - `sender`
// - `auth`
// - `used`
// - `remaining`
// - `lastused`
// - `status`
// - `type`
// - `templatename`
// - `created`
func (op *ListOp) OrderBy(val string) *ListOp {
if op != nil {
op.QueryOpts.Set("order_by", val)
}
return op
}
// SearchFields is a comma-separated list of additional properties to include in a search.
//
// - `sender`: Include sender name and email in the search.
// - `recipients`: Include recipient names and emails in the search.
// - `envelope`: Include envelope information in the search.
func (op *ListOp) SearchFields(val string) *ListOp {
if op != nil {
op.QueryOpts.Set("search_fields", val)
}
return op
}
// SearchText use this parameter to search for specific text.
func (op *ListOp) SearchText(val string) *ListOp {
if op != nil {
op.QueryOpts.Set("search_text", val)
}
return op
}
// ToDate is the end date for a date range.
//
// **Note:** If no value is provided, this property defaults to the current date.
func (op *ListOp) ToDate(val time.Time) *ListOp {
if op != nil {
op.QueryOpts.Set("to_date", val.Format(time.RFC3339))
}
return op
}
// ListSenders gets PowerForm senders.
//
// https://developers.docusign.com/docs/esign-rest-api/reference/powerforms/powerforms/listsenders
//
// SDK Method PowerForms::listPowerFormSenders
func (s *Service) ListSenders() *ListSendersOp {
return &ListSendersOp{
Credential: s.credential,
Method: "GET",
Path: "powerforms/senders",
Accept: "application/json",
QueryOpts: make(url.Values),
Version: esign.APIv21,
}
}
// ListSendersOp implements DocuSign API SDK PowerForms::listPowerFormSenders
type ListSendersOp esign.Op
// Do executes the op. A nil context will return error.
func (op *ListSendersOp) Do(ctx context.Context) (*model.PowerFormSendersResponse, error) {
var res *model.PowerFormSendersResponse
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// StartPosition is the position within the total result set from which to start returning values. The value **thumbnail** may be used to return the page image.
func (op *ListSendersOp) StartPosition(val int) *ListSendersOp {
if op != nil {
op.QueryOpts.Set("start_position", fmt.Sprintf("%d", val))
}
return op
}
// Update updates an existing PowerForm.
//
// https://developers.docusign.com/docs/esign-rest-api/reference/powerforms/powerforms/update
//
// SDK Method PowerForms::updatePowerForm
func (s *Service) Update(powerFormID string, powerForm *model.PowerForm) *UpdateOp {
return &UpdateOp{
Credential: s.credential,
Method: "PUT",
Path: strings.Join([]string{"powerforms", powerFormID}, "/"),
Payload: powerForm,
Accept: "application/json",
QueryOpts: make(url.Values),
Version: esign.APIv21,
}
}
// UpdateOp implements DocuSign API SDK PowerForms::updatePowerForm
type UpdateOp esign.Op
// Do executes the op. A nil context will return error.
func (op *UpdateOp) Do(ctx context.Context) (*model.PowerForm, error) {
var res *model.PowerForm
return res, ((*esign.Op)(op)).Do(ctx, &res)
}