Skip to content

Commit

Permalink
Added new endpoint into OnboardingController
Browse files Browse the repository at this point in the history
  • Loading branch information
giampieroferrara committed Jan 15, 2025
1 parent d4ee43b commit 95c2b26
Show file tree
Hide file tree
Showing 6 changed files with 284 additions and 67 deletions.
85 changes: 85 additions & 0 deletions apps/onboarding-ms/src/main/docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,44 @@
} ]
}
},
"/v1/onboarding/aggregation/import" : {
"post" : {
"tags" : [ "Onboarding Controller" ],
"summary" : "Asynchronously import aggregated onboarding to COMPLETED status and create token",
"description" : "Perform a manual onboarding with aggregator, create token and set onboarding status to COMPLETED phase.",
"operationId" : "onboardingAggregationImport",
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/OnboardingAggregationImportRequest"
}
}
}
},
"responses" : {
"200" : {
"description" : "OK",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/OnboardingResponse"
}
}
}
},
"401" : {
"description" : "Not Authorized"
},
"403" : {
"description" : "Not Allowed"
}
},
"security" : [ {
"SecurityScheme" : [ ]
} ]
}
},
"/v1/onboarding/aggregation/increment" : {
"post" : {
"tags" : [ "Onboarding Controller" ],
Expand Down Expand Up @@ -2356,6 +2394,53 @@
"type" : "string",
"example" : "2022-03-10T12:15:50"
},
"OnboardingAggregationImportRequest" : {
"required" : [ "productId", "users", "institution" ],
"type" : "object",
"properties" : {
"productId" : {
"minLength" : 1,
"type" : "string"
},
"users" : {
"minItems" : 1,
"type" : "array",
"items" : {
"$ref" : "#/components/schemas/UserRequest"
}
},
"aggregates" : {
"type" : "array",
"items" : {
"$ref" : "#/components/schemas/AggregateInstitutionRequest"
}
},
"isAggregator" : {
"type" : "boolean"
},
"pricingPlan" : {
"type" : "string"
},
"signContract" : {
"type" : "boolean"
},
"institution" : {
"$ref" : "#/components/schemas/InstitutionBaseRequest"
},
"billing" : {
"$ref" : "#/components/schemas/BillingRequest"
},
"additionalInformations" : {
"$ref" : "#/components/schemas/AdditionalInformationsDto"
},
"gpuData" : {
"$ref" : "#/components/schemas/GPUData"
},
"onboardingImportContract" : {
"$ref" : "#/components/schemas/OnboardingImportContract"
}
}
},
"OnboardingDefaultRequest" : {
"required" : [ "productId", "users", "institution" ],
"type" : "object",
Expand Down
62 changes: 62 additions & 0 deletions apps/onboarding-ms/src/main/docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,33 @@ paths:
description: Not Allowed
security:
- SecurityScheme: []
/v1/onboarding/aggregation/import:
post:
tags:
- Onboarding Controller
summary: Asynchronously import aggregated onboarding to COMPLETED status and
create token
description: "Perform a manual onboarding with aggregator, create token and\
\ set onboarding status to COMPLETED phase."
operationId: onboardingAggregationImport
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/OnboardingAggregationImportRequest"
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: "#/components/schemas/OnboardingResponse"
"401":
description: Not Authorized
"403":
description: Not Allowed
security:
- SecurityScheme: []
/v1/onboarding/aggregation/increment:
post:
tags:
Expand Down Expand Up @@ -1712,6 +1739,41 @@ components:
format: date-time
type: string
example: 2022-03-10T12:15:50
OnboardingAggregationImportRequest:
required:
- productId
- users
- institution
type: object
properties:
productId:
minLength: 1
type: string
users:
minItems: 1
type: array
items:
$ref: "#/components/schemas/UserRequest"
aggregates:
type: array
items:
$ref: "#/components/schemas/AggregateInstitutionRequest"
isAggregator:
type: boolean
pricingPlan:
type: string
signContract:
type: boolean
institution:
$ref: "#/components/schemas/InstitutionBaseRequest"
billing:
$ref: "#/components/schemas/BillingRequest"
additionalInformations:
$ref: "#/components/schemas/AdditionalInformationsDto"
gpuData:
$ref: "#/components/schemas/GPUData"
onboardingImportContract:
$ref: "#/components/schemas/OnboardingImportContract"
OnboardingDefaultRequest:
required:
- productId
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
package it.pagopa.selfcare.onboarding.controller;

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

import io.quarkus.security.Authenticated;
import io.quarkus.security.identity.CurrentIdentityAssociation;
import io.smallrye.jwt.auth.principal.DefaultJWTCallerPrincipal;
import io.smallrye.mutiny.Uni;
import it.pagopa.selfcare.onboarding.common.OnboardingStatus;
import it.pagopa.selfcare.onboarding.common.WorkflowType;
import it.pagopa.selfcare.onboarding.constants.CustomError;
import it.pagopa.selfcare.onboarding.controller.request.*;
import it.pagopa.selfcare.onboarding.controller.request.OnboardingDefaultRequest;
import it.pagopa.selfcare.onboarding.controller.request.OnboardingImportPspRequest;
import it.pagopa.selfcare.onboarding.controller.request.OnboardingImportRequest;
import it.pagopa.selfcare.onboarding.controller.request.OnboardingPaRequest;
import it.pagopa.selfcare.onboarding.controller.request.OnboardingPgRequest;
import it.pagopa.selfcare.onboarding.controller.request.OnboardingPspRequest;
import it.pagopa.selfcare.onboarding.controller.request.OnboardingUserPgRequest;
import it.pagopa.selfcare.onboarding.controller.request.OnboardingUserRequest;
import it.pagopa.selfcare.onboarding.controller.request.ReasonRequest;
import it.pagopa.selfcare.onboarding.controller.response.OnboardingGet;
import it.pagopa.selfcare.onboarding.controller.response.OnboardingGetResponse;
import it.pagopa.selfcare.onboarding.controller.response.OnboardingResponse;
import it.pagopa.selfcare.onboarding.entity.Billing;
import it.pagopa.selfcare.onboarding.entity.CheckManagerResponse;
import it.pagopa.selfcare.onboarding.entity.Onboarding;
import it.pagopa.selfcare.onboarding.entity.OnboardingAggregationImportRequest;
import it.pagopa.selfcare.onboarding.exception.ResourceNotFoundException;
import it.pagopa.selfcare.onboarding.mapper.OnboardingMapper;
import it.pagopa.selfcare.onboarding.model.OnboardingGetFilters;
Expand All @@ -22,11 +33,24 @@
import jakarta.inject.Inject;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.*;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DefaultValue;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.HEAD;
import jakarta.ws.rs.InternalServerErrorException;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.SecurityContext;
import java.io.File;
import java.util.List;
import java.util.Objects;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpStatus;
Expand All @@ -36,12 +60,6 @@
import org.jboss.resteasy.reactive.RestForm;
import org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext;

import java.io.File;
import java.util.List;
import java.util.Objects;

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

@Authenticated
@Path("/v1/onboarding")
@Tag(name = "Onboarding Controller")
Expand Down Expand Up @@ -567,4 +585,20 @@ public Uni<RecipientCodeStatus> checkRecipientCode(@QueryParam("recipientCode")
return RecipientCodeStatus.ACCEPTED;
});
}

@Operation(
summary = "Asynchronously import aggregated onboarding to COMPLETED status and create token",
description = "Perform a manual onboarding with aggregator, create token and set onboarding status to COMPLETED phase."
)
@Path("/aggregation/import")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Uni<OnboardingResponse> onboardingAggregationImport(@Valid OnboardingAggregationImportRequest onboardingRequest,
@Context SecurityContext ctx) {
return readUserIdFromToken(ctx)
.onItem().transformToUni(userId -> onboardingService
.onboardingAggregationImport(fillUserId(onboardingMapper.toEntity(onboardingRequest), userId),
onboardingRequest.getOnboardingImportContract(), onboardingRequest.getUsers(), onboardingRequest.getAggregates()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package it.pagopa.selfcare.onboarding.entity;

import it.pagopa.selfcare.onboarding.controller.request.OnboardingDefaultRequest;
import it.pagopa.selfcare.onboarding.controller.request.OnboardingImportContract;
import jakarta.validation.Valid;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class OnboardingAggregationImportRequest extends OnboardingDefaultRequest {

@Valid
private OnboardingImportContract onboardingImportContract;
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import it.pagopa.selfcare.onboarding.entity.Onboarding;
import it.pagopa.selfcare.onboarding.model.FormItem;
import it.pagopa.selfcare.onboarding.model.OnboardingGetFilters;

import java.util.List;

public interface OnboardingService {
Expand Down Expand Up @@ -45,6 +44,12 @@ Uni<OnboardingResponse> onboardingAggregationCompletion(
List<UserRequest> userRequests,
List<AggregateInstitutionRequest> aggregates);

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

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

Uni<OnboardingGet> approve(String onboardingId);
Expand Down
Loading

0 comments on commit 95c2b26

Please sign in to comment.