Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronWDS committed Oct 12, 2023
2 parents eeb1306 + 16121ac commit 28f1f69
Show file tree
Hide file tree
Showing 18 changed files with 79 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,20 @@ protected void onInitModel(WorkArguments args, ModelMap model) throws Exception
}

@Override
// ***DS.snippet.0.start
protected Object doWork(WorkArguments args, ModelMap model, HttpServletResponse response) throws ApiException {
// Step 1. get envelope recipients
//ds-snippet-start:eSign15Step2
EnvelopesApi envelopesApi = createEnvelopesApi(session.getBasePath(), user.getAccessToken());
//ds-snippet-end:eSign15Step2
//ds-snippet-start:eSign15Step3
EnvelopeFormData envelopeFormData = GetTabValuesService.getTabValues(
envelopesApi,
session.getAccountId(),
session.getEnvelopeId());
//ds-snippet-end:eSign15Step3
DoneExample.createDefault(getTextForCodeExampleByApiType().ExampleName)
.withJsonObject(envelopeFormData)
.withMessage(getTextForCodeExampleByApiType().ResultsPageText)
.addToModel(model, config);
return DONE_EXAMPLE_PAGE;
}
// ***DS.snippet.0.end
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,28 @@ protected Object doWork(WorkArguments args, ModelMap model,

EnvelopeDefinition envelope = SetTabValuesService.makeEnvelope(signerEmail, signerName);

// Step 2. Construct your API headers
//ds-snippet-start:eSign16Step2
ApiClient apiClient = createApiClient(session.getBasePath(), user.getAccessToken());
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
//ds-snippet-end:eSign16Step2

// Step 5. Call the eSignature REST API
// Call the eSignature REST API
//ds-snippet-start:eSign16Step4
EnvelopeSummary envelopeSummary = SetTabValuesService.createEnvelope(envelopesApi, accountId, envelope);
//ds-snippet-end:eSign16Step4

String envelopeId = envelopeSummary.getEnvelopeId();
session.setEnvelopeId(envelopeId);

// Step 6. Create the view request
// Create the view request
//ds-snippet-start:eSign16Step5
RecipientViewRequest viewRequest = SetTabValuesService.makeRecipientViewRequest(
signerEmail,
signerName,
config.getDsReturnUrl(),
config.getDsPingUrl());
ViewUrl viewUrl = SetTabValuesService.createRecipientView(envelopesApi, accountId, envelopeId, viewRequest);
//ds-snippet-end:eSign16Step5

// State can be stored/recovered using the framework's session or a
// query parameter on the returnUrl (see the makeRecipientViewRequest method)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ protected void onInitModel(WorkArguments args, ModelMap model) throws Exception
}

@Override
// ***DS.snippet.0.start
protected Object doWork(WorkArguments args, ModelMap model, HttpServletResponse response) throws ApiException {
// Step 2. Construct your API headers
//ds-snippet-start:eSign18Step2
EnvelopesApi envelopesApi = createEnvelopesApi(session.getBasePath(), user.getAccessToken());
// Step 3. Call the eSignature REST API
//ds-snippet-end:eSign18Step2
//ds-snippet-start:eSign18Step3
CustomFieldsEnvelope customFieldsEnvelope = EnvelopeCustomFieldValuesService.envelopeCustomFieldValues(
envelopesApi,
session.getAccountId(),
session.getEnvelopeId()
);
//ds-snippet-end:eSign18Step3

DoneExample.createDefault(getTextForCodeExampleByApiType().ExampleName)
.withJsonObject(customFieldsEnvelope)
.withMessage(getTextForCodeExampleByApiType().ResultsPageText)
.addToModel(model, config);
return DONE_EXAMPLE_PAGE;
}
// ***DS.snippet.0.end
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public EG019ControllerAccessCodeAuthentication(DSConfiguration config, Session s
}

