forked from jfcote87/esign
-
Notifications
You must be signed in to change notification settings - Fork 0
/
powerforms.go
305 lines (267 loc) · 9.06 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
// Copyright 2019 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 PowerForms to be created and managed.
//
// Service Api documentation may be found at:
// https://developers.docusign.com/esign-rest-api/v2/reference/PowerForms
// Usage example:
//
// import (
// "github.com/pwaterz/esign"
// "github.com/pwaterz/esign/v2/powerforms"
// "github.com/pwaterz/esign/v2/model"
// )
// ...
// powerformsService := powerforms.New(esignCredential)
package powerforms // import "github.com/pwaterz/esign/v2/powerforms"
import (
"context"
"fmt"
"net/url"
"strings"
"time"
"github.com/pwaterz/esign"
"github.com/pwaterz/esign/v2/model"
)
// Service implements DocuSign PowerForms Category 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 form data associated with the usage of a PowerForm.
//
// https://developers.docusign.com/esign-rest-api/v2/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"}, "/"),
QueryOpts: make(url.Values),
}
}
// 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 set the call query parameter data_layout
func (op *DataListOp) DataLayout(val string) *DataListOp {
if op != nil {
op.QueryOpts.Set("data_layout", val)
}
return op
}
// FromDate start of the search date range. Only returns templates created on or after this date/time. If no value is specified, there is no limit on the earliest date created.
func (op *DataListOp) FromDate(val time.Time) *DataListOp {
if op != nil {
op.QueryOpts.Set("from_date", val.Format(time.RFC3339))
}
return op
}
// ToDate end of the search date range. Only returns templates created up to this date/time. If no value is provided, this defaults to the current date.
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/esign-rest-api/v2/reference/powerforms/powerforms/create
//
// SDK Method PowerForms::createPowerForm
func (s *Service) Create(powerForms *model.PowerForm) *CreateOp {
return &CreateOp{
Credential: s.credential,
Method: "POST",
Path: "powerforms",
Payload: powerForms,
QueryOpts: make(url.Values),
}
}
// 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 delete a PowerForm.
//
// https://developers.docusign.com/esign-rest-api/v2/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),
}
}
// 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/esign-rest-api/v2/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,
QueryOpts: make(url.Values),
}
}
// 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/esign-rest-api/v2/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}, "/"),
QueryOpts: make(url.Values),
}
}
// 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 the list of PowerForms available to the user.
//
// https://developers.docusign.com/esign-rest-api/v2/reference/powerforms/powerforms/list
//
// SDK Method PowerForms::listPowerForms
func (s *Service) List() *ListOp {
return &ListOp{
Credential: s.credential,
Method: "GET",
Path: "powerforms",
QueryOpts: make(url.Values),
}
}
// 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 start of the search date range. Only returns templates created on or after this date/time. If no value is specified, there is no limit on the earliest date created.
func (op *ListOp) FromDate(val time.Time) *ListOp {
if op != nil {
op.QueryOpts.Set("from_date", val.Format(time.RFC3339))
}
return op
}
// Order is an optional value that sets the direction order used to sort the item list.
//
// Valid values are:
//
// * asc = ascending sort order
// * desc = descending sort order
func (op *ListOp) Order(val string) *ListOp {
if op != nil {
op.QueryOpts.Set("order", val)
}
return op
}
// OrderBy is an optional value that sets the file attribute used to sort the item list.
//
// Valid values are:
//
// * modified
// * name
func (op *ListOp) OrderBy(val string) *ListOp {
if op != nil {
op.QueryOpts.Set("order_by", val)
}
return op
}
// ToDate end of the search date range. Only returns templates created up to this date/time. If no value is provided, this 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 returns the list of PowerForms available to the user.
//
// https://developers.docusign.com/esign-rest-api/v2/reference/powerforms/powerforms/listsenders
//
// SDK Method PowerForms::listPowerFormSenders
func (s *Service) ListSenders() *ListSendersOp {
return &ListSendersOp{
Credential: s.credential,
Method: "GET",
Path: "powerforms/senders",
QueryOpts: make(url.Values),
}
}
// 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 creates a new PowerForm.
//
// https://developers.docusign.com/esign-rest-api/v2/reference/powerforms/powerforms/update
//
// SDK Method PowerForms::updatePowerForm
func (s *Service) Update(powerFormID string, powerForms *model.PowerForm) *UpdateOp {
return &UpdateOp{
Credential: s.credential,
Method: "PUT",
Path: strings.Join([]string{"powerforms", powerFormID}, "/"),
Payload: powerForms,
QueryOpts: make(url.Values),
}
}
// 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)
}