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-6094] feat: set mobile phone field in sc-users queue message #236

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.openapi.quarkus.user_registry_json.model.CertifiableFieldResourceOfstring;
import org.openapi.quarkus.user_registry_json.model.UserResource;
import org.openapi.quarkus.user_registry_json.model.*;

import javax.swing.text.html.Option;
import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

@Mapper(componentModel = "cdi", imports = UUID.class)
public interface NotificationMapper {
Expand Down Expand Up @@ -52,9 +53,10 @@ default UserToNotify mapUserForFD(UserResource userResource,OnboardedProduct onb
default UserToNotify mapUser(UserResource userResource, String userMailUuid, OnboardedProduct onboardedProduct) {
UserToNotify userToNotify = new UserToNotify();
userToNotify.setUserId(Optional.ofNullable(userResource.getId()).map(UUID::toString).orElse(null));
userToNotify.setName(Optional.ofNullable(userResource.getName()).map(CertifiableFieldResourceOfstring::getValue).orElse(null));
userToNotify.setFamilyName(Optional.ofNullable(userResource.getFamilyName()).map(CertifiableFieldResourceOfstring::getValue).orElse(null));
userToNotify.setName(Optional.ofNullable(userResource.getName()).map(NameCertifiableSchema::getValue).orElse(null));
userToNotify.setFamilyName(Optional.ofNullable(userResource.getFamilyName()).map(FamilyNameCertifiableSchema::getValue).orElse(null));
userToNotify.setEmail(Optional.ofNullable(userMailUuid).map(mailUuid -> retrieveMailFromWorkContacts(userResource, mailUuid)).orElse(null));
userToNotify.setMobilePhone(Optional.ofNullable(userMailUuid).map(mailUuid -> retrievePhoneFromWorkContacts(userResource, mailUuid)).orElse(null));
userToNotify.setProductRole(onboardedProduct.getProductRole());
userToNotify.setRole(Optional.ofNullable(onboardedProduct.getRole()).map(Enum::name).orElse(null));
userToNotify.setRelationshipStatus(onboardedProduct.getStatus());
Expand All @@ -65,7 +67,15 @@ default String retrieveMailFromWorkContacts(UserResource userResource, String us
return Optional.ofNullable(userResource.getWorkContacts())
.flatMap(stringWorkContactResourceMap -> Optional.ofNullable(stringWorkContactResourceMap.get(userMailUuid))
.flatMap(workContactResource -> Optional.ofNullable(workContactResource.getEmail())
.map(CertifiableFieldResourceOfstring::getValue)))
.map(EmailCertifiableSchema::getValue)))
.orElse(null);
}

default String retrievePhoneFromWorkContacts(UserResource userResource, String userMailUuid) {
return Optional.ofNullable(userResource.getWorkContacts())
.flatMap(stringWorkContactResourceMap -> Optional.ofNullable(stringWorkContactResourceMap.get(userMailUuid))
.flatMap(workContactResource -> Optional.ofNullable(workContactResource.getMobilePhone())
.map(MobilePhoneCertifiableSchema::getValue)))
.orElse(null);
}
}
167 changes: 119 additions & 48 deletions apps/user-cdc/src/main/openapi/user_registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"basePath" : {
"default" : "user-registry/v1"
}
},
"x-amazon-apigateway-endpoint-configuration" : {
"disableExecuteApiEndpoint" : true
}
} ],
"tags" : [ {
Expand Down Expand Up @@ -389,17 +392,7 @@
}
}
},
"WorkContactResource" : {
"title" : "WorkContactResource",
"type" : "object",
"properties" : {
"email" : {
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
}
}
},
"CertifiableFieldResourceOfstring" : {
"title" : "CertifiableFieldResourceOfstring",
"BirthDateCertifiableSchema" : {
"required" : [ "certification", "value" ],
"type" : "object",
"properties" : {
Expand All @@ -410,37 +403,42 @@
},
"value" : {
"type" : "string",
"description" : "Field value"
"description" : "Field value",
"format" : "date"
}
}
},
"description" : "User date of birth"
},
"UserId" : {
"title" : "UserId",
"required" : [ "id" ],
"WorkContactResource" : {
"type" : "object",
"properties" : {
"id" : {
"type" : "string",
"description" : "User internal id",
"format" : "uuid"
"email" : {
"$ref" : "#/components/schemas/EmailCertifiableSchema"
},
"mobilePhone" : {
"$ref" : "#/components/schemas/MobilePhoneCertifiableSchema"
},
"telephone" : {
"$ref" : "#/components/schemas/TelephoneCertifiableSchema"
}
}
},
"description" : "User work contacts"
},
"MutableUserFieldsDto" : {
"title" : "MutableUserFieldsDto",
"type" : "object",
"properties" : {
"birthDate" : {
"$ref" : "#/components/schemas/CertifiableFieldResourceOfLocalDate"
"$ref" : "#/components/schemas/BirthDateCertifiableSchema"
},
"email" : {
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
"$ref" : "#/components/schemas/EmailCertifiableSchema"
},
"familyName" : {
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
"$ref" : "#/components/schemas/FamilyNameCertifiableSchema"
},
"name" : {
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
"$ref" : "#/components/schemas/NameCertifiableSchema"
},
"workContacts" : {
"type" : "object",
Expand All @@ -451,8 +449,7 @@
}
}
},
"CertifiableFieldResourceOfLocalDate" : {
"title" : "CertifiableFieldResourceOfLocalDate",
"NameCertifiableSchema" : {
"required" : [ "certification", "value" ],
"type" : "object",
"properties" : {
Expand All @@ -463,24 +460,23 @@
},
"value" : {
"type" : "string",
"description" : "Field value",
"format" : "date"
"description" : "Field value"
}
}
},
"description" : "User name"
},
"UserResource" : {
"title" : "UserResource",
"required" : [ "id" ],
"type" : "object",
"properties" : {
"birthDate" : {
"$ref" : "#/components/schemas/CertifiableFieldResourceOfLocalDate"
"$ref" : "#/components/schemas/BirthDateCertifiableSchema"
},
"email" : {
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
"$ref" : "#/components/schemas/EmailCertifiableSchema"
},
"familyName" : {
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
"$ref" : "#/components/schemas/FamilyNameCertifiableSchema"
},
"fiscalCode" : {
"type" : "string",
Expand All @@ -492,7 +488,7 @@
"format" : "uuid"
},
"name" : {
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
"$ref" : "#/components/schemas/NameCertifiableSchema"
},
"workContacts" : {
"type" : "object",
Expand All @@ -503,26 +499,84 @@
}
}
},
"TelephoneCertifiableSchema" : {
"required" : [ "certification", "value" ],
"type" : "object",
"properties" : {
"certification" : {
"type" : "string",
"description" : "Certified source of information",
"enum" : [ "NONE", "SPID" ]
},
"value" : {
"type" : "string",
"description" : "Field value"
}
},
"description" : "User work telephone number"
},
"InvalidParam" : {
"title" : "InvalidParam",
"required" : [ "name", "reason" ],
"type" : "object",
"properties" : {
"name" : {
"type" : "string",
"description" : "Invalid parameter name."
},
"reason" : {
"type" : "string",
"description" : "Invalid parameter reason."
}
}
},
"EmailCertifiableSchema" : {
"required" : [ "certification", "value" ],
"type" : "object",
"properties" : {
"certification" : {
"type" : "string",
"description" : "Certified source of information",
"enum" : [ "NONE", "SPID" ]
},
"value" : {
"type" : "string",
"description" : "Field value"
}
},
"description" : "User email"
},
"UserId" : {
"title" : "UserId",
"required" : [ "id" ],
"type" : "object",
"properties" : {
"id" : {
"type" : "string",
"description" : "User internal id",
"format" : "uuid"
}
}
},
"SaveUserDto" : {
"title" : "SaveUserDto",
"required" : [ "fiscalCode" ],
"type" : "object",
"properties" : {
"birthDate" : {
"$ref" : "#/components/schemas/CertifiableFieldResourceOfLocalDate"
"$ref" : "#/components/schemas/BirthDateCertifiableSchema"
},
"email" : {
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
"$ref" : "#/components/schemas/EmailCertifiableSchema"
},
"familyName" : {
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
"$ref" : "#/components/schemas/FamilyNameCertifiableSchema"
},
"fiscalCode" : {
"type" : "string",
"description" : "User fiscal code"
},
"name" : {
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
"$ref" : "#/components/schemas/NameCertifiableSchema"
},
"workContacts" : {
"type" : "object",
Expand Down Expand Up @@ -569,20 +623,37 @@
},
"description" : "A \"problem detail\" as a way to carry machine-readable details of errors (https://datatracker.ietf.org/doc/html/rfc7807)"
},
"InvalidParam" : {
"title" : "InvalidParam",
"required" : [ "name", "reason" ],
"FamilyNameCertifiableSchema" : {
"required" : [ "certification", "value" ],
"type" : "object",
"properties" : {
"name" : {
"certification" : {
"type" : "string",
"description" : "Invalid parameter name."
"description" : "Certified source of information",
"enum" : [ "NONE", "SPID" ]
},
"reason" : {
"value" : {
"type" : "string",
"description" : "Invalid parameter reason."
"description" : "Field value"
}
}
},
"description" : "User family name"
},
"MobilePhoneCertifiableSchema" : {
"required" : [ "certification", "value" ],
"type" : "object",
"properties" : {
"certification" : {
"type" : "string",
"description" : "Certified source of information",
"enum" : [ "NONE", "SPID" ]
},
"value" : {
"type" : "string",
"description" : "Field value"
}
},
"description" : "User work mobile phone number"
}
},
"securitySchemes" : {
Expand Down
Loading
Loading