Skip to content

Commit

Permalink
Merge pull request #4190 from nickmango/icla-webhook
Browse files Browse the repository at this point in the history
Webhook Payload
  • Loading branch information
nickmango authored Nov 23, 2023
2 parents 45c2c22 + bed0e84 commit 4133431
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 84 deletions.
143 changes: 65 additions & 78 deletions cla-backend-go/v2/sign/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,19 +331,9 @@ type DocuSignRecipientEvent struct {
}

type DocuSignEventNotification struct {
URL string `json:"url"`
LoggingEnabled bool `json:"loggingEnabled"`
RequireAcknowledgment string `json:"requireAcknowledgment"`
UseSoapInterface string `json:"useSoapInterface"`
IncludeCertificateWithSoap string `json:"includeCertificateWithSoap"`
SignMessageWithX509Cert string `json:"signMessageWithX509Cert"`
IncludeDocuments string `json:"includeDocuments"`
IncludeEnvelopeVoidReason string `json:"includeEnvelopeVoidReason"`
IncludeTimeZone string `json:"includeTimeZone"`
IncludeSenderAccountAsCustomField string `json:"includeSenderAccountAsCustomField"`
IncludeDocumentFields string `json:"includeDocumentFields"`
IncludeCertificateOfCompletion string `json:"includeCertificateOfCompletion"`
EnvelopeEvents []DocuSignRecipientEvent `json:"envelopeEvents"`
URL string `json:"url"`
LoggingEnabled bool `json:"loggingEnabled"`
EnvelopeEvents []DocuSignRecipientEvent `json:"envelopeEvents"`
}