@Override
// ***DS.snippet.0.start
protected Object doWork(WorkArguments args, ModelMap model,
HttpServletResponse response) throws ApiException, IOException {
// Step 1: Construct your API headers
Expand Down Expand Up @@ -63,5 +62,4 @@ protected Object doWork(WorkArguments args, ModelMap model,

return DONE_EXAMPLE_PAGE;
}
// ***DS.snippet.0.end
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected Object doWork(WorkArguments args, ModelMap model, HttpServletResponse
// Step 3: Construct your envelope JSON body
EnvelopeDefinition envelope = makeEnvelope(args, session.getTemplateId());

// Step 5: Call the eSignature REST API
// Step 4: Call the eSignature REST API
EnvelopeSummary envelopeSummary = ApplyBrandToTemplateService.applyBrandToTemplate(
envelopesApi,
session.getAccountId(),
Expand All @@ -90,6 +90,7 @@ protected Object doWork(WorkArguments args, ModelMap model, HttpServletResponse
return DONE_EXAMPLE_PAGE;
}

//ds-snippet-start:eSign30Step3
private static EnvelopeDefinition makeEnvelope(WorkArguments args, String templateId) {
TemplateRole signer = new TemplateRole()
.email(args.getSignerEmail())
Expand All @@ -107,4 +108,5 @@ private static EnvelopeDefinition makeEnvelope(WorkArguments args, String templa
.brandId(args.getBrandId())
.status(EnvelopeHelpers.ENVELOPE_STATUS_SENT);
}
//ds-snippet-end:eSign30Step3
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,25 @@ protected Object doWork(WorkArguments args, ModelMap model, HttpServletResponse
throws ApiException, IOException
{

// Step 2: Construct your API headers
//ds-snippet-start:eSign32Step2
EnvelopesApi envelopesApi = createEnvelopesApi(this.session.getBasePath(), this.user.getAccessToken());

// Step 3: Construct your envelope JSON body
//ds-snippet-end:eSign32Step2

// Construct your envelope JSON body
EnvelopeDefinition envelope = PauseSignatureWorkflowService.createEnvelope(
args.getSignerName(),
args.getSignerEmail(),
args.getSignerName2(),
args.getSignerEmail2()
);

// Step 4: Call the eSignature REST API
//ds-snippet-start:eSign32Step4
EnvelopeSummary envelopeSummary = PauseSignatureWorkflowService.pauseSignatureWorkflow(
envelopesApi,
this.session.getAccountId(),
envelope
);
//ds-snippet-end:eSign32Step4

this.session.setEnvelopeId(envelopeSummary.getEnvelopeId());
DoneExample.createDefault(this.title)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ protected Object doWork(WorkArguments args, ModelMap model,
EnvelopeDefinition envelope = InPersonSigningService.makeEnvelope(hostEmail, hostName, signerName,
ANCHOR_OFFSET_Y, ANCHOR_OFFSET_X, DOCUMENT_FILE_NAME, DOCUMENT_NAME);

// Step 3 start
//ds-snippet-start:eSign39Step3
ApiClient apiClient = createApiClient(basePath, accessToken);
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);

EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envelope);
// Step 3 end
// Step 5 start
//ds-snippet-end:eSign39Step3
//ds-snippet-start:eSign39Step5
RecipientViewRequest viewRequest = InPersonSigningService.makeRecipientViewRequest(hostEmail, hostName, config);
// Step 5 end
//ds-snippet-end:eSign39Step5

ViewUrl viewUrl = InPersonSigningService.inPersonSigning(
envelopesApi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ protected Object doWork(WorkArguments args, ModelMap model,
EnvelopeDefinition envelope = SetDocumentVisibilityService.makeEnvelope(signerEmail, signerName, signer2Email,
signer2Name, ccEmail, ccName, DOCUMENT_FILE_NAME_PDF, DOCUMENT_FILE_NAME_DOCX, DOCUMENT_FILE_NAME_HTML);

// Step 2 start
//ds-snippet-start:eSign40Step2
ApiClient apiClient = createApiClient(basePath, accessToken);
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
// Step 2 end
//ds-snippet-end:eSign40Step2

// Step 4 start
//ds-snippet-start:eSign40Step4
EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envelope);
// Step 4 end
//ds-snippet-end:eSign40Step4

DoneExample.createDefault(title)
.withMessage("The envelope has been created and sent!<br />Envelope ID "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ protected Object doWork(WorkArguments args, ModelMap model,
String phoneNumber = args.getPhoneNumber();
String accountId = session.getAccountId();

// Step 2 start
//ds-snippet-start:eSign41Step2
ApiClient apiClient = createApiClient(session.getBasePath(), user.getAccessToken());
// Step 2 end

// Step 3 start
AccountsApi workflowDetails = new AccountsApi(apiClient);
AccountIdentityVerificationResponse workflowRes = workflowDetails.getAccountIdentityVerification(session.getAccountId());
List<AccountIdentityVerificationWorkflow> identityVerification = workflowRes.getIdentityVerification();
Expand All @@ -75,15 +73,16 @@ protected Object doWork(WorkArguments args, ModelMap model,
workflowId = identityVerification.get(i).getWorkflowId();
}
}
// Step 3 end
//ds-snippet-end:eSign41Step2

logger.info("workflowId = " + workflowId);
if (workflowId.equals(""))
{
throw new ApiException(0, getTextForCodeExample().CustomErrorTexts.get(0).ErrorMessage);
}


// Step 1. Create the envelope definition
// Create the envelope definition
//ds-snippet-start:eSign41Step4
EnvelopeDefinition envelope = CfrEmbeddedSigningService.makeEnvelope(
signerName,
signerEmail,
Expand All @@ -96,26 +95,33 @@ protected Object doWork(WorkArguments args, ModelMap model,
DOCUMENT_FILE_NAME,
DOCUMENT_NAME);

// Step 2. Call DocuSign to create the envelope
// Call DocuSign to create the envelope
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envelope);

String envelopeId = envelopeSummary.getEnvelopeId();
//ds-snippet-end:eSign41Step4

session.setEnvelopeId(envelopeId);

// Step 3. create the recipient view, the embedded signing
// create the recipient view, the embedded signing
//ds-snippet-start:eSign41Step5
RecipientViewRequest viewRequest = CfrEmbeddedSigningService.makeRecipientViewRequest(
signerEmail,
signerName,
config,
signerClientId);

//ds-snippet-end:eSign41Step5

//ds-snippet-start:eSign41Step6
ViewUrl viewUrl = CfrEmbeddedSigningService.embeddedSigning(
envelopesApi,
accountId,
envelopeId,
viewRequest
);
//ds-snippet-end:eSign41Step6

// Step 4. Redirect the user to the embedded signing
// Don't use an iFrame!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ public static EnvelopeSummary accessCodeAuthentication(
String accountId,
EnvelopeDefinition envelope
) throws ApiException {
//ds-snippet-start:eSign19Step4
return envelopesApi.createEnvelope(accountId, envelope);
//ds-snippet-end:eSign19Step4
}

//ds-snippet-start:eSign19Step3
public static EnvelopeDefinition createEnvelope(
String signerName,
String signerEmail,
Expand All @@ -43,4 +46,5 @@ public static EnvelopeDefinition createEnvelope(

return envelope;
}
//ds-snippet-end:eSign19Step3
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public static ViewUrl addDocumentToTemplate(
args
);

// Step 3 start
//ds-snippet-start:eSign13Step3
EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envelope);
// Step 3 end
//ds-snippet-end:eSign13Step3

// Step 4 start
//ds-snippet-start:eSign13Step4
RecipientViewRequest viewRequest = AddDocToTemplateService.makeRecipientViewRequest(
dsReturnUrl,
signerEmail,
Expand All @@ -71,10 +71,12 @@ public static RecipientViewRequest makeRecipientViewRequest(
signerName,
dsPingUrl);
}
//ds-snippet-end:eSign13Step4

// The envelope request object uses Composite Template to include in the envelope:
// 1. A template stored on the DocuSign service
// 2. An additional document which is a custom HTML source document
//ds-snippet-start:eSign13Step2
public static EnvelopeDefinition makeEnvelope(
String signerEmail,
String signerName,
Expand Down Expand Up @@ -143,6 +145,7 @@ public static EnvelopeDefinition makeEnvelope(

return envelopeDefinition;
}
//ds-snippet-end:eSign13Step2

// Adding clientUserId transforms the template recipient into an embedded recipient
public static Signer createSigner(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public static EnvelopeSummary applyBrandToTemplate(
String accountId,
EnvelopeDefinition envelope
) throws ApiException {
//ds-snippet-start:eSign30Step4
return envelopesApi.createEnvelope(accountId, envelope);
//ds-snippet-end:eSign30Step4
}

public static EnvelopeDefinition makeEnvelope(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Collections;

public final class CfrEmbeddedSigningService {
//ds-snippet-start:eSign41Step6
public static ViewUrl embeddedSigning(
EnvelopesApi envelopesApi,
String accountId,
Expand All @@ -19,7 +20,9 @@ public static ViewUrl embeddedSigning(
) throws ApiException {
return envelopesApi.createRecipientView(accountId, envelopeId, viewRequest);
}
//ds-snippet-end:eSign41Step6

//ds-snippet-start:eSign41Step5
public static RecipientViewRequest makeRecipientViewRequest(
String signerEmail,
String signerName,
Expand Down Expand Up @@ -61,7 +64,9 @@ public static RecipientViewRequest makeRecipientViewRequest(

return viewRequest;
}
//ds-snippet-end:eSign41Step5

//ds-snippet-start:eSign41Step3
public static EnvelopeDefinition makeEnvelope(
String signerName,
String signerEmail,
Expand Down Expand Up @@ -115,4 +120,5 @@ public static EnvelopeDefinition makeEnvelope(

return envelopeDefinition;
}
//ds-snippet-end:eSign41Step3
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static ViewUrl inPersonSigning(
return envelopesApi.createRecipientView(accountId, envelopeId, viewRequest);
}

// Step 4 start
//ds-snippet-start:eSign39Step4
public static RecipientViewRequest makeRecipientViewRequest(
String hostEmail,
String hostName,
Expand All @@ -40,9 +40,9 @@ public static RecipientViewRequest makeRecipientViewRequest(

return viewRequest;
}
// Step 4 end
//ds-snippet-end:eSign39Step4

// Step 2 start
//ds-snippet-start:eSign39Step2
public static EnvelopeDefinition makeEnvelope(
String hostEmail,
String hostName,
Expand Down Expand Up @@ -74,5 +74,5 @@ public static EnvelopeDefinition makeEnvelope(

return envelopeDefinition;
}
// Step 2 end
//ds-snippet-end:eSign39Step2
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static EnvelopeSummary pauseSignatureWorkflow(
return envelopesApi.createEnvelope(accountId, envelope);
}

//ds-snippet-start:eSign32Step3
public static EnvelopeDefinition createEnvelope(
String signerName,
String signerEmail,
Expand Down Expand Up @@ -80,4 +81,5 @@ public static EnvelopeDefinition createEnvelope(

return envelope;
}
//ds-snippet-end:eSign32Step3
}
Loading

0 comments on commit 28f1f69

Please sign in to comment.