Skip to content

Commit

Permalink
[PPD-206] crud gps: added enrollments api (no business code)
Browse files Browse the repository at this point in the history
  • Loading branch information
aacitelli committed Jun 20, 2022
1 parent d313cec commit 492b8e4
Show file tree
Hide file tree
Showing 10 changed files with 352 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package it.gov.pagopa.spontaneouspayment.controller;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import it.gov.pagopa.spontaneouspayment.model.EnrollmentModel;
import it.gov.pagopa.spontaneouspayment.model.OrganizationEnrollmentModel;
import it.gov.pagopa.spontaneouspayment.model.OrganizationModel;
import it.gov.pagopa.spontaneouspayment.model.ProblemJson;
import it.gov.pagopa.spontaneouspayment.model.response.EnrollmentModelResponse;
import it.gov.pagopa.spontaneouspayment.model.response.OrganizationModelResponse;


@Tag(name = "Enrollments API")
@RequestMapping
@Validated
public interface IEnrollmentsController {

@Operation(summary = "The organization creates a creditor institution with its subscription to the 1st service.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "createECAndFirstServiceEnrollment")
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "Request created.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "OrganizationModelResponse", implementation = OrganizationModelResponse.class))),
@ApiResponse(responseCode = "400", description = "Malformed request.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))),
@ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())),
@ApiResponse(responseCode = "404", description = "Not Found the enroll service.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))),
@ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))})
@PostMapping(value = "/organizations/{organizationFiscalCode}/services/{serviceId}",
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<OrganizationModelResponse> createECAndFirstServiceEnrollment(
@Parameter(description = "The fiscal code of the Organization.", required = true)
@NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode,
@Parameter(description = "The service id to enroll.", required = true)
@NotBlank @PathVariable("serviceId") String serviceId,
@Valid @RequestBody OrganizationEnrollmentModel organizationEnrollmentModel);

@Operation(summary = "The organization updates the enrollment to service for the creditor institution.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "updateECEnrollment")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Request updated.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "OrganizationModelResponse", implementation = OrganizationModelResponse.class))),
@ApiResponse(responseCode = "400", description = "Malformed request.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))),
@ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())),
@ApiResponse(responseCode = "404", description = "Not Found the creditor institution or the enroll service.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))),
@ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))})
@PutMapping(value = "/organizations/{organizationFiscalCode}/services/{serviceId}",
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<OrganizationModelResponse> updateECEnrollment(
@Parameter(description = "The fiscal code of the Organization.", required = true)
@NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode,
@Parameter(description = "The service id to enroll.", required = true)
@NotBlank @PathVariable("serviceId") String serviceId,
@Valid @RequestBody EnrollmentModel enrollmentModel);

@Operation(summary = "The organization updates the creditor institution.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "updateEC")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Request updated.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "OrganizationModelResponse", implementation = OrganizationModelResponse.class))),
@ApiResponse(responseCode = "400", description = "Malformed request.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))),
@ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())),
@ApiResponse(responseCode = "404", description = "Not Found the creditor institution.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))),
@ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))})
@PutMapping(value = "/organizations/{organizationFiscalCode}",
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<OrganizationModelResponse> updateEC(
@Parameter(description = "The fiscal code of the Organization.", required = true)
@NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode,
@Valid @RequestBody OrganizationModel organizationModel);

@Operation(summary = "The organization deletes the enrollment to service for the creditor institution.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "deleteECEnrollment")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Request deleted."),
@ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())),
@ApiResponse(responseCode = "404", description = "Not Found the creditor institution or the enroll service.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))),
@ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))})
@DeleteMapping(value = "/organizations/{organizationFiscalCode}/services/{serviceId}",
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<String> deleteECEnrollment(
@Parameter(description = "The fiscal code of the Organization.", required = true)
@NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode,
@Parameter(description = "The service id to enroll.", required = true)
@NotBlank @PathVariable("serviceId") String serviceId);

@Operation(summary = "Return the single enrollment to a service.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "getSingleEnrollment")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Obtained single enrollment.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "EnrollmentModelResponse", implementation = EnrollmentModelResponse.class))),
@ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())),
@ApiResponse(responseCode = "404", description = "No payment option found.", content = @Content(schema = @Schema(implementation = ProblemJson.class))),
@ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))})
@GetMapping(value = "/organizations/{organizationFiscalCode}/services/{serviceId}",
produces = {"application/json"})
ResponseEntity<EnrollmentModelResponse> getSingleEnrollment(
@Parameter(description = "The fiscal code of the Organization.", required = true)
@NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode,
@Parameter(description = "The service id to enroll.", required = true)
@NotBlank @PathVariable("serviceId") String serviceId);

@Operation(summary = "Return all enrollments for a creditor institution.", security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")}, operationId = "getECEnrollments")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Obtained all enrollments for the creditor institution.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(name = "OrganizationModelResponse", implementation = OrganizationModelResponse.class))),
@ApiResponse(responseCode = "401", description = "Wrong or missing function key.", content = @Content(schema = @Schema())),
@ApiResponse(responseCode = "404", description = "No payment option found.", content = @Content(schema = @Schema(implementation = ProblemJson.class))),
@ApiResponse(responseCode = "500", description = "Service unavailable.", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))})
@GetMapping(value = "/organizations/{organizationFiscalCode}",
produces = {"application/json"})
ResponseEntity<OrganizationModelResponse> getECEnrollments(
@Parameter(description = "The fiscal code of the Organization.", required = true)
@NotBlank @PathVariable("organizationfiscalcode") String organizationFiscalCode);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package it.gov.pagopa.spontaneouspayment.controller.impl;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;

