1

I'm using the Docusign Java SDK and I'm curious if anyone else noticed it's NOT typesafe. Are there at least constants for the value I can use instead of generic String values.

for example, to send a JSON webhook payload when you use request an envelope signature:

// configure a connect notification
EventNotification eventNotification = new EventNotification();

// Set up the endpoint URL to call (it must be using HTTPS and at least TLS1.1 or higher)
eventNotification.setUrl("my-webhook-url");

// DocuSign will retry on failure if this is set
eventNotification.setRequireAcknowledgment("true");  <---- the String "true"?????

// This would send the documents together with the event to the endpoint
eventNotification.setIncludeDocuments("false");  <---- the String "false"?????

// Allows you to see this in the DocuSign Admin Connect logs section
eventNotification.setLoggingEnabled("true");  <---- the String "true"?????

// send an event when the envelope is sent and completed.
EnvelopeEvent sentEvent = new EnvelopeEvent();
sentEvent.setEnvelopeEventStatusCode("Sent");   <---- the String "Sent"?????
sentEvent.setIncludeDocuments("false");

EnvelopeEvent completedEvent = new EnvelopeEvent();
completedEvent.setEnvelopeEventStatusCode("Completed");  <---- the String "Completed"?????
completedEvent.setIncludeDocuments("false");

eventNotification.setEnvelopeEvents(List.of(sentEvent, completedEvent));

ConnectEventData eventData = new ConnectEventData();
eventData.setVersion("restv2.1");   <---- surely these should be constants....right?
eventData.setFormat("json");        <----

eventNotification.setEventData(eventData);
envelope.setEventNotification(eventNotification);

this documentation led me to use Strings like envelope-completed instead of Completed....which cost me hours of trial and error.

Isn't the whole point of an SDK in a language like Java to be type safe? What am I missing here?

Jason
  • 2,451
  • 2
  • 23
  • 31

1 Answers1

1

This is not an issue with the Java SDK, but with the swagger file that has definitions for various fields in the DocuSign eSignature REST API.

The swagger file defines many things as strings, even if they do not have to be strings. Changing this now would be a breaking change for many integrations and developers that rely on this (buggy or not) behavior.

This may be fixed in a new version of the API to avoid having backward compatibility issues.

Inbar Gazit
  • 12,566
  • 1
  • 16
  • 23
  • the issue I have is that the docs refer to events names like `envelope-complete` but when you use the SDK that only requires a String value....the value "envelope-completed" does not work......but the value "completed" does. IE: I had to do this: `envelope.setEnvelopeEventStatusCode("Completed")`. – Jason Dec 07 '22 at 17:12
  • Which doc exactly? maybe we have to fix that doc – Inbar Gazit Dec 07 '22 at 17:24
  • envelope-complete is for Connect webhook, not for setting an envelope status. Maybe there's some confusion? – Inbar Gazit Dec 07 '22 at 17:25
  • https://developers.docusign.com/platform/webhooks/connect/event-triggers/ would lead you to believe that `setEnvelopeEventStatusCode()` should be set to `envelope-completed`, but that didn't work for me and even worse, nothing failed or indicated I used the wrong magic string. Once I use `Completed` my envelope connect hook worked as expected – Jason Dec 07 '22 at 22:37
  • Do you use Connect 1.0 or Connect 2.0? – Inbar Gazit Dec 07 '22 at 23:14
  • https://www.docusign.com/blog/developers/connect-20 – Inbar Gazit Dec 07 '22 at 23:14
  • that doc links directly to the doc I referenced. – Jason Dec 08 '22 at 14:00
  • ok, sorry for the confusion. What questions can I answer for you? – Inbar Gazit Dec 08 '22 at 16:39
  • you already answered the question. I don't understand why you couldn't leave all the existing code in place and provide string constants or better yet, enums for the values in the SDK. No reason this needs to be a breaking change. – Jason Dec 09 '22 at 20:32
  • This is a new version of the Connect and there are two different things, one is called events and the other is called envelopeEvents. This is not a breaking change since we added a new fields. – Inbar Gazit Dec 09 '22 at 20:58
  • You use setEnvelopeEventStatusCode() which is the old way to do this. The setEvents() which is the new way is better in many ways, support more events and have some other advantages... – Inbar Gazit Dec 09 '22 at 20:59