-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(VIST-CPC-811): send email on visit request #589
Conversation
Qodana for JVM374 new problems were found
☁️ View the detailed Qodana report Contact Qodana teamContact us at [email protected]
|
...gateway/src/main/java/com/petclinic/bffapigateway/domainclientlayer/VisitsServiceClient.java
Show resolved
Hide resolved
public Mono<? extends Throwable> rethrow(ClientResponse clientResponse, Function<Map, ? extends Throwable> exceptionProvider) { | ||
return clientResponse.createException().flatMap(n -> | ||
{ | ||
try { | ||
final Map map = | ||
objectMapper.readValue(n.getResponseBodyAsString(), Map.class); | ||
return Mono.error(exceptionProvider.apply(map)); | ||
} catch (JsonProcessingException e) { | ||
// e.printStackTrace(); | ||
return Mono.error(e); | ||
} | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify what this method is doing and why you need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It rethrows error to what called it. I need it because of how the authServiceClient was implemented(copied from the api-gateway).
@@ -80,11 +88,20 @@ public Mono<VisitResponseDTO> addVisit(Mono<VisitRequestDTO> visitRequestDTOMono | |||
.then(validatePetId(visitRequestDTO.getPetId())) | |||
.then(validateVetId(visitRequestDTO.getPractitionerId())) | |||
.then(Mono.just(visitRequestDTO)) | |||
.doOnNext(s->{ | |||
|
|||
authServiceClient.getUserById(visitRequestDTO.getJwtToken(), visitRequestDTO.getOwnerId()).subscribe(user->mailService.sendMail(generateVisitRequestEmail(user, visitRequestDTO.getPetId(), visitRequestDTO.getVisitDate()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain what .subscribe () is doing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It allows to run code once we get the return from the asynchronous getUserById method from the AuthServiceClient. In this case, it is a non blocking way to wait to get the user, then go ahead with sending the email.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This passes the Vibe Check
(Please don't Kill me Dylan)
JIRA: link to jira ticket
Context:
Sending an email to the pet owner when a visit is requested/scheduled.
Changes
Added AuthServiceClient and mailerClient integration to be able to send emails.
Before and After UI (Required for UI-impacting PRs)
Image of an email sent when a visit is added.
Dev notes (Optional)