Skip to content

Commit

Permalink
DEVDOCS-10206 adding codeDepot markers
Browse files Browse the repository at this point in the history
  • Loading branch information
raileendr committed Oct 13, 2023
1 parent 8a79aba commit ed93399
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public EG010ControllerSendBinaryDocs(DSConfiguration config, Session session, Us
}

@Override
// ***DS.snippet.0.start
protected Object doWork(WorkArguments args, ModelMap model, HttpServletResponse response) throws IOException {
String responseString = SendBinaryDocsService.sendBinaryDocs(
args,
Expand All @@ -54,5 +53,4 @@ protected Object doWork(WorkArguments args, ModelMap model, HttpServletResponse
.addToModel(model, config);
return DONE_EXAMPLE_PAGE;
}
// ***DS.snippet.0.end
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public static String sendBinaryDocs(
String accountId,
String accessToken
) throws IOException {
// Step 1. Gather documents and their headers
List<DocumentInfo> documents = List.of(
new DocumentInfo(HTML_DOCUMENT_NAME, "1", DocumentType.HTML,
EnvelopeHelpers.createHtmlFromTemplateFile(HTML_DOCUMENT_FILE_NAME, "args", args)
Expand All @@ -59,15 +58,15 @@ public static String sendBinaryDocs(
EnvelopeHelpers.readFile(PDF_DOCUMENT_FILE_NAME))
);

// Step 2. Make the envelope JSON request body
// Make the envelope JSON request body
JSONObject envelopeJSON = SendBinaryDocsService.makeEnvelopeJSON(
signerName,
signerEmail,
ccName,
ccEmail,
documents);

// Step 3. Create the multipart body
// Create the multipart body
URL uri = new URL(String.format("%s/v2.1/accounts/%s/envelopes", basePath, accountId));
String contentType = String.join(
"",
Expand All @@ -81,6 +80,7 @@ public static String sendBinaryDocs(
connection.setDoOutput(true);

// See https://developers.docusign.com/esign-rest-api/guides/requests-and-responses
//ds-snippet-start:eSign10Step4
DataOutputStream buffer = new DataOutputStream(connection.getOutputStream());
SendBinaryDocsService.writeBoundaryHeader(buffer, MediaType.APPLICATION_JSON, "form-data");
buffer.writeBytes(envelopeJSON.toString(DoneExample.JSON_INDENT_FACTOR));
Expand All @@ -102,6 +102,7 @@ public static String sendBinaryDocs(

return StreamUtils.copyToString(connection.getInputStream(), StandardCharsets.UTF_8);
}
//ds-snippet-end:eSign10Step4

private static void writeBoundaryHeader(
DataOutputStream buffer,
Expand Down Expand Up @@ -136,6 +137,7 @@ private static void writeClosingBoundary(DataOutputStream buffer) throws IOExcep
// recipient 2 - cc
// The envelope will be sent first to the signer.
// After it is signed, a copy is sent to the cc person.
//ds-snippet-start:eSign10Step3
private static JSONObject makeEnvelopeJSON(
String signerName,
String signerEmail,
Expand Down Expand Up @@ -189,6 +191,7 @@ private static JSONObject makeEnvelopeJSON(

return envelopeJSON;
}
//ds-snippet-end:eSign10Step3
@Value
public static class DocumentInfo {
String name;
Expand Down

0 comments on commit ed93399

Please sign in to comment.