Skip to content
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

[SELC - 6127] feat: updated onboardingCompletion APIs logic to accept file in input #627

Merged
merged 6 commits into from
Dec 5, 2024
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
42 changes: 36 additions & 6 deletions apps/onboarding-ms/src/main/docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,19 @@
"operationId" : "onboardingCompletion",
"requestBody" : {
"content" : {
"application/json" : {
"multipart/form-data" : {
"schema" : {
"$ref" : "#/components/schemas/OnboardingDefaultRequest"
"required" : [ "contract", "onboardingRequest" ],
"type" : "object",
"properties" : {
"contract" : {
"format" : "binary",
"type" : "string"
},
"onboardingRequest" : {
"type" : "string"
}
}
}
}
}
Expand Down Expand Up @@ -680,9 +690,19 @@
"operationId" : "onboardingPaCompletion",
"requestBody" : {
"content" : {
"application/json" : {
"multipart/form-data" : {
"schema" : {
"$ref" : "#/components/schemas/OnboardingPaRequest"
"required" : [ "contract", "onboardingRequest" ],
"type" : "object",
"properties" : {
"contract" : {
"format" : "binary",
"type" : "string"
},
"onboardingRequest" : {
"type" : "string"
}
}
}
}
}
Expand Down Expand Up @@ -832,9 +852,19 @@
"operationId" : "onboardingPspCompletion",
"requestBody" : {
"content" : {
"application/json" : {
"multipart/form-data" : {
"schema" : {
"$ref" : "#/components/schemas/OnboardingPspRequest"
"required" : [ "contract", "onboardingRequest" ],
"type" : "object",
"properties" : {
"contract" : {
"format" : "binary",
"type" : "string"
},
"onboardingRequest" : {
"type" : "string"
}
}
}
}
}
Expand Down
39 changes: 33 additions & 6 deletions apps/onboarding-ms/src/main/docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,18 @@ paths:
operationId: onboardingCompletion
requestBody:
content:
application/json:
multipart/form-data:
schema:
$ref: "#/components/schemas/OnboardingDefaultRequest"
required:
- contract
- onboardingRequest
type: object
properties:
contract:
format: binary
type: string
onboardingRequest:
type: string
responses:
"200":
description: OK
Expand Down Expand Up @@ -498,9 +507,18 @@ paths:
operationId: onboardingPaCompletion
requestBody:
content:
application/json:
multipart/form-data:
schema:
$ref: "#/components/schemas/OnboardingPaRequest"
required:
- contract
- onboardingRequest
type: object
properties:
contract:
format: binary
type: string
onboardingRequest:
type: string
responses:
"200":
description: OK
Expand Down Expand Up @@ -606,9 +624,18 @@ paths:
operationId: onboardingPspCompletion
requestBody:
content:
application/json:
multipart/form-data:
schema:
$ref: "#/components/schemas/OnboardingPspRequest"
required:
- contract
- onboardingRequest
type: object
properties:
contract:
format: binary
type: string
onboardingRequest:
type: string
responses:
"200":
description: OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.List;
import java.util.Objects;

import static it.pagopa.selfcare.onboarding.util.Utils.parseOnboardingRequest;
import static it.pagopa.selfcare.onboarding.util.Utils.retrieveContractFromFormData;

@Authenticated
Expand Down Expand Up @@ -169,26 +170,58 @@ public Uni<OnboardingResponse> onboardingPsp(@Valid OnboardingPspRequest onboard
)
@Path("/completion")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public Uni<OnboardingResponse> onboardingCompletion(@Valid OnboardingDefaultRequest onboardingRequest, @Context SecurityContext ctx) {
return readUserIdFromToken(ctx)
.onItem().transformToUni(userId -> onboardingService
.onboardingCompletion(fillUserId(onboardingMapper.toEntity(onboardingRequest), userId), onboardingRequest.getUsers()));
public Uni<OnboardingResponse> onboardingCompletion(
@NotNull @RestForm("contract") File file,
@NotNull @RestForm("onboardingRequest") String onboardingRequestJson,
@Context ResteasyReactiveRequestContext ctx,
@Context SecurityContext securityContext) {

return readUserIdFromToken(securityContext)
.onItem()
.transformToUni(
userId -> {
// Parse JSON into OnboardingDefaultRequest
OnboardingDefaultRequest onboardingRequest =
parseOnboardingRequest(onboardingRequestJson, OnboardingDefaultRequest.class);

// Call the onboarding service
return onboardingService.onboardingCompletion(
fillUserId(onboardingMapper.toEntity(onboardingRequest), userId),
onboardingRequest.getUsers(),
retrieveContractFromFormData(ctx.getFormData(), file));
});
}

@Operation(
summary = "Complete PA onboarding request and set status to COMPLETED.",
description = "Perform onboarding as /onboarding/pa but completing the onboarding request to COMPLETED phase."
)
description =
"Perform onboarding as /onboarding/pa but completing the onboarding request to COMPLETED phase.")
@POST
@Path("/pa/completion")
@Consumes(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public Uni<OnboardingResponse> onboardingPaCompletion(@Valid OnboardingPaRequest onboardingRequest, @Context SecurityContext ctx) {
return readUserIdFromToken(ctx)
.onItem().transformToUni(userId -> onboardingService
.onboardingCompletion(fillUserId(onboardingMapper.toEntity(onboardingRequest), userId), onboardingRequest.getUsers()));
public Uni<OnboardingResponse> onboardingPaCompletion(
@NotNull @RestForm("contract") File file,
@NotNull @RestForm("onboardingRequest") String onboardingRequestJson,
@Context ResteasyReactiveRequestContext ctx,
@Context SecurityContext securityContext) {

return readUserIdFromToken(securityContext)
.onItem()
.transformToUni(
userId -> {
// Parse JSON into OnboardingPaRequest
OnboardingPaRequest onboardingRequest =
parseOnboardingRequest(onboardingRequestJson, OnboardingPaRequest.class);

// Call the onboarding service
return onboardingService.onboardingCompletion(
fillUserId(onboardingMapper.toEntity(onboardingRequest), userId),
onboardingRequest.getUsers(),
retrieveContractFromFormData(ctx.getFormData(), file));
});
}

@Operation(
Expand Down Expand Up @@ -221,16 +254,32 @@ public Uni<OnboardingResponse> onboardingPspImport(@Valid OnboardingImportPspReq

@Operation(
summary = "Complete PSP onboarding request and set status to COMPLETED.",
description = "Perform onboarding as /onboarding/psp but completing the onboarding request to COMPLETED phase."
)
description =
"Perform onboarding as /onboarding/psp but completing the onboarding request to COMPLETED phase.")
@POST
@Path("/psp/completion")
@Consumes(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public Uni<OnboardingResponse> onboardingPspCompletion(@Valid OnboardingPspRequest onboardingRequest, @Context SecurityContext ctx) {
return readUserIdFromToken(ctx)
.onItem().transformToUni(userId -> onboardingService
.onboardingCompletion(fillUserId(onboardingMapper.toEntity(onboardingRequest), userId), onboardingRequest.getUsers()));
public Uni<OnboardingResponse> onboardingPspCompletion(
@NotNull @RestForm("contract") File file,
@NotNull @RestForm("onboardingRequest") String onboardingRequestJson,
@Context ResteasyReactiveRequestContext ctx,
@Context SecurityContext securityContext) {

return readUserIdFromToken(securityContext)
.onItem()
.transformToUni(
userId -> {
// Parse JSON into OnboardingPspRequest
OnboardingPspRequest onboardingRequest =
parseOnboardingRequest(onboardingRequestJson, OnboardingPspRequest.class);

// Call the onboarding service
return onboardingService.onboardingCompletion(
fillUserId(onboardingMapper.toEntity(onboardingRequest), userId),
onboardingRequest.getUsers(),
retrieveContractFromFormData(ctx.getFormData(), file));
});
}

@Operation(
Expand All @@ -246,7 +295,7 @@ public Uni<OnboardingResponse> onboardingPspCompletion(@Valid OnboardingPspReque
public Uni<OnboardingResponse> onboardingPgCompletion(@Valid OnboardingPgRequest onboardingRequest, @Context SecurityContext ctx) {
return readUserIdFromToken(ctx)
.onItem().transformToUni(userId -> onboardingService
.onboardingCompletion(fillUserId(onboardingMapper.toEntity(onboardingRequest), userId), onboardingRequest.getUsers()));
.onboardingCompletion(fillUserId(onboardingMapper.toEntity(onboardingRequest), userId), onboardingRequest.getUsers(), null));
}

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,27 @@

public interface OnboardingService {

Uni<OnboardingResponse> onboarding(Onboarding onboarding, List<UserRequest> userRequests, List<AggregateInstitutionRequest> aggregates);
Uni<OnboardingResponse> onboarding(
Onboarding onboarding,
List<UserRequest> userRequests,
List<AggregateInstitutionRequest> aggregates);

Uni<OnboardingResponse> onboardingUsers(OnboardingUserRequest onboardingUserRequest, String userId, WorkflowType workflowType);
Uni<OnboardingResponse> onboardingUsers(
OnboardingUserRequest onboardingUserRequest, String userId, WorkflowType workflowType);

Uni<OnboardingResponse> onboardingImport(Onboarding onboarding, List<UserRequest> userRequests, OnboardingImportContract contractImported, boolean forceImport);
Uni<OnboardingResponse> onboardingImport(
Onboarding onboarding,
List<UserRequest> userRequests,
OnboardingImportContract contractImported,
boolean forceImport);

Uni<OnboardingResponse> onboardingCompletion(Onboarding onboarding, List<UserRequest> userRequests);
Uni<OnboardingResponse> onboardingCompletion(
Onboarding onboarding, List<UserRequest> userRequests, FormItem formItem);

Uni<OnboardingResponse> onboardingAggregationCompletion(Onboarding onboarding, List<UserRequest> userRequests, List<AggregateInstitutionRequest> aggregates);
Uni<OnboardingResponse> onboardingAggregationCompletion(
Onboarding onboarding,
List<UserRequest> userRequests,
List<AggregateInstitutionRequest> aggregates);

Uni<OnboardingResponse> onboardingUserPg(Onboarding onboarding, List<UserRequest> userRequests);

Expand All @@ -46,9 +58,16 @@ public interface OnboardingService {

Uni<OnboardingGet> onboardingPending(String onboardingId);

Uni<List<OnboardingResponse>> institutionOnboardings(String taxCode, String subunitCode, String origin, String originId, OnboardingStatus status);
Uni<List<OnboardingResponse>> institutionOnboardings(
String taxCode, String subunitCode, String origin, String originId, OnboardingStatus status);

Uni<List<OnboardingResponse>> verifyOnboarding(String taxCode, String subunitCode, String origin, String originId, OnboardingStatus status, String productId);
Uni<List<OnboardingResponse>> verifyOnboarding(
String taxCode,
String subunitCode,
String origin,
String originId,
OnboardingStatus status,
String productId);

Uni<OnboardingGet> onboardingGet(String onboardingId);

Expand All @@ -60,6 +79,8 @@ public interface OnboardingService {

Uni<CustomError> checkRecipientCode(String recipientCode, String originId);

Uni<OnboardingResponse> onboardingIncrement(Onboarding onboarding, List<UserRequest> userRequests, List<AggregateInstitutionRequest> aggregates);

Uni<OnboardingResponse> onboardingIncrement(
Onboarding onboarding,
List<UserRequest> userRequests,
List<AggregateInstitutionRequest> aggregates);
}
Loading
Loading