forked from jfcote87/esign
/
workspaces.go
416 lines (363 loc) · 13.6 KB
/
workspaces.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
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
// 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 workspaces implements the DocuSign SDK
// category Workspaces.
//
// Workspaces creation and management.
//
// Service Api documentation may be found at:
// https://developers.docusign.com/esign-rest-api/v2/reference/Workspaces
// Usage example:
//
// import (
// "github.com/ICGGroup/esign"
// "github.com/ICGGroup/esign/v2/workspaces"
// "github.com/ICGGroup/esign/v2/model"
// )
// ...
// workspacesService := workspaces.New(esignCredential)
package workspaces // import "github.com/ICGGroup/esign/v2/workspaces"
import (
"context"
"fmt"
"io"
"net/url"
"strings"
"github.com/ICGGroup/esign"
"github.com/ICGGroup/esign/v2/model"
)
// Service implements DocuSign Workspaces Category API operations
type Service struct {
credential esign.Credential
}
// New initializes a workspaces service using cred to authorize ops.
func New(cred esign.Credential) *Service {
return &Service{credential: cred}
}
// ItemsCreateFIle creates a workspace file.
// If media is an io.ReadCloser, Do() will close media.
//
// https://developers.docusign.com/esign-rest-api/v2/reference/workspaces/workspaceitems/createfile
//
// SDK Method Workspaces::createWorkspaceFile
func (s *Service) ItemsCreateFIle(folderID string, workspaceID string, media io.Reader, mimeType string) *ItemsCreateFIleOp {
return &ItemsCreateFIleOp{
Credential: s.credential,
Method: "POST",
Path: strings.Join([]string{"workspaces", workspaceID, "folders", folderID, "files"}, "/"),
Payload: &esign.UploadFile{Reader: media, ContentType: mimeType},
QueryOpts: make(url.Values),
}
}
// ItemsCreateFIleOp implements DocuSign API SDK Workspaces::createWorkspaceFile
type ItemsCreateFIleOp esign.Op
// Do executes the op. A nil context will return error.
func (op *ItemsCreateFIleOp) Do(ctx context.Context) (*model.WorkspaceItem, error) {
var res *model.WorkspaceItem
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// ItemsDeleteFolderItems deletes workspace one or more specific files/folders from the given folder or root.
//
// https://developers.docusign.com/esign-rest-api/v2/reference/workspaces/workspaceitems/deletefolderitems
//
// SDK Method Workspaces::deleteWorkspaceFolderItems
func (s *Service) ItemsDeleteFolderItems(folderID string, workspaceID string, workspaceItemList *model.WorkspaceItemList) *ItemsDeleteFolderItemsOp {
return &ItemsDeleteFolderItemsOp{
Credential: s.credential,
Method: "DELETE",
Path: strings.Join([]string{"workspaces", workspaceID, "folders", folderID}, "/"),
Payload: workspaceItemList,
QueryOpts: make(url.Values),
}
}
// ItemsDeleteFolderItemsOp implements DocuSign API SDK Workspaces::deleteWorkspaceFolderItems
type ItemsDeleteFolderItemsOp esign.Op
// Do executes the op. A nil context will return error.
func (op *ItemsDeleteFolderItemsOp) Do(ctx context.Context) error {
return ((*esign.Op)(op)).Do(ctx, nil)
}
// ItemsGetFile get Workspace File
//
// https://developers.docusign.com/esign-rest-api/v2/reference/workspaces/workspaceitems/getfile
//
// SDK Method Workspaces::getWorkspaceFile
func (s *Service) ItemsGetFile(fileID string, folderID string, workspaceID string) *ItemsGetFileOp {
return &ItemsGetFileOp{
Credential: s.credential,
Method: "GET",
Path: strings.Join([]string{"workspaces", workspaceID, "folders", folderID, "files", fileID}, "/"),
QueryOpts: make(url.Values),
}
}
// ItemsGetFileOp implements DocuSign API SDK Workspaces::getWorkspaceFile
type ItemsGetFileOp esign.Op
// Do executes the op. A nil context will return error.
func (op *ItemsGetFileOp) Do(ctx context.Context) (*esign.Download, error) {
var res *esign.Download
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// IsDownload when set to **true**, the Content-Disposition header is set in the response. The value of the header provides the filename of the file. Default is **false**.
func (op *ItemsGetFileOp) IsDownload() *ItemsGetFileOp {
if op != nil {
op.QueryOpts.Set("is_download", "true")
}
return op
}
// PdfVersion when set to **true** the file returned as a PDF.
func (op *ItemsGetFileOp) PdfVersion() *ItemsGetFileOp {
if op != nil {
op.QueryOpts.Set("pdf_version", "true")
}
return op
}
// ItemsListFilePages list File Pages
//
// https://developers.docusign.com/esign-rest-api/v2/reference/workspaces/workspaceitems/listfilepages
//
// SDK Method Workspaces::listWorkspaceFilePages
func (s *Service) ItemsListFilePages(fileID string, folderID string, workspaceID string) *ItemsListFilePagesOp {
return &ItemsListFilePagesOp{
Credential: s.credential,
Method: "GET",
Path: strings.Join([]string{"workspaces", workspaceID, "folders", folderID, "files", fileID, "pages"}, "/"),
QueryOpts: make(url.Values),
}
}
// ItemsListFilePagesOp implements DocuSign API SDK Workspaces::listWorkspaceFilePages
type ItemsListFilePagesOp esign.Op
// Do executes the op. A nil context will return error.
func (op *ItemsListFilePagesOp) Do(ctx context.Context) (*model.PageImages, error) {
var res *model.PageImages
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// Count is the maximum number of results to be returned by this request.
func (op *ItemsListFilePagesOp) Count(val int) *ItemsListFilePagesOp {
if op != nil {
op.QueryOpts.Set("count", fmt.Sprintf("%d", val))
}
return op
}
// Dpi number of dots per inch for the resulting image. The default if not used is 94. The range is 1-310.
func (op *ItemsListFilePagesOp) Dpi(val int) *ItemsListFilePagesOp {
if op != nil {
op.QueryOpts.Set("dpi", fmt.Sprintf("%d", val))
}
return op
}
// MaxHeight sets the maximum height (in pixels) of the returned image.
func (op *ItemsListFilePagesOp) MaxHeight(val int) *ItemsListFilePagesOp {
if op != nil {
op.QueryOpts.Set("max_height", fmt.Sprintf("%d", val))
}
return op
}
// MaxWidth sets the maximum width (in pixels) of the returned image.
func (op *ItemsListFilePagesOp) MaxWidth(val int) *ItemsListFilePagesOp {
if op != nil {
op.QueryOpts.Set("max_width", fmt.Sprintf("%d", val))
}
return op
}
// 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 *ItemsListFilePagesOp) StartPosition(val int) *ItemsListFilePagesOp {
if op != nil {
op.QueryOpts.Set("start_position", fmt.Sprintf("%d", val))
}
return op
}
// ItemsListFolderItems list Workspace Folder Contents
//
// https://developers.docusign.com/esign-rest-api/v2/reference/workspaces/workspaceitems/listfolderitems
//
// SDK Method Workspaces::listWorkspaceFolderItems
func (s *Service) ItemsListFolderItems(folderID string, workspaceID string) *ItemsListFolderItemsOp {
return &ItemsListFolderItemsOp{
Credential: s.credential,
Method: "GET",
Path: strings.Join([]string{"workspaces", workspaceID, "folders", folderID}, "/"),
QueryOpts: make(url.Values),
}
}
// ItemsListFolderItemsOp implements DocuSign API SDK Workspaces::listWorkspaceFolderItems
type ItemsListFolderItemsOp esign.Op
// Do executes the op. A nil context will return error.
func (op *ItemsListFolderItemsOp) Do(ctx context.Context) (*model.WorkspaceFolderContents, error) {
var res *model.WorkspaceFolderContents
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// Count is the maximum number of results to be returned by this request.
func (op *ItemsListFolderItemsOp) Count(val int) *ItemsListFolderItemsOp {
if op != nil {
op.QueryOpts.Set("count", fmt.Sprintf("%d", val))
}
return op
}
// IncludeFiles when set to **true**, file information is returned in the response along with folder information. The default is **false**.
func (op *ItemsListFolderItemsOp) IncludeFiles() *ItemsListFolderItemsOp {
if op != nil {
op.QueryOpts.Set("include_files", "true")
}
return op
}
// IncludeSubFolders when set to **true**, information about the sub-folders of the current folder is returned. The default is **false**.
func (op *ItemsListFolderItemsOp) IncludeSubFolders() *ItemsListFolderItemsOp {
if op != nil {
op.QueryOpts.Set("include_sub_folders", "true")
}
return op
}
// IncludeThumbnails when set to **true**, thumbnails are returned as part of the response. The default is **false**.
func (op *ItemsListFolderItemsOp) IncludeThumbnails() *ItemsListFolderItemsOp {
if op != nil {
op.QueryOpts.Set("include_thumbnails", "true")
}
return op
}
// IncludeUserDetail set to **true** to return extended details about the user. The default is **false**.
func (op *ItemsListFolderItemsOp) IncludeUserDetail() *ItemsListFolderItemsOp {
if op != nil {
op.QueryOpts.Set("include_user_detail", "true")
}
return op
}
// StartPosition is the position within the total result set from which to start returning values.
func (op *ItemsListFolderItemsOp) StartPosition(val int) *ItemsListFolderItemsOp {
if op != nil {
op.QueryOpts.Set("start_position", fmt.Sprintf("%d", val))
}
return op
}
// WorkspaceUserID if set, then the results are filtered to those associated with the specified userId.
func (op *ItemsListFolderItemsOp) WorkspaceUserID(val string) *ItemsListFolderItemsOp {
if op != nil {
op.QueryOpts.Set("workspace_user_id", val)
}
return op
}
// ItemsUpdateFile update Workspace File Metadata
// If media is an io.ReadCloser, Do() will close media.
//
// https://developers.docusign.com/esign-rest-api/v2/reference/workspaces/workspaceitems/updatefile
//
// SDK Method Workspaces::updateWorkspaceFile
func (s *Service) ItemsUpdateFile(fileID string, folderID string, workspaceID string, media io.Reader, mimeType string) *ItemsUpdateFileOp {
return &ItemsUpdateFileOp{
Credential: s.credential,
Method: "PUT",
Path: strings.Join([]string{"workspaces", workspaceID, "folders", folderID, "files", fileID}, "/"),
Payload: &esign.UploadFile{Reader: media, ContentType: mimeType},
QueryOpts: make(url.Values),
}
}
// ItemsUpdateFileOp implements DocuSign API SDK Workspaces::updateWorkspaceFile
type ItemsUpdateFileOp esign.Op
// Do executes the op. A nil context will return error.
func (op *ItemsUpdateFileOp) Do(ctx context.Context) (*model.WorkspaceItem, error) {
var res *model.WorkspaceItem
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// Create create a Workspace
//
// https://developers.docusign.com/esign-rest-api/v2/reference/workspaces/workspaces/create
//
// SDK Method Workspaces::createWorkspace
func (s *Service) Create(workspaces *model.Workspace) *CreateOp {
return &CreateOp{
Credential: s.credential,
Method: "POST",
Path: "workspaces",
Payload: workspaces,
QueryOpts: make(url.Values),
}
}
// CreateOp implements DocuSign API SDK Workspaces::createWorkspace
type CreateOp esign.Op
// Do executes the op. A nil context will return error.
func (op *CreateOp) Do(ctx context.Context) (*model.Workspace, error) {
var res *model.Workspace
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// Delete delete Workspace
//
// https://developers.docusign.com/esign-rest-api/v2/reference/workspaces/workspaces/delete
//
// SDK Method Workspaces::deleteWorkspace
func (s *Service) Delete(workspaceID string) *DeleteOp {
return &DeleteOp{
Credential: s.credential,
Method: "DELETE",
Path: strings.Join([]string{"workspaces", workspaceID}, "/"),
QueryOpts: make(url.Values),
}
}
// DeleteOp implements DocuSign API SDK Workspaces::deleteWorkspace
type DeleteOp esign.Op
// Do executes the op. A nil context will return error.
func (op *DeleteOp) Do(ctx context.Context) (*model.Workspace, error) {
var res *model.Workspace
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// Get get Workspace
//
// https://developers.docusign.com/esign-rest-api/v2/reference/workspaces/workspaces/get
//
// SDK Method Workspaces::getWorkspace
func (s *Service) Get(workspaceID string) *GetOp {
return &GetOp{
Credential: s.credential,
Method: "GET",
Path: strings.Join([]string{"workspaces", workspaceID}, "/"),
QueryOpts: make(url.Values),
}
}
// GetOp implements DocuSign API SDK Workspaces::getWorkspace
type GetOp esign.Op
// Do executes the op. A nil context will return error.
func (op *GetOp) Do(ctx context.Context) (*model.Workspace, error) {
var res *model.Workspace
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// List list Workspaces
//
// https://developers.docusign.com/esign-rest-api/v2/reference/workspaces/workspaces/list
//
// SDK Method Workspaces::listWorkspaces
func (s *Service) List() *ListOp {
return &ListOp{
Credential: s.credential,
Method: "GET",
Path: "workspaces",
QueryOpts: make(url.Values),
}
}
// ListOp implements DocuSign API SDK Workspaces::listWorkspaces
type ListOp esign.Op
// Do executes the op. A nil context will return error.
func (op *ListOp) Do(ctx context.Context) (*model.WorkspaceList, error) {
var res *model.WorkspaceList
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// Update update Workspace
//
// https://developers.docusign.com/esign-rest-api/v2/reference/workspaces/workspaces/update
//
// SDK Method Workspaces::updateWorkspace
func (s *Service) Update(workspaceID string, workspaces *model.Workspace) *UpdateOp {
return &UpdateOp{
Credential: s.credential,
Method: "PUT",
Path: strings.Join([]string{"workspaces", workspaceID}, "/"),
Payload: workspaces,
QueryOpts: make(url.Values),
}
}
// UpdateOp implements DocuSign API SDK Workspaces::updateWorkspace
type UpdateOp esign.Op
// Do executes the op. A nil context will return error.
func (op *UpdateOp) Do(ctx context.Context) (*model.Workspace, error) {
var res *model.Workspace
return res, ((*esign.Op)(op)).Do(ctx, &res)
}