import it.gov.pagopa.spontaneouspayment.controller.IEnrollmentsController;
import it.gov.pagopa.spontaneouspayment.model.EnrollmentModel;
import it.gov.pagopa.spontaneouspayment.model.OrganizationEnrollmentModel;
import it.gov.pagopa.spontaneouspayment.model.OrganizationModel;
import it.gov.pagopa.spontaneouspayment.model.response.EnrollmentModelResponse;
import it.gov.pagopa.spontaneouspayment.model.response.OrganizationModelResponse;

@Controller
public class EnrollmentsController implements IEnrollmentsController{

@Override
public ResponseEntity<OrganizationModelResponse> createECAndFirstServiceEnrollment(
@NotBlank String organizationFiscalCode, @NotBlank String serviceId,
@Valid OrganizationEnrollmentModel organizationEnrollmentModel) {
// TODO Auto-generated method stub
return null;
}

@Override
public ResponseEntity<OrganizationModelResponse> updateECEnrollment(@NotBlank String organizationFiscalCode,
@NotBlank String serviceId, @Valid EnrollmentModel enrollmentModel) {
// TODO Auto-generated method stub
return null;
}

@Override
public ResponseEntity<OrganizationModelResponse> updateEC(@NotBlank String organizationFiscalCode,
@Valid OrganizationModel organizationModel) {
// TODO Auto-generated method stub
return null;
}

@Override
public ResponseEntity<String> deleteECEnrollment(@NotBlank String organizationFiscalCode,
@NotBlank String serviceId) {
// TODO Auto-generated method stub
return null;
}

@Override
public ResponseEntity<EnrollmentModelResponse> getSingleEnrollment(@NotBlank String organizationFiscalCode,
@NotBlank String serviceId) {
// TODO Auto-generated method stub
return null;
}

@Override
public ResponseEntity<OrganizationModelResponse> getECEnrollments(@NotBlank String organizationFiscalCode) {
// TODO Auto-generated method stub
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package it.gov.pagopa.spontaneouspayment.model;

import java.io.Serializable;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class EnrollmentModel implements Serializable{

/**
* generated serialVersionUID
*/
private static final long serialVersionUID = 8505165905680276253L;

private String iban;
private String officeName;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package it.gov.pagopa.spontaneouspayment.model;

import java.io.Serializable;

import javax.validation.constraints.NotBlank;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class OrganizationEnrollmentModel implements Serializable{
/**
* generated serialVersionUID
*/
private static final long serialVersionUID = 3009315407053476788L;

@NotBlank(message = "company name is required")
private String companyName;
@NotBlank(message = "iban is required")
private String iban;
private String officeName;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package it.gov.pagopa.spontaneouspayment.model;

import java.io.Serializable;

import it.gov.pagopa.spontaneouspayment.model.enumeration.Status;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class OrganizationModel implements Serializable{

/**
* generated serialVersionUID
*/
private static final long serialVersionUID = -1181181033127626459L;

private String companyName;
private Status status;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package it.gov.pagopa.spontaneouspayment.model.enumeration;

public enum Status {
ENABLED, DISABLED
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package it.gov.pagopa.spontaneouspayment.model.response;

import java.io.Serializable;

import javax.validation.constraints.NotBlank;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class EnrollmentModelResponse implements Serializable{
/**
* generated serialVersionUID
*/
private static final long serialVersionUID = -6830998393310794316L;

@NotBlank(message = "service ID is required")
private String serviceId;
@NotBlank(message = "iban is required")
private String iban;
private String officeName;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package it.gov.pagopa.spontaneouspayment.model.response;

import java.io.Serializable;
import java.util.List;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import it.gov.pagopa.spontaneouspayment.model.enumeration.Status;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class OrganizationModelResponse implements Serializable {
/**
* generated serialVersionUID
*/
private static final long serialVersionUID = 6474656487948357626L;

@NotBlank(message = "organization fiscal code is required")
private String organizationFiscalCode;

@NotBlank(message = "company name is required")
private String companyName;

@NotNull(message = "status is required")
private Status type;

@Valid
private List<EnrollmentModelResponse> enrollments;


}
28 changes: 28 additions & 0 deletions src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# info
properties.environment=dev

# Cosmos account config
azure.cosmos.uri=https://pagopa-d-gps-cosmos-account.documents.azure.com:443/
azure.cosmos.key=lGiI05RuRfjbT3UvHzFjuITKcSu6gK0f8lgHdKmipHgGiTIKVxceTdpJhVC67xmYm5uXihdsznnyyfOm2LsVoQ==
azure.cosmos.database=db
azure.cosmos.populate-query-metrics=false

azure.cosmos.ec-container-name=creditor_institutions
azure.cosmos.service-container-name=services

service.gpd.host=http://localhost:8085

# timeout
feign.client.config.default.connect-timeout=1000
feign.client.config.default.read-timeout=1000

# retry configuration
retry.maxAttempts=1
retry.maxDelay=200

# logging level settings
logging.level.root=INFO
logging.level.it.gov.pagopa.spontaneouspayment=INFO



5 changes: 1 addition & 4 deletions src/main/resources/application-local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,4 @@ retry.maxDelay=200

# logging level settings
logging.level.root=INFO
logging.level.it.gov.pagopa.spontaneouspayment=INFO



logging.level.it.gov.pagopa.spontaneouspayment=INFO

0 comments on commit 492b8e4

Please sign in to comment.