Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/rest_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ These three endpoints each deal with the same large request payload: the entire
"comments_to_clerk": "I worked with clerk John Brown to complete this at the law library.",
"tyler_payment_id": "12345678-1234-1234-1234-12345678abcd", // retrieved from .../payments/payment-accounts
"lead_contact": {
// same as users / other_parties
// same as users / other_parties. Not required if users[0].is_form_filler is true
"email": "cool_dude1@example.com", // email is required
},
"return_date": "YYYY-MM-DD+01:00",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,34 +336,48 @@ public FilingInformation fromNode(JsonNode node, InfoCollector collector) throws

entities.setPaymentId(extractNullableString(node.get("tyler_payment_id")));

JsonNode leadJson = node.get("lead_contact");
if (leadJson == null) {
InterviewVariable var =
collector.requestVar(
"lead_contact", "Someone to contact about this case", "ALIndividual");
collector.addRequired(var);
if (users.size() >= 1
&& users.get(0).isFormFiller()
&& users.get(0).getContactInfo().getEmail().isPresent()) {
log.info(
"Using users[0] as lead_contact because `is_form_filler` is true (this is what the EFM will do as well)");
entities.setLeadContact(users.get(0));
} else {
collector.pushAttributeStack("lead_contact");
Result<Person, FilingError> per =
PersonDocassembleJacksonDeserializer.fromNode(
node.get("lead_contact"), parser, collector);
collector.popAttributeStack();
if (per.isErr()) {
FilingError ex = per.unwrapErrOrElseThrow();
log.warn("Person exception: ", ex);
collector.error(ex);
entities.setLeadContact(null);
if (users.size() >= 1
&& users.get(0).isFormFiller()
&& users.get(0).getContactInfo().getEmail().isEmpty()) {
log.warn(
"I want to use users[0] as lead_contact, but they don't have an email! Using lead_contact instead");
}
JsonNode leadJson = node.get("lead_contact");
if (leadJson == null) {
InterviewVariable var =
collector.requestVar(
"lead_contact", "Someone to contact about this case", "ALIndividual");
collector.addRequired(var);
} else {
Person person = per.unwrapOrElseThrow();
if (person.getContactInfo().getEmail().isEmpty()) {
InterviewVariable var =
collector.requestVar(
"lead_contact.email",
"We need an email to contact someone about this case.",
"text");
collector.addRequired(var);
collector.pushAttributeStack("lead_contact");
Result<Person, FilingError> per =
PersonDocassembleJacksonDeserializer.fromNode(
node.get("lead_contact"), parser, collector);
collector.popAttributeStack();
if (per.isErr()) {
FilingError ex = per.unwrapErrOrElseThrow();
log.warn("Person exception: ", ex);
collector.error(ex);
entities.setLeadContact(null);
} else {
Person person = per.unwrapOrElseThrow();
if (person.getContactInfo().getEmail().isEmpty()) {
InterviewVariable var =
collector.requestVar(
"lead_contact.email",
"We need an email to contact someone about this case.",
"text");
collector.addRequired(var);
}
entities.setLeadContact(person);
}
entities.setLeadContact(person);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,9 @@ public Result<Optional<String>, TextVarError> vetEmail(Optional<String> email) {
if (!emailRow.matchRegex(email.get())) {
return Result.err(new WrongVar(email.get(), emailRow.regularexpression));
}
if (email.get().isBlank()) {
return Result.ok(Optional.empty());
}
} else if (emailRow.isrequired) {
return Result.err(new MissingVar(emailRow.regularexpression));
}
Expand Down
Loading