|
| 1 | +# DocuSign eSignature RestApi v2 for Go |
| 2 | + |
| 3 | +esign provides Go packages for interacting with DocuSign's eSignature RestApi and |
| 4 | +has been created using the lastest published swagger definition. |
| 5 | + |
| 6 | +The package requires Go 1.7 or above and has been tested with Go 1.9-1.12. |
| 7 | + |
| 8 | +The previous package github.com/jfcote87/docusign is now deprecated. |
| 9 | + |
| 10 | +## Resources |
| 11 | + |
| 12 | +Official documentation: [https://developers.docusign.com/](https://developers.docusign.com/) |
| 13 | + |
| 14 | +## Package Updates |
| 15 | + |
| 16 | +All packages, excepte for gen-esign and legacy, are generated from DocuSign's [OpenAPI(swagger) specification](https://github.com/docusign/eSign-OpenAPI-Specification) using the gen-esign package. |
| 17 | + |
| 18 | +Corrections to field names and definitions are documented in gen-esign/overrides/overrides.go. |
| 19 | + |
| 20 | +The package names correspond to the API categories listed on the |
| 21 | +[DocuSign REST API Reference](https://developers.docusign.com/esign-rest-api/reference) page. |
| 22 | +Each operation contains an SDK Method which corresponds to the package operation which you will |
| 23 | +find in operation definition. |
| 24 | + |
| 25 | +## Authentication |
| 26 | + |
| 27 | +Authentication is handled by the esign.Credential interface. OAuth2Credentials may be created |
| 28 | +via the OAuth2Config struct for 3-legged oauth and the JWTConfig struct for 2-legged oauth. Examples |
| 29 | +are shown for each in the esign examples. |
| 30 | + |
| 31 | +UserID/Password login is available via the legacy.Config which may also be used to create non-expiring |
| 32 | +oauth tokens (legacy.OauthCredential). Examples are shown in the legacy package. |
| 33 | + |
| 34 | +## Models |
| 35 | + |
| 36 | +The model package describes the structure of all data passed to and received from API calls. |
| 37 | + |
| 38 | +## Operations |
| 39 | + |
| 40 | +Each package has a service object which is initialized via the <packagename>.New(<credential>) call. |
| 41 | +The service methods define all operations for the package with corresponding options. An operation is |
| 42 | +executed via a Do(context.Context) function. A context must be passwed for all operation |
| 43 | + |
| 44 | +## Example |
| 45 | + |
| 46 | +Create envelope |
| 47 | + |
| 48 | +```go |
| 49 | + sv := envelopes.New(credential) |
| 50 | + |
| 51 | + f1, err := ioutil.ReadFile("letter.pdf") |
| 52 | + if err != nil { |
| 53 | + return nil, err |
| 54 | + } |
| 55 | + f2, err := ioutil.ReadFile("contract.pdf") |
| 56 | + if err != nil { |
| 57 | + return nil, err |
| 58 | + } |
| 59 | + |
| 60 | + env := &model.EnvelopeDefinition{ |
| 61 | + EmailSubject: "[Go eSignagure SDK] - Please sign this doc", |
| 62 | + EmailBlurb: "Please sign this test document", |
| 63 | + Status: "sent", |
| 64 | + Documents: []model.Document{ |
| 65 | + { |
| 66 | + DocumentBase64: f1, |
| 67 | + Name: "invite letter.pdf", |
| 68 | + DocumentID: "1", |
| 69 | + }, |
| 70 | + { |
| 71 | + DocumentBase64: f2, |
| 72 | + Name: "contract.pdf", |
| 73 | + DocumentID: "2", |
| 74 | + }, |
| 75 | + }, |
| 76 | + Recipients: &model.Recipients{ |
| 77 | + Signers: []model.Signer{ |
| 78 | + { |
| 79 | + Email: email, |
| 80 | + EmailNotification: nil, |
| 81 | + Name: name, |
| 82 | + RecipientID: "1", |
| 83 | + Tabs: &model.Tabs{ |
| 84 | + SignHereTabs: []model.SignHere{ |
| 85 | + { |
| 86 | + TabBase: model.TabBase{ |
| 87 | + DocumentID: "1", |
| 88 | + RecipientID: "1", |
| 89 | + }, |
| 90 | + TabPosition: model.TabPosition{ |
| 91 | + PageNumber: "1", |
| 92 | + TabLabel: "signature", |
| 93 | + XPosition: "192", |
| 94 | + YPosition: "160", |
| 95 | + }, |
| 96 | + }, |
| 97 | + }, |
| 98 | + DateSignedTabs: []model.DateSigned{ |
| 99 | + { |
| 100 | + TabBase: model.TabBase{ |
| 101 | + DocumentID: "1", |
| 102 | + RecipientID: "1", |
| 103 | + }, |
| 104 | + TabPosition: model.TabPosition{ |
| 105 | + PageNumber: "1", |
| 106 | + TabLabel: "dateSigned", |
| 107 | + XPosition: "334", |
| 108 | + YPosition: "179", |
| 109 | + }, |
| 110 | + }, |
| 111 | + }, |
| 112 | + TextTabs: []model.Text{ |
| 113 | + { |
| 114 | + TabBase: model.TabBase{ |
| 115 | + DocumentID: "2", |
| 116 | + RecipientID: "1", |
| 117 | + }, |
| 118 | + TabPosition: model.TabPosition{ |
| 119 | + PageNumber: "1", |
| 120 | + TabLabel: "txtNote", |
| 121 | + XPosition: "70", |
| 122 | + YPosition: "564", |
| 123 | + }, |
| 124 | + TabStyle: model.TabStyle{ |
| 125 | + Name: "This is the tab tooltip", |
| 126 | + }, |
| 127 | + Width: 300, |
| 128 | + Height: 150, |
| 129 | + }, |
| 130 | + }, |
| 131 | + }, |
| 132 | + }, |
| 133 | + }, |
| 134 | + }, |
| 135 | + } |
| 136 | + envSummary, err := sv.Create(env).Do(context.Background()) |
| 137 | +``` |
0 commit comments