type Recipient struct {
Expand Down Expand Up @@ -411,74 +401,65 @@ type DocusignRecipientViewResponse struct {
URL string `json:"url"`
}

type Payload struct {
APIVersion string `json:"apiVersion"`
ConfigurationID int `json:"configurationId"`
Data Data `json:"data"`
Event string `json:"event"`
GeneratedDateTime string `json:"generatedDateTime"`
RetryCount int `json:"retryCount"`
URI string `json:"uri"`
}

type Data struct {
AccountID string `json:"accountId"`
EnvelopeID string `json:"envelopeId"`
EnvelopeSummary EnvelopeSummary `json:"envelopeSummary"`
UserID string `json:"userId"`
}

type EnvelopeSummary struct {
AllowComments string `json:"allowComments"`
AllowMarkup string `json:"allowMarkup"`
AllowReassign string `json:"allowReassign"`
AllowViewHistory string `json:"allowViewHistory"`
AnySigner interface{} `json:"anySigner"`
AttachmentsURI string `json:"attachmentsUri"`
AutoNavigation string `json:"autoNavigation"`
BurnDefaultTabData string `json:"burnDefaultTabData"`
CertificateURI string `json:"certificateUri"`
CompletedDateTime string `json:"completedDateTime"`
CreatedDateTime string `json:"createdDateTime"`
CustomFieldsURI string `json:"customFieldsUri"`
DeliveredDateTime string `json:"deliveredDateTime"`
DocumentsCombinedURI string `json:"documentsCombinedUri"`
DocumentsURI string `json:"documentsUri"`
EmailBlurb string `json:"emailBlurb"`
EmailSubject string `json:"emailSubject"`
EnableWetSign string `json:"enableWetSign"`
EnvelopeID string `json:"envelopeId"`
EnvelopeIdStamping string `json:"envelopeIdStamping"`
EnvelopeLocation string `json:"envelopeLocation"`
// DocuSignWebhookModel represents the webhook callback data model from DocuSign
type DocuSignWebhookModel struct {
APIVersion string `json:"apiVersion"` // v2.1
ConfigurationID int `json:"configurationId"` // 10418598
Data DocuSignWebhookData `json:"data"`
Event string `json:"event"` // envelope-sent, envelope-completed
GeneratedDateTime time.Time `json:"generatedDateTime"` // generated_date_time
URI string `json:"uri"` // /restapi/v2.1/accounts/77c754e9-4016-4ccc-957f-15eaa18f2d22/envelopes/016d4678-bf5c-41f3-b7c9-5c58606cdb4a
}

type DocuSignWebhookData struct {
AccountID string `json:"accountId"` // 77c754e9-4016-4ccc-957f-15eaa18f2d22
EnvelopeID string `json:"envelopeId"` // 016d4678-bf5c-41f3-b7c9-5c58606cdb4a
EnvelopeSummary DocuSignEnvelopeSummary `json:"envelopeSummary"`
UserID string `json:"userId"` // 9fd66d5d-7396-4b80-a85e-2a7e536471b1
}

type DocuSignEnvelopeSummary struct {
AllowComments string `json:"allowComments"` // "true"
AllowMarkup string `json:"allowMarkup"` // "false"
AllowReassign string `json:"allowReassign"` // "true"
AllowViewHistory string `json:"allowViewHistory"` // "true"
AnySigner interface{} `json:"anySigner"` // <nil>
AttachmentsURI string `json:"attachmentsUri"` // /envelopes/016d4678-bf5c-41f3-b7c9-5c58606cdb4a/attachments
AutoNavigation string `json:"autoNavigation"` // "true"
BurnDefaultTabData string `json:"burnDefaultTabData"` // "false"
CertificateURI string `json:"certificateUri"` // /envelopes/016d4678-bf5c-41f3-b7c9-5c58606cdb4a/documents/summary
CreatedDateTime time.Time `json:"createdDateTime"` // 2023-05-26T18:55:47.18Z
CustomFieldsURI string `json:"customFieldsUri"` // /envelopes/016d4678-bf5c-41f3-b7c9-5c58606cdb4a/custom_fields
DocumentsCombinedURI string `json:"documentsCombinedUri"` // /envelopes/016d4678-bf5c-41f3-b7c9-5c58606cdb4a/documents/combined
DocumentsURI string `json:"documentsUri"` // /envelopes/016d4678-bf5c-41f3-b7c9-5c58606cdb4a/documents
EmailSubject string `json:"emailSubject"` // Please DocuSign this document: Test DocuSign
EnableWetSign string `json:"enableWetSign"` // "false"
EnvelopeID string `json:"envelopeId"` // 016d4678-bf5c-41f3-b7c9-5c58606cdb4a
EnvelopeIDStamping string `json:"envelopeIdStamping"` // "true"
EnvelopeLocation string `json:"envelopeLocation"` // current_site
EnvelopeMetadata EnvelopeMetadata `json:"envelopeMetadata"`
EnvelopeURI string `json:"envelopeUri"`
ExpireAfter string `json:"expireAfter"`
ExpireDateTime string `json:"expireDateTime"`
ExpireEnabled string `json:"expireEnabled"`
HasComments string `json:"hasComments"`
HasFormDataChanged string `json:"hasFormDataChanged"`
InitialSentDateTime string `json:"initialSentDateTime"`
Is21CFRPart11 string `json:"is21CFRPart11"`
IsDynamicEnvelope string `json:"isDynamicEnvelope"`
IsSignatureProviderEnvelope string `json:"isSignatureProviderEnvelope"`
LastModifiedDateTime string `json:"lastModifiedDateTime"`
NotificationURI string `json:"notificationUri"`
PurgeState string `json:"purgeState"`
EnvelopeURI string `json:"envelopeUri"` // /envelopes/016d4678-bf5c-41f3-b7c9-5c58606cdb4a
ExpiresAfter string `json:"expiresAfter"` // 120
ExpireDateTime time.Time `json:"expireDateTime"` // 2023-05-26T18:55:48.257Z
ExpireEnabled string `json:"expireEnabled"` // "true"
HasComments string `json:"hasComments"` // "false"
HasFormDataChanged string `json:"hasFormDataChanged"` // "false"
InitialSendDateTime time.Time `json:"initialSendDateTime"` // 2023-05-26T18:55:48.257Z
Is21CFRPart11 string `json:"is21CFRPart11"` // "false"
IsDynamicEnvelope string `json:"isDynamicEnvelope"` // "false"
IsSignatureProviderEnvelope string `json:"isSignatureProviderEnvelope"` // "false"
LastModifiedDateTime time.Time `json:"lastModifiedDateTime"` // 2023-05-26T18:55:48.257Z
NotificationURI string `json:"notificationUri"` // /envelopes/016d4678-bf5c-41f3-b7c9-5c58606cdb4a/notification
PurgeState string `json:"purgeState"` // unpurged
Recipients Recipients `json:"recipients"`
RecipientsURI string `json:"recipientsUri"`
RecipientsURI string `json:"recipientsUri"` // /envelopes/016d4678-bf5c-41f3-b7c9-5c58606cdb4a/recipients
Sender Sender `json:"sender"`
SentDateTime string `json:"sentDateTime"`
SignerCanSignOnMobile string `json:"signerCanSignOnMobile"`
SigningLocation string `json:"signingLocation"`
Status string `json:"status"`
StatusChangedDateTime string `json:"statusChangedDateTime"`
TemplatesURI string `json:"templatesUri"`
}

type EnvelopeMetadata struct {
AllowAdvancedCorrect string `json:"allowAdvancedCorrect"`
AllowCorrect string `json:"allowCorrect"`
EnableSignWithNotary string `json:"enableSignWithNotary"`
SentDateTime time.Time `json:"sentDateTime"` // 2023-05-26T18:55:48.257Z
SignerCanSignOnMobile string `json:"signerCanSignOnMobile"` // "true"
SignerLocation string `json:"signerLocation"` // online
Status string `json:"status"` // sent
StatusChangedDateTime time.Time `json:"statusChangedDateTime"` // 2023-05-26T18:55:48.257Z
TemplatesURI string `json:"templatesUri"` // /envelopes/016d4678-bf5c-41f3-b7c9-5c58606cdb4a/templates0:w
}

type Recipients struct {
Expand All @@ -496,6 +477,12 @@ type Recipients struct {
Witnesses []interface{} `json:"witnesses"` // <nil>
}

type EnvelopeMetadata struct {
AllowAdvancedCorrect string `json:"allowAdvancedCorrect"` // "false"
AllowCorrect string `json:"allowCorrect"` // "true"
EnableSignWithNotary string `json:"enableSignWithNotary"` // "false"
}

type WebhookSigner struct {
CompletedCount string `json:"completedCount"` // 0
CreationReason string `json:"creationReason"` // sender
Expand Down
12 changes: 6 additions & 6 deletions cla-backend-go/v2/sign/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,9 @@ func (s *service) SignedIndividualCallbackGithub(ctx context.Context, payload []

log.WithFields(f).Debug("processing signed individual callback...")

var dataModel Payload
var dataModel DocuSignWebhookModel

// var dataModel Payload

err := json.Unmarshal(payload, &dataModel)
if err != nil {
Expand Down Expand Up @@ -984,11 +986,9 @@ func (s *service) populateSignURL(ctx context.Context,
}

eventNotification := DocuSignEventNotification{
URL: callbackURL,
LoggingEnabled: true,
EnvelopeEvents: recipientEvents,
UseSoapInterface: "true",
IncludeDocuments: "true",
URL: callbackURL,
LoggingEnabled: true,
EnvelopeEvents: recipientEvents,
}

envelopeRequest = DocuSignEnvelopeRequest{
Expand Down

0 comments on commit 4133431

Please sign in to comment.