-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added connector,modified model,dto,mapper,repository, added pattern o…
…n controller
- Loading branch information
1 parent
3aed12c
commit ff16d30
Showing
26 changed files
with
562 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/it/gov/pagopa/onboarding/citizen/connector/tpp/TppConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package it.gov.pagopa.onboarding.citizen.connector.tpp; | ||
|
||
import it.gov.pagopa.onboarding.citizen.dto.TppDTO; | ||
import reactor.core.publisher.Mono; | ||
|
||
public interface TppConnector { | ||
Mono<TppDTO> get(String tppId); | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/it/gov/pagopa/onboarding/citizen/connector/tpp/TppConnectorImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package it.gov.pagopa.onboarding.citizen.connector.tpp; | ||
|
||
import it.gov.pagopa.onboarding.citizen.dto.TppDTO; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.core.ParameterizedTypeReference; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Mono; | ||
|
||
@Service | ||
public class TppConnectorImpl implements TppConnector { | ||
private final WebClient webClient; | ||
|
||
public TppConnectorImpl(WebClient.Builder webClientBuilder, | ||
@Value("${rest-client.tpp.baseUrl}") String baseUrl) { | ||
this.webClient = webClientBuilder.baseUrl(baseUrl).build(); | ||
} | ||
|
||
@Override | ||
public Mono<TppDTO> get(String tppId) { | ||
return webClient.get() | ||
.uri("/emd/tpp/" + tppId) | ||
.retrieve() | ||
.bodyToMono(new ParameterizedTypeReference<>() { | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/it/gov/pagopa/onboarding/citizen/dto/CitizenConsentStateUpdateDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package it.gov.pagopa.onboarding.citizen.dto; | ||
|
||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.AllArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@Data | ||
@SuperBuilder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class CitizenConsentStateUpdateDTO { | ||
private String hashedFiscalCode; | ||
private String tppId; | ||
private Boolean tppState; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/it/gov/pagopa/onboarding/citizen/dto/Contact.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package it.gov.pagopa.onboarding.citizen.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class Contact { | ||
|
||
private String name; | ||
private String number; | ||
private String email; | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/it/gov/pagopa/onboarding/citizen/dto/TppDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package it.gov.pagopa.onboarding.citizen.dto; | ||
|
||
|
||
import it.gov.pagopa.onboarding.citizen.enums.AuthenticationType; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@Data | ||
@SuperBuilder | ||
@NoArgsConstructor | ||
public class TppDTO { | ||
@NotNull | ||
private String tppId; | ||
private String entityId; | ||
private String businessName; | ||
private String messageUrl; | ||
private String authenticationUrl; | ||
private AuthenticationType authenticationType; | ||
private Contact contact; | ||
private Boolean state; | ||
|
||
|
||
|
||
} |
21 changes: 15 additions & 6 deletions
21
...ain/java/it/gov/pagopa/onboarding/citizen/dto/mapper/CitizenConsentObjectToDTOMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,29 @@ | ||
package it.gov.pagopa.onboarding.citizen.dto.mapper; | ||
|
||
|
||
import it.gov.pagopa.onboarding.citizen.dto.CitizenConsentDTO; | ||
import it.gov.pagopa.onboarding.citizen.dto.CitizenConsentDTO.ConsentDTO; | ||
import it.gov.pagopa.onboarding.citizen.model.CitizenConsent; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Service | ||
public class CitizenConsentObjectToDTOMapper { | ||
|
||
public CitizenConsentDTO map(CitizenConsent citizenConsent){ | ||
public CitizenConsentDTO map(CitizenConsent citizenConsent) { | ||
Map<String, ConsentDTO> consentsDTO = new HashMap<>(); | ||
|
||
citizenConsent.getConsents().forEach((tppId, consentDetails) -> consentsDTO.put(tppId, ConsentDTO.builder() | ||
.tc(consentDetails.getTc()) | ||
.tppState(consentDetails.getTppState()) | ||
.creationDate(consentDetails.getCreationDate()) | ||
.lastUpdateDate(consentDetails.getLastUpdateDate()) | ||
.build())); | ||
|
||
return CitizenConsentDTO.builder() | ||
.hashedFiscalCode(citizenConsent.getHashedFiscalCode()) | ||
.tppState(citizenConsent.getTppState()) | ||
.tppId(citizenConsent.getTppId()) | ||
.creationDate(citizenConsent.getCreationDate()) | ||
.lastUpdateDate(citizenConsent.getLastUpdateDate()) | ||
.consents(consentsDTO) | ||
.build(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/it/gov/pagopa/onboarding/citizen/enums/AuthenticationType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package it.gov.pagopa.onboarding.citizen.enums; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum AuthenticationType { | ||
OAUTH2("OAUTH2"); | ||
|
||
|
||
private final String status; | ||
|
||
AuthenticationType(String status) { | ||
this.status = status; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/it/gov/pagopa/onboarding/citizen/model/ConsentDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package it.gov.pagopa.onboarding.citizen.model; | ||
|
||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@SuperBuilder | ||
public class ConsentDetails { | ||
private Boolean tc; | ||
private Boolean tppState; | ||
private LocalDateTime creationDate; | ||
private LocalDateTime lastTcUpdateDate; | ||
private LocalDateTime lastUpdateDate; | ||
} |
19 changes: 15 additions & 4 deletions
19
...n/java/it/gov/pagopa/onboarding/citizen/model/mapper/CitizenConsentDTOToObjectMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,29 @@ | ||
package it.gov.pagopa.onboarding.citizen.model.mapper; | ||
|
||
|
||
import it.gov.pagopa.onboarding.citizen.dto.CitizenConsentDTO; | ||
import it.gov.pagopa.onboarding.citizen.model.CitizenConsent; | ||
import it.gov.pagopa.onboarding.citizen.model.ConsentDetails; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Service | ||
public class CitizenConsentDTOToObjectMapper { | ||
|
||
public CitizenConsent map(CitizenConsentDTO citizenConsentDTO){ | ||
public CitizenConsent map(CitizenConsentDTO citizenConsentDTO) { | ||
Map<String, ConsentDetails> consents = new HashMap<>(); | ||
|
||
citizenConsentDTO.getConsents().forEach((tppId, consentDTO) -> consents.put(tppId, ConsentDetails.builder() | ||
.tc(consentDTO.getTc()) | ||
.tppState(consentDTO.getTppState()) | ||
.creationDate(consentDTO.getCreationDate()) | ||
.lastTcUpdateDate(consentDTO.getLastUpdateDate()) | ||
.build())); | ||
|
||
return CitizenConsent.builder() | ||
.tppState(true) | ||
.tppId(citizenConsentDTO.getTppId()) | ||
.hashedFiscalCode(citizenConsentDTO.getHashedFiscalCode()) | ||
.consents(consents) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.