Skip to content

Commit

Permalink
VKT(Backend): Enrollment appointment contact form continues
Browse files Browse the repository at this point in the history
  • Loading branch information
jrkkp committed Oct 22, 2024
1 parent f998f35 commit 986c56d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public PublicEnrollmentAppointmentDTO saveEnrollmentAppointment(
final Person person = publicAuthService.getPersonFromSession(session);

if (enrollmentAppointmentId != dto.id()) {
throw new APIException(APIExceptionType.RESERVATION_PERSON_SESSION_MISMATCH);
throw new APIException(APIExceptionType.APPOINTMENT_ID_MISMATCH);
}

return publicEnrollmentService.saveEnrollmentAppointment(dto, person);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package fi.oph.vkt.api.dto;

import fi.oph.vkt.util.StringUtil;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Builder;
import lombok.NonNull;

Expand All @@ -11,8 +13,16 @@ public record PublicEnrollmentAppointmentUpdateDTO(
String previousEnrollment,
@NonNull @NotNull Boolean digitalCertificateConsent,
@NonNull @NotBlank String phoneNumber,
String street,
String postalCode,
String town,
String country
) {}
@Size(max = 1024) String street,
@Size(max = 1024) String postalCode,
@Size(max = 1024) String town,
@Size(max = 1024) String country
) {
public PublicEnrollmentAppointmentUpdateDTO {
previousEnrollment = StringUtil.sanitize(previousEnrollment);
street = StringUtil.sanitize(street);
postalCode = StringUtil.sanitize(postalCode);
town = StringUtil.sanitize(town);
country = StringUtil.sanitize(country);
}
}
14 changes: 12 additions & 2 deletions backend/vkt/src/main/java/fi/oph/vkt/service/PaymentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,18 @@ private String getFinalizePaymentRedirectUrl(final Long paymentId, final String
.orElseThrow(() -> new NotFoundException("Payment not found"));

return payment.getEnrollment() != null
? String.format("%s/ilmoittaudu/%d/maksu/%s", baseUrl, payment.getEnrollment().getExamEvent().getId(), state)
: String.format("%s/markkinapaikka/%d/maksu/%s", baseUrl, payment.getEnrollmentAppointment().getId(), state);
? String.format(
"%s/erinomainen-taito/ilmoittaudu/%d/maksu/%s",
baseUrl,
payment.getEnrollment().getExamEvent().getId(),
state
)
: String.format(
"%s/hyva-ja-tyydyttava-taito/ilmoittaudu/%d/maksu/%s",
baseUrl,
payment.getEnrollmentAppointment().getId(),
state
);
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ public PublicEnrollmentAppointmentDTO saveEnrollmentAppointment(
enrollmentAppointment.setPostalCode(dto.postalCode());
enrollmentAppointment.setTown(dto.town());
enrollmentAppointment.setCountry(dto.country());
enrollmentAppointment.setPhoneNumber(dto.phoneNumber());

if (dto.digitalCertificateConsent()) {
clearAddress(enrollmentAppointment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public enum APIExceptionType {
ATTACHMENT_PERSON_MISMATCH,
TICKET_VALIDATION_ERROR,
SESSION_APPOINTMENT_PERSON_MISMATCH,
SESSION_APPOINTMENT_ID_MISMATCH;
SESSION_APPOINTMENT_ID_MISMATCH,
APPOINTMENT_ID_MISMATCH;

public String getCode() {
final StringBuilder codeBuilder = new StringBuilder();
Expand Down

0 comments on commit 986c56d

Please sign in to comment.