Skip to content

Commit

Permalink
new params
Browse files Browse the repository at this point in the history
  • Loading branch information
jacopocarlini committed Jun 5, 2024
1 parent b3198dc commit eb03950
Show file tree
Hide file tree
Showing 13 changed files with 268 additions and 256 deletions.
115 changes: 70 additions & 45 deletions openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -742,27 +742,26 @@
}
} ]
},
"/creditorinstitutions/{creditorInstitutionCode}/applicationcodes" : {
"/creditorinstitutions/{ci-tax-code}/segregationcodes" : {
"get" : {
"tags" : [ "Creditor Institutions" ],
"summary" : "Get application code associations with creditor institution",
"operationId" : "getApplicationCodesFromCreditorInstitution",
"summary" : "Get segregation code associations with creditor institution",
"operationId" : "getSegregationCodesFromCreditorInstitution",
"parameters" : [ {
"name" : "creditorInstitutionCode",
"name" : "ci-tax-code",
"in" : "path",
"description" : "Organization fiscal code, the fiscal code of the Organization.",
"description" : "Creditor institution's tax code that own the station",
"required" : true,
"schema" : {
"type" : "string"
}
}, {
"name" : "showUsedCodes",
"name" : "targetCITaxCode",
"in" : "query",
"description" : "The flag that permits to show the codes already used. Default: true",
"required" : false,
"description" : "Tax code of the creditor institution that will be associated to the station",
"required" : true,
"schema" : {
"type" : "boolean",
"default" : true
"type" : "string"
}
} ],
"responses" : {
Expand All @@ -779,7 +778,7 @@
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/CIAssociatedCodeList"
"$ref" : "#/components/schemas/AvailableCodes"
}
}
}
Expand Down Expand Up @@ -869,11 +868,11 @@
}
} ]
},
"/creditorinstitutions/{creditorInstitutionCode}/segregationcodes" : {
"/creditorinstitutions/{creditorInstitutionCode}/applicationcodes" : {
"get" : {
"tags" : [ "Creditor Institutions" ],
"summary" : "Get segregation code associations with creditor institution",
"operationId" : "getSegregationCodesFromCreditorInstitution",
"summary" : "Get application code associations with creditor institution",
"operationId" : "getApplicationCodesFromCreditorInstitution",
"parameters" : [ {
"name" : "creditorInstitutionCode",
"in" : "path",
Expand All @@ -891,14 +890,6 @@
"type" : "boolean",
"default" : true
}
}, {
"name" : "service",
"in" : "query",
"description" : "The service endpoint, to be used as a search filter to obtain only the segregation codes used by the CI for stations using same endpoint service. Default: null",
"required" : false,
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"200" : {
Expand Down Expand Up @@ -1688,6 +1679,28 @@
},
"components" : {
"schemas" : {
"ProblemJson" : {
"type" : "object",
"properties" : {
"title" : {
"type" : "string",
"description" : "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable"
},
"status" : {
"maximum" : 600,
"minimum" : 100,
"type" : "integer",
"description" : "The HTTP status code generated by the origin server for this occurrence of the problem.",
"format" : "int32",
"example" : 200
},
"detail" : {
"type" : "string",
"description" : "A human readable explanation specific to this occurrence of the problem.",
"example" : "There was an error processing the request"
}
}
},
"IbanDetails" : {
"type" : "object",
"properties" : {
Expand Down Expand Up @@ -1785,28 +1798,6 @@
}
}
},
"ProblemJson" : {
"type" : "object",
"properties" : {
"title" : {
"type" : "string",
"description" : "A short, summary of the problem type. Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable"
},
"status" : {
"maximum" : 600,
"minimum" : 100,
"type" : "integer",
"description" : "The HTTP status code generated by the origin server for this occurrence of the problem.",
"format" : "int32",
"example" : 200
},
"detail" : {
"type" : "string",
"description" : "A human readable explanation specific to this occurrence of the problem.",
"example" : "There was an error processing the request"
}
}
},
"ChannelDetails" : {
"required" : [ "agid", "broker_psp_code", "card_chart", "channel_code", "digital_stamp_brand", "enabled", "on_us", "payment_model", "port", "primitive_version", "protocol", "recovery", "rt_push", "thread_number", "timeout_a", "timeout_b", "timeout_c" ],
"type" : "object",
Expand Down Expand Up @@ -2372,8 +2363,21 @@
}
}
},
"AvailableCodes" : {
"type" : "object",
"properties" : {
"availableCodes" : {
"type" : "array",
"description" : "List of codes not used for existing associations",
"items" : {
"type" : "string",
"description" : "List of codes not used for existing associations"
}
}
}
},
"CreditorInstitutionDetail" : {
"required" : [ "broker_code", "business_name", "creditor_institution_code", "psp_payment", "station_code", "station_enabled", "station_version" ],
"required" : [ "broker_code", "business_name", "ci_status", "creditor_institution_code", "psp_payment", "station_code", "station_enabled", "station_version" ],
"type" : "object",
"properties" : {
"business_name" : {
Expand Down Expand Up @@ -2440,6 +2444,27 @@
"broadcast" : {
"type" : "boolean",
"description" : "The flag that define if the station is made for broadcast operations"
},
"endpoint_rt" : {
"type" : "string",
"description" : "endpoint for RT"
},
"endpoint_redirect" : {
"type" : "string",
"description" : "endpoint for Redirect"
},
"endpoint_mod4" : {
"type" : "string",
"description" : "endpoint for Modello Unico"
},
"primitive_version" : {
"type" : "integer",
"description" : "Version of the primitive",
"format" : "int32"
},
"ci_status" : {
"type" : "boolean",
"description" : "True if the CI is enabled"
}
},
"description" : "List of creditor institutions associated to the same broker by different stations"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,81 +141,34 @@ public ResponseEntity<CIAssociatedCodeList> getApplicationCodesFromCreditorInsti
}

/**
* GET /{creditorInstitutionCode}/segregationcodes : Get creditor institution station
* GET /{creditorInstitutionCode}/segregationcodes : Get creditor institution segregation codes
*
* @param creditorInstitutionCode station code. (required)
* @param showUsedCodes The flag that permits to show the codes already used
* @param service The service endpoint, to be used as a search filter to obtain only the
* segregation codes used by the CI for stations using same endpoint service.
* @param ciTaxCode Creditor institution's tax code that own the station
* @param targetCITaxCode Tax code of the creditor institution that will be associated to the station
* @return OK. (status code 200) or Not Found (status code 404) or Service unavailable (status
* code 500)
* code 500)
*/
@Operation(
summary = "Get segregation code associations with creditor institution",
security = {
@SecurityRequirement(name = "ApiKey"),
@SecurityRequirement(name = "Authorization")
},
tags = {
"Creditor Institutions",
})
@ApiResponses(
value = {
@ApiResponse(
responseCode = "200",
description = "OK",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(implementation = CIAssociatedCodeList.class))),
@ApiResponse(
responseCode = "401",
description = "Unauthorized",
content = @Content(schema = @Schema())),
@ApiResponse(
responseCode = "403",
description = "Forbidden",
content = @Content(schema = @Schema())),
@ApiResponse(
responseCode = "404",
description = "Not Found",
content = @Content(schema = @Schema(implementation = ProblemJson.class))),
@ApiResponse(
responseCode = "429",
description = "Too many requests",
content = @Content(schema = @Schema())),
@ApiResponse(
responseCode = "500",
description = "Service unavailable",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ProblemJson.class)))
})
@GetMapping(
value = "/{creditorInstitutionCode}/segregationcodes",
produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<CIAssociatedCodeList> getSegregationCodesFromCreditorInstitution(
@Parameter(
description = "Organization fiscal code, the fiscal code of the Organization.",
required = true)
@PathVariable("creditorInstitutionCode")
String creditorInstitutionCode,
@Parameter(
description = "The flag that permits to show the codes already used. Default: true")
@RequestParam(required = false, defaultValue = "true")
boolean showUsedCodes,
@Parameter(
description =
"The service endpoint, to be used as a search filter to obtain only the"
+ " segregation codes used by the CI for stations using same endpoint"
+ " service. Default: null")
@RequestParam(required = false)
String service) {
return ResponseEntity.ok(
creditorInstitutionsService.getSegregationCodesFromCreditorInstitution(
creditorInstitutionCode, showUsedCodes, service));
security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK",
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = AvailableCodes.class))),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema())),
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema())),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(implementation = ProblemJson.class))),
@ApiResponse(responseCode = "429", description = "Too many requests", content = @Content(schema = @Schema())),
@ApiResponse(responseCode = "500", description = "Service unavailable",
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))
})
@GetMapping(value = "/{ci-tax-code}/segregationcodes", produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<AvailableCodes> getSegregationCodesFromCreditorInstitution(
@Parameter(description = "Creditor institution's tax code that own the station") @PathVariable("ci-tax-code") String ciTaxCode,
@Parameter(description = "Tax code of the creditor institution that will be associated to the station") @RequestParam @NotBlank String targetCITaxCode
) {
return ResponseEntity.ok(this.creditorInstitutionsService.getAvailableCISegregationCodes(ciTaxCode, targetCITaxCode));
}

/**
* Retrieve a list of creditor institution business names, given the provided list of creditor institution tax codes
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
import it.gov.pagopa.apiconfig.starter.entity.Pa;
import it.gov.pagopa.apiconfig.starter.entity.PaStazionePa;
import it.gov.pagopa.apiconfig.starter.entity.Stazioni;
import org.apache.logging.log4j.util.Strings;
import org.modelmapper.Converter;
import org.modelmapper.spi.MappingContext;

import static it.gov.pagopa.apiconfig.selfcareintegration.util.Utility.deNull;

public class ConvertPaStazionePaToCreditorInstitutionDetail implements Converter<PaStazionePa, CreditorInstitutionDetail> {

@Override
Expand All @@ -18,7 +21,7 @@ public CreditorInstitutionDetail convert(MappingContext<PaStazionePa, CreditorIn
Stazioni stazione = src.getFkStazione();
IntermediariPa intermediariPa = stazione.getIntermediarioPa();

return CreditorInstitutionDetail.builder()
var builder = CreditorInstitutionDetail.builder()
.businessName(pa.getRagioneSociale())
.creditorInstitutionCode(pa.getIdDominio())
.pspPayment(pa.getPagamentoPressoPsp())
Expand All @@ -31,13 +34,49 @@ public CreditorInstitutionDetail convert(MappingContext<PaStazionePa, CreditorIn
.auxDigit(src.getAuxDigit())
.segregationCode(getDoubleDigitCode(src.getSegregazione()))
.applicationCode(getDoubleDigitCode(src.getProgressivo()))
.broadcast(src.getBroadcast())
.endpointRT(stazione.getProtocollo() + stazione.getIp() + stazione.getPorta() + stazione.getServizio())
.endpointRedirect(stazione.getRedirectProtocollo() + stazione.getRedirectIp() + stazione.getRedirectPorta()+ stazione.getRedirectPath() + stazione.getRedirectQueryString())
.endpointMU(stazione.getProtocollo4Mod() + stazione.getIp4Mod() + stazione.getPorta4Mod() + stazione.getServizio4Mod())
.versionePrimitive(stazione.getVersionePrimitive())
.ecStatus(src.getPa().getEnabled())
.build();
.broadcast(src.getBroadcast());

if (Strings.isNotBlank(stazione.getIp())) {
String endpointRT = String.format("%s://%s:%s%s",
deNull(stazione.getProtocollo()).toLowerCase(),
deNull(stazione.getIp()),
deNull(stazione.getPorta()),
startWith("/", deNull(stazione.getServizio()))
);
builder.endpointRT(endpointRT);
}

if (Strings.isNotBlank(stazione.getRedirectIp())) {
String endpointRedirect = String.format("%s://%s:%s%s%s",
deNull(stazione.getRedirectProtocollo().toLowerCase()),
deNull(stazione.getRedirectIp()),
deNull(stazione.getRedirectPorta()),
startWith("/", deNull(stazione.getRedirectPath())),
startWith("?", deNull(stazione.getRedirectQueryString()))
);
builder.endpointRedirect(endpointRedirect);
}

if (Strings.isNotBlank(stazione.getIp4Mod())) {
String endpointMU = String.format("%s://%s:%s%s",
deNull(stazione.getProtocollo4Mod()).toLowerCase(),
deNull(stazione.getIp4Mod()),
deNull(stazione.getPorta4Mod()),
startWith("/", deNull(stazione.getServizio4Mod()))
);
builder.endpointMU(endpointMU);
}

builder.versionePrimitive(stazione.getVersionePrimitive());
builder.ciStatus(deNull(src.getPa().getEnabled()));
return builder.build();
}

private String startWith(String prefix, String s) {
if (!s.startsWith(prefix)) {
return prefix + s;
}
return s;
}

private String getDoubleDigitCode(Long code) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,5 @@ public class CreditorInstitutionDetail {
@JsonProperty("ci_status")
@Schema(description = "True if the CI is enabled", requiredMode = Schema.RequiredMode.REQUIRED)
private Boolean ciStatus;

}
Loading

0 comments on commit eb03950

Please sign in to comment.