createDocFromTemplateAsync
Overview
Parameters:
Return:
DocAsyncResponse - success
Exception - failure
To create this document we need:
set your api token.
set your variables.
set your doc.
call the method.
Usage:
Import the relevant components:
import body.doc.DeParaTemplate;
import body.doc.DocFromTemplate;
import docs.DocRequests;
import response.DocAsyncResponse;
import services.JsonConverter;
import java.util.ArrayList;
Set your Api Token:
String apiToken = "YOUR TOKEN";
add your variables in a DeParaTemplate class list:
DeParaTemplate deParaTemplateName = DeParaTemplate.deParaTemplateBuilder()
.de("{{FULL NAME}}")
.para("Full Name")
.build();
DeParaTemplate deParaTemplateNumber= DeParaTemplate.deParaTemplateBuilder()
.de("{{SOCIAL SECURITY NUMBER}}")
.para("Social Security Number")
.build();
DeParaTemplate deParaTemplateAddress = DeParaTemplate.deParaTemplateBuilder()
.de("{{FULL ADDRESS}}")
.para("Full address")
.build();
ArrayList<DeParaTemplate> deParaTemplates = new ArrayList<>();
deParaTemplates.add(deParaTemplateName);
deParaTemplates.add(deParaTemplateCpf);
deParaTemplates.add(deParaTemplateEnd);
Set your doc with class with the class DocFromTemplate:
DocFromTemplate docFromTemplate = DocFromTemplate.docFromTemplateBuilder()
.sandbox(false)
.brand_primary_color("#000000")
.lang("en")
.signer_name("My Signer for template")
.template_id("75a3a92b-...")
.data(deParaTemplates)
.build();
Call the method createDocFromTemplateAsync and receive the DocAsyncResponse class or an error message as a response:
try {
DocAsyncResponse docAsyncResponse = new DocRequests(apiToken).createDocFromTemplateAsync(docFromTemplate);
String jsonDocResponse = new JsonConverter().docAsyncResponseToJson(docAsyncResponse);
System.out.println(jsonDocResponse);
}
catch(Exception exceptionError) {
System.out.println(exceptionError.getMessage());
}
Example:
import body.doc.DeParaTemplate;
import body.doc.DocFromTemplate;
import docs.DocRequests;
import response.DocResponse;
import services.JsonConverter;
import java.util.ArrayList;
public class CreateDocFromTemplate {
public static void main(String[] args) throws Exception {
String apiToken = "YOUR TOKEN";
DeParaTemplate deParaTemplateName = DeParaTemplate.deParaTemplateBuilder()
.de("{{FULL NAME}}")
.para("Full Name")
.build();
DeParaTemplate deParaTemplateNumber= DeParaTemplate.deParaTemplateBuilder()
.de("{{SOCIAL SECURITY NUMBER}}")
.para("Social Security Number")
.build();
DeParaTemplate deParaTemplateAddress = DeParaTemplate.deParaTemplateBuilder()
.de("{{FULL ADDRESS}}")
.para("Full address")
.build();
ArrayList<DeParaTemplate> deParaTemplates = new ArrayList<>();
deParaTemplates.add(deParaTemplateName);
deParaTemplates.add(deParaTemplateCpf);
deParaTemplates.add(deParaTemplateEnd);
DocFromTemplate docFromTemplate = DocFromTemplate.docFromTemplateBuilder()
.sandbox(false)
.brand_primary_color("#000000")
.lang("en")
.signer_name("My Signer for template")
.template_id("75a3a92b-36d5-451f-95cd-5af9a927a392")
.data(deParaTemplates)
.build();
try {
DocAsyncResponse docAsyncResponse = new DocRequests(apiToken).createDocFromTemplateAsync(docFromTemplate);
String jsonDocResponse = new JsonConverter().docAsyncResponseToJson(docAsyncResponse);
System.out.println(jsonDocResponse);
}
catch(Exception exceptionError) {
System.out.println(exceptionError.getMessage());
}
}
}
Last updated