forked from jfcote87/esign
-
Notifications
You must be signed in to change notification settings - Fork 0
/
connect.go
500 lines (441 loc) · 17.4 KB
/
connect.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
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
// 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 connect implements the DocuSign SDK
// category Connect.
//
// The Connect category enables your application to be called via HTTPS when an event of interest occurs.
//
// Use the Connect service to "end the polling madness." With Connect, there is no need for your application to poll DocuSign every 15 minutes to learn the latest about your envelopes.
//
// Instead, you register your interest in one or more types of envelope or recipient events. Then, when an interesting event occurs, the DocuSign platform will contact your application with the event's details and data. You can register interest in envelopes sent by particular users in your account, or for envelopes sent by any user.
//
// ## Incoming Connect Calls
// To use the Connect service, your application needs to provide an https url that can be called from the public internet. If your application runs on a server behind your organization's firewall, then you will need to create a "pinhole" in the firewall to allow the incoming Connect calls from DocuSign to reach your application. Other techniques for receiving the incoming calls including proxy servers and DMZ networking can also be used.
//
// ## Per-envelope Connect Configuration
// Instead of registering a general Connect configuration and listener, an individual envelope can have its own Connect configuration. See the `eventNotification` field for envelopes.
//
// ## Categories
// Use the Connect category for:
//
// * Programmatically creating Connect configurations. Connect configurations can be created manually by using the DocuSign web service, or programmatically via the API. Configurations created via the API can be seen and updated from the web service.
// * Retrieving and managing the event log for your Connect configurations.
// * Requesting that an event be re-published to the listener.
//
// Service Api documentation may be found at:
// https://developers.docusign.com/esign-rest-api/reference/Connect
// Usage example:
//
// import (
// "github.com/thaitanloi365/esign"
// "github.com/thaitanloi365/esign/v2.1/connect"
// "github.com/thaitanloi365/esign/v2.1/model"
// )
// ...
// connectService := connect.New(esignCredential)
package connect // import "github.com/thaitanloi365/esign/v2.1/connect"
import (
"context"
"fmt"
"io"
"net/url"
"strings"
"time"
"github.com/thaitanloi365/esign"
"github.com/thaitanloi365/esign/v2.1/model"
)
// Service implements DocuSign Connect Category API operations
type Service struct {
credential esign.Credential
}
// New initializes a connect service using cred to authorize ops.
func New(cred esign.Credential) *Service {
return &Service{credential: cred}
}
// ConfigurationsCreate creates a connect configuration for the specified account.
//
// https://developers.docusign.com/esign-rest-api/reference/connect/connectconfigurations/create
//
// SDK Method Connect::createConfiguration
func (s *Service) ConfigurationsCreate(connectConfigurations *model.ConnectCustomConfiguration) *ConfigurationsCreateOp {
return &ConfigurationsCreateOp{
Credential: s.credential,
Method: "POST",
Path: "connect",
Payload: connectConfigurations,
QueryOpts: make(url.Values),
Version: esign.VersionV21,
}
}
// ConfigurationsCreateOp implements DocuSign API SDK Connect::createConfiguration
type ConfigurationsCreateOp esign.Op
// Do executes the op. A nil context will return error.
func (op *ConfigurationsCreateOp) Do(ctx context.Context) (*model.ConnectCustomConfiguration, error) {
var res *model.ConnectCustomConfiguration
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// ConfigurationsDelete deletes the specified connect configuration.
//
// https://developers.docusign.com/esign-rest-api/reference/connect/connectconfigurations/delete
//
// SDK Method Connect::deleteConfiguration
func (s *Service) ConfigurationsDelete(connectID string) *ConfigurationsDeleteOp {
return &ConfigurationsDeleteOp{
Credential: s.credential,
Method: "DELETE",
Path: strings.Join([]string{"connect", connectID}, "/"),
QueryOpts: make(url.Values),
Version: esign.VersionV21,
}
}
// ConfigurationsDeleteOp implements DocuSign API SDK Connect::deleteConfiguration
type ConfigurationsDeleteOp esign.Op
// Do executes the op. A nil context will return error.
func (op *ConfigurationsDeleteOp) Do(ctx context.Context) error {
return ((*esign.Op)(op)).Do(ctx, nil)
}
// ConfigurationsGet get information on a Connect Configuration
//
// https://developers.docusign.com/esign-rest-api/reference/connect/connectconfigurations/get
//
// SDK Method Connect::getConfiguration
func (s *Service) ConfigurationsGet(connectID string) *ConfigurationsGetOp {
return &ConfigurationsGetOp{
Credential: s.credential,
Method: "GET",
Path: strings.Join([]string{"connect", connectID}, "/"),
QueryOpts: make(url.Values),
Version: esign.VersionV21,
}
}
// ConfigurationsGetOp implements DocuSign API SDK Connect::getConfiguration
type ConfigurationsGetOp esign.Op
// Do executes the op. A nil context will return error.
func (op *ConfigurationsGetOp) Do(ctx context.Context) (*model.ConnectConfigResults, error) {
var res *model.ConnectConfigResults
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// ConfigurationsList get Connect Configuration Information
//
// https://developers.docusign.com/esign-rest-api/reference/connect/connectconfigurations/list
//
// SDK Method Connect::listConfigurations
func (s *Service) ConfigurationsList() *ConfigurationsListOp {
return &ConfigurationsListOp{
Credential: s.credential,
Method: "GET",
Path: "connect",
QueryOpts: make(url.Values),
Version: esign.VersionV21,
}
}
// ConfigurationsListOp implements DocuSign API SDK Connect::listConfigurations
type ConfigurationsListOp esign.Op
// Do executes the op. A nil context will return error.
func (op *ConfigurationsListOp) Do(ctx context.Context) (*model.ConnectConfigResults, error) {
var res *model.ConnectConfigResults
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// ConfigurationsListUsers returns users from the configured Connect service.
//
// https://developers.docusign.com/esign-rest-api/reference/connect/connectconfigurations/listusers
//
// SDK Method Connect::connectUsers
func (s *Service) ConfigurationsListUsers(connectID string) *ConfigurationsListUsersOp {
return &ConfigurationsListUsersOp{
Credential: s.credential,
Method: "GET",
Path: strings.Join([]string{"connect", connectID, "users"}, "/"),
QueryOpts: make(url.Values),
Version: esign.VersionV21,
}
}
// ConfigurationsListUsersOp implements DocuSign API SDK Connect::connectUsers
type ConfigurationsListUsersOp esign.Op
// Do executes the op. A nil context will return error.
func (op *ConfigurationsListUsersOp) Do(ctx context.Context) (*model.IntegratedUserInfoList, error) {
var res *model.IntegratedUserInfoList
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// Count optional. Number of items to return.
func (op *ConfigurationsListUsersOp) Count(val int) *ConfigurationsListUsersOp {
if op != nil {
op.QueryOpts.Set("count", fmt.Sprintf("%d", val))
}
return op
}
// EmailSubstring filters returned user records by full email address or a substring of email address.
func (op *ConfigurationsListUsersOp) EmailSubstring(val string) *ConfigurationsListUsersOp {
if op != nil {
op.QueryOpts.Set("email_substring", val)
}
return op
}
// ListIncludedUsers set the call query parameter list_included_users
func (op *ConfigurationsListUsersOp) ListIncludedUsers() *ConfigurationsListUsersOp {
if op != nil {
op.QueryOpts.Set("list_included_users", "true")
}
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 *ConfigurationsListUsersOp) StartPosition(val int) *ConfigurationsListUsersOp {
if op != nil {
op.QueryOpts.Set("start_position", fmt.Sprintf("%d", val))
}
return op
}
// Status filters the results by user status.
// You can specify a comma-separated
// list of the following statuses:
//
// * ActivationRequired
// * ActivationSent
// * Active
// * Closed
// * Disabled
func (op *ConfigurationsListUsersOp) Status(val ...string) *ConfigurationsListUsersOp {
if op != nil {
op.QueryOpts.Set("status", strings.Join(val, ","))
}
return op
}
// UserNameSubstring filters returned user records by full user name or a substring of user name.
func (op *ConfigurationsListUsersOp) UserNameSubstring(val string) *ConfigurationsListUsersOp {
if op != nil {
op.QueryOpts.Set("user_name_substring", val)
}
return op
}
// ConfigurationsUpdate updates a specified Connect configuration.
//
// https://developers.docusign.com/esign-rest-api/reference/connect/connectconfigurations/update
//
// SDK Method Connect::updateConfiguration
func (s *Service) ConfigurationsUpdate(connectConfigurations *model.ConnectCustomConfiguration) *ConfigurationsUpdateOp {
return &ConfigurationsUpdateOp{
Credential: s.credential,
Method: "PUT",
Path: "connect",
Payload: connectConfigurations,
QueryOpts: make(url.Values),
Version: esign.VersionV21,
}
}
// ConfigurationsUpdateOp implements DocuSign API SDK Connect::updateConfiguration
type ConfigurationsUpdateOp esign.Op
// Do executes the op. A nil context will return error.
func (op *ConfigurationsUpdateOp) Do(ctx context.Context) (*model.ConnectCustomConfiguration, error) {
var res *model.ConnectCustomConfiguration
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// EventsDelete deletes a specified Connect log entry.
//
// https://developers.docusign.com/esign-rest-api/reference/connect/connectevents/delete
//
// SDK Method Connect::deleteEventLog
func (s *Service) EventsDelete(logID string) *EventsDeleteOp {
return &EventsDeleteOp{
Credential: s.credential,
Method: "DELETE",
Path: strings.Join([]string{"connect", "logs", logID}, "/"),
QueryOpts: make(url.Values),
Version: esign.VersionV21,
}
}
// EventsDeleteOp implements DocuSign API SDK Connect::deleteEventLog
type EventsDeleteOp esign.Op
// Do executes the op. A nil context will return error.
func (op *EventsDeleteOp) Do(ctx context.Context) error {
return ((*esign.Op)(op)).Do(ctx, nil)
}
// EventsDeleteFailure deletes a Connect failure log entry.
//
// https://developers.docusign.com/esign-rest-api/reference/connect/connectevents/deletefailure
//
// SDK Method Connect::deleteEventFailureLog
func (s *Service) EventsDeleteFailure(failureID string) *EventsDeleteFailureOp {
return &EventsDeleteFailureOp{
Credential: s.credential,
Method: "DELETE",
Path: strings.Join([]string{"connect", "failures", failureID}, "/"),
QueryOpts: make(url.Values),
Version: esign.VersionV21,
}
}
// EventsDeleteFailureOp implements DocuSign API SDK Connect::deleteEventFailureLog
type EventsDeleteFailureOp esign.Op
// Do executes the op. A nil context will return error.
func (op *EventsDeleteFailureOp) Do(ctx context.Context) error {
return ((*esign.Op)(op)).Do(ctx, nil)
}
// EventsDeleteList gets a list of Connect log entries.
//
// https://developers.docusign.com/esign-rest-api/reference/connect/connectevents/deletelist
//
// SDK Method Connect::deleteEventLogs
func (s *Service) EventsDeleteList() *EventsDeleteListOp {
return &EventsDeleteListOp{
Credential: s.credential,
Method: "DELETE",
Path: "connect/logs",
QueryOpts: make(url.Values),
Version: esign.VersionV21,
}
}
// EventsDeleteListOp implements DocuSign API SDK Connect::deleteEventLogs
type EventsDeleteListOp esign.Op
// Do executes the op. A nil context will return error.
func (op *EventsDeleteListOp) Do(ctx context.Context) error {
return ((*esign.Op)(op)).Do(ctx, nil)
}
// EventsGet get the specified Connect log entry.
//
// https://developers.docusign.com/esign-rest-api/reference/connect/connectevents/get
//
// SDK Method Connect::getEventLog
func (s *Service) EventsGet(logID string) *EventsGetOp {
return &EventsGetOp{
Credential: s.credential,
Method: "GET",
Path: strings.Join([]string{"connect", "logs", logID}, "/"),
QueryOpts: make(url.Values),
Version: esign.VersionV21,
}
}
// EventsGetOp implements DocuSign API SDK Connect::getEventLog
type EventsGetOp esign.Op
// Do executes the op. A nil context will return error.
func (op *EventsGetOp) Do(ctx context.Context) (*model.ConnectLog, error) {
var res *model.ConnectLog
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// AdditionalInfo when true, the connectDebugLog information is included in the response.
func (op *EventsGetOp) AdditionalInfo() *EventsGetOp {
if op != nil {
op.QueryOpts.Set("additional_info", "true")
}
return op
}
// EventsList gets the Connect log.
//
// https://developers.docusign.com/esign-rest-api/reference/connect/connectevents/list
//
// SDK Method Connect::listEventLogs
func (s *Service) EventsList() *EventsListOp {
return &EventsListOp{
Credential: s.credential,
Method: "GET",
Path: "connect/logs",
QueryOpts: make(url.Values),
Version: esign.VersionV21,
}
}
// EventsListOp implements DocuSign API SDK Connect::listEventLogs
type EventsListOp esign.Op
// Do executes the op. A nil context will return error.
func (op *EventsListOp) Do(ctx context.Context) (*model.ConnectLogs, error) {
var res *model.ConnectLogs
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// 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 *EventsListOp) FromDate(val time.Time) *EventsListOp {
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 *EventsListOp) ToDate(val time.Time) *EventsListOp {
if op != nil {
op.QueryOpts.Set("to_date", val.Format(time.RFC3339))
}
return op
}
// EventsListFailures gets the Connect failure log information.
//
// https://developers.docusign.com/esign-rest-api/reference/connect/connectevents/listfailures
//
// SDK Method Connect::listEventFailureLogs
func (s *Service) EventsListFailures() *EventsListFailuresOp {
return &EventsListFailuresOp{
Credential: s.credential,
Method: "GET",
Path: "connect/failures",
QueryOpts: make(url.Values),
Version: esign.VersionV21,
}
}
// EventsListFailuresOp implements DocuSign API SDK Connect::listEventFailureLogs
type EventsListFailuresOp esign.Op
// Do executes the op. A nil context will return error.
func (op *EventsListFailuresOp) Do(ctx context.Context) (*model.ConnectLogs, error) {
var res *model.ConnectLogs
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// 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 *EventsListFailuresOp) FromDate(val time.Time) *EventsListFailuresOp {
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 *EventsListFailuresOp) ToDate(val time.Time) *EventsListFailuresOp {
if op != nil {
op.QueryOpts.Set("to_date", val.Format(time.RFC3339))
}
return op
}
// EventsRetryForEnvelope republishes Connect information for the specified envelope.
// If media is an io.ReadCloser, Do() will close media.
//
// https://developers.docusign.com/esign-rest-api/reference/connect/connectevents/retryforenvelope
//
// SDK Method Connect::retryEventForEnvelope
func (s *Service) EventsRetryForEnvelope(envelopeID string, media io.Reader, mimeType string) *EventsRetryForEnvelopeOp {
return &EventsRetryForEnvelopeOp{
Credential: s.credential,
Method: "PUT",
Path: strings.Join([]string{"connect", "envelopes", envelopeID, "retry_queue"}, "/"),
Payload: &esign.UploadFile{Reader: media, ContentType: mimeType},
QueryOpts: make(url.Values),
Version: esign.VersionV21,
}
}
// EventsRetryForEnvelopeOp implements DocuSign API SDK Connect::retryEventForEnvelope
type EventsRetryForEnvelopeOp esign.Op
// Do executes the op. A nil context will return error.
func (op *EventsRetryForEnvelopeOp) Do(ctx context.Context) (*model.ConnectFailureResults, error) {
var res *model.ConnectFailureResults
return res, ((*esign.Op)(op)).Do(ctx, &res)
}
// EventsRetryForEnvelopes republishes Connect information for multiple envelopes.
//
// https://developers.docusign.com/esign-rest-api/reference/connect/connectevents/retryforenvelopes
//
// SDK Method Connect::retryEventForEnvelopes
func (s *Service) EventsRetryForEnvelopes(connectFailureFilter *model.ConnectFailureFilter) *EventsRetryForEnvelopesOp {
return &EventsRetryForEnvelopesOp{
Credential: s.credential,
Method: "PUT",
Path: "connect/envelopes/retry_queue",
Payload: connectFailureFilter,
QueryOpts: make(url.Values),
Version: esign.VersionV21,
}
}
// EventsRetryForEnvelopesOp implements DocuSign API SDK Connect::retryEventForEnvelopes
type EventsRetryForEnvelopesOp esign.Op
// Do executes the op. A nil context will return error.
func (op *EventsRetryForEnvelopesOp) Do(ctx context.Context) (*model.ConnectFailureResults, error) {
var res *model.ConnectFailureResults
return res, ((*esign.Op)(op)).Do(ctx, &res)
}