Skip to content

Commit 900e821

Browse files
[SELC-6094] feat: set mobile phone field in sc-users queue message (#236)
1 parent 37f1c46 commit 900e821

File tree

9 files changed

+349
-83
lines changed

9 files changed

+349
-83
lines changed

apps/user-cdc/src/main/java/it/pagopa/selfcare/user/event/mapper/NotificationMapper.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
import org.mapstruct.Mapper;
88
import org.mapstruct.Mapping;
99
import org.mapstruct.Named;
10-
import org.openapi.quarkus.user_registry_json.model.CertifiableFieldResourceOfstring;
11-
import org.openapi.quarkus.user_registry_json.model.UserResource;
10+
import org.openapi.quarkus.user_registry_json.model.*;
1211

13-
import javax.swing.text.html.Option;
14-
import java.util.*;
12+
import java.util.Collections;
13+
import java.util.List;
14+
import java.util.Optional;
15+
import java.util.UUID;
1516

1617
@Mapper(componentModel = "cdi", imports = UUID.class)
1718
public interface NotificationMapper {
@@ -52,9 +53,10 @@ default UserToNotify mapUserForFD(UserResource userResource,OnboardedProduct onb
5253
default UserToNotify mapUser(UserResource userResource, String userMailUuid, OnboardedProduct onboardedProduct) {
5354
UserToNotify userToNotify = new UserToNotify();
5455
userToNotify.setUserId(Optional.ofNullable(userResource.getId()).map(UUID::toString).orElse(null));
55-
userToNotify.setName(Optional.ofNullable(userResource.getName()).map(CertifiableFieldResourceOfstring::getValue).orElse(null));
56-
userToNotify.setFamilyName(Optional.ofNullable(userResource.getFamilyName()).map(CertifiableFieldResourceOfstring::getValue).orElse(null));
56+
userToNotify.setName(Optional.ofNullable(userResource.getName()).map(NameCertifiableSchema::getValue).orElse(null));
57+
userToNotify.setFamilyName(Optional.ofNullable(userResource.getFamilyName()).map(FamilyNameCertifiableSchema::getValue).orElse(null));
5758
userToNotify.setEmail(Optional.ofNullable(userMailUuid).map(mailUuid -> retrieveMailFromWorkContacts(userResource, mailUuid)).orElse(null));
59+
userToNotify.setMobilePhone(Optional.ofNullable(userMailUuid).map(mailUuid -> retrievePhoneFromWorkContacts(userResource, mailUuid)).orElse(null));
5860
userToNotify.setProductRole(onboardedProduct.getProductRole());
5961
userToNotify.setRole(Optional.ofNullable(onboardedProduct.getRole()).map(Enum::name).orElse(null));
6062
userToNotify.setRelationshipStatus(onboardedProduct.getStatus());
@@ -65,7 +67,15 @@ default String retrieveMailFromWorkContacts(UserResource userResource, String us
6567
return Optional.ofNullable(userResource.getWorkContacts())
6668
.flatMap(stringWorkContactResourceMap -> Optional.ofNullable(stringWorkContactResourceMap.get(userMailUuid))
6769
.flatMap(workContactResource -> Optional.ofNullable(workContactResource.getEmail())
68-
.map(CertifiableFieldResourceOfstring::getValue)))
70+
.map(EmailCertifiableSchema::getValue)))
71+
.orElse(null);
72+
}
73+
74+
default String retrievePhoneFromWorkContacts(UserResource userResource, String userMailUuid) {
75+
return Optional.ofNullable(userResource.getWorkContacts())
76+
.flatMap(stringWorkContactResourceMap -> Optional.ofNullable(stringWorkContactResourceMap.get(userMailUuid))
77+
.flatMap(workContactResource -> Optional.ofNullable(workContactResource.getMobilePhone())
78+
.map(MobilePhoneCertifiableSchema::getValue)))
6979
.orElse(null);
7080
}
7181
}

apps/user-cdc/src/main/openapi/user_registry.json

Lines changed: 119 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"basePath" : {
1212
"default" : "user-registry/v1"
1313
}
14+
},
15+
"x-amazon-apigateway-endpoint-configuration" : {
16+
"disableExecuteApiEndpoint" : true
1417
}
1518
} ],
1619
"tags" : [ {
@@ -389,17 +392,7 @@
389392
}
390393
}
391394
},
392-
"WorkContactResource" : {
393-
"title" : "WorkContactResource",
394-
"type" : "object",
395-
"properties" : {
396-
"email" : {
397-
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
398-
}
399-
}
400-
},
401-
"CertifiableFieldResourceOfstring" : {
402-
"title" : "CertifiableFieldResourceOfstring",
395+
"BirthDateCertifiableSchema" : {
403396
"required" : [ "certification", "value" ],
404397
"type" : "object",
405398
"properties" : {
@@ -410,37 +403,42 @@
410403
},
411404
"value" : {
412405
"type" : "string",
413-
"description" : "Field value"
406+
"description" : "Field value",
407+
"format" : "date"
414408
}
415-
}
409+
},
410+
"description" : "User date of birth"
416411
},
417-
"UserId" : {
418-
"title" : "UserId",
419-
"required" : [ "id" ],
412+
"WorkContactResource" : {
420413
"type" : "object",
421414
"properties" : {
422-
"id" : {
423-
"type" : "string",
424-
"description" : "User internal id",
425-
"format" : "uuid"
415+
"email" : {
416+
"$ref" : "#/components/schemas/EmailCertifiableSchema"
417+
},
418+
"mobilePhone" : {
419+
"$ref" : "#/components/schemas/MobilePhoneCertifiableSchema"
420+
},
421+
"telephone" : {
422+
"$ref" : "#/components/schemas/TelephoneCertifiableSchema"
426423
}
427-
}
424+
},
425+
"description" : "User work contacts"
428426
},
429427
"MutableUserFieldsDto" : {
430428
"title" : "MutableUserFieldsDto",
431429
"type" : "object",
432430
"properties" : {
433431
"birthDate" : {
434-
"$ref" : "#/components/schemas/CertifiableFieldResourceOfLocalDate"
432+
"$ref" : "#/components/schemas/BirthDateCertifiableSchema"
435433
},
436434
"email" : {
437-
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
435+
"$ref" : "#/components/schemas/EmailCertifiableSchema"
438436
},
439437
"familyName" : {
440-
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
438+
"$ref" : "#/components/schemas/FamilyNameCertifiableSchema"
441439
},
442440
"name" : {
443-
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
441+
"$ref" : "#/components/schemas/NameCertifiableSchema"
444442
},
445443
"workContacts" : {
446444
"type" : "object",
@@ -451,8 +449,7 @@
451449
}
452450
}
453451
},
454-
"CertifiableFieldResourceOfLocalDate" : {
455-
"title" : "CertifiableFieldResourceOfLocalDate",
452+
"NameCertifiableSchema" : {
456453
"required" : [ "certification", "value" ],
457454
"type" : "object",
458455
"properties" : {
@@ -463,24 +460,23 @@
463460
},
464461
"value" : {
465462
"type" : "string",
466-
"description" : "Field value",
467-
"format" : "date"
463+
"description" : "Field value"
468464
}
469-
}
465+
},
466+
"description" : "User name"
470467
},
471468
"UserResource" : {
472-
"title" : "UserResource",
473469
"required" : [ "id" ],
474470
"type" : "object",
475471
"properties" : {
476472
"birthDate" : {
477-
"$ref" : "#/components/schemas/CertifiableFieldResourceOfLocalDate"
473+
"$ref" : "#/components/schemas/BirthDateCertifiableSchema"
478474
},
479475
"email" : {
480-
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
476+
"$ref" : "#/components/schemas/EmailCertifiableSchema"
481477
},
482478
"familyName" : {
483-
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
479+
"$ref" : "#/components/schemas/FamilyNameCertifiableSchema"
484480
},
485481
"fiscalCode" : {
486482
"type" : "string",
@@ -492,7 +488,7 @@
492488
"format" : "uuid"
493489
},
494490
"name" : {
495-
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
491+
"$ref" : "#/components/schemas/NameCertifiableSchema"
496492
},
497493
"workContacts" : {
498494
"type" : "object",
@@ -503,26 +499,84 @@
503499
}
504500
}
505501
},
502+
"TelephoneCertifiableSchema" : {
503+
"required" : [ "certification", "value" ],
504+
"type" : "object",
505+
"properties" : {
506+
"certification" : {
507+
"type" : "string",
508+
"description" : "Certified source of information",
509+
"enum" : [ "NONE", "SPID" ]
510+
},
511+
"value" : {
512+
"type" : "string",
513+
"description" : "Field value"
514+
}
515+
},
516+
"description" : "User work telephone number"
517+
},
518+
"InvalidParam" : {
519+
"title" : "InvalidParam",
520+
"required" : [ "name", "reason" ],
521+
"type" : "object",
522+
"properties" : {
523+
"name" : {
524+
"type" : "string",
525+
"description" : "Invalid parameter name."
526+
},
527+
"reason" : {
528+
"type" : "string",
529+
"description" : "Invalid parameter reason."
530+
}
531+
}
532+
},
533+
"EmailCertifiableSchema" : {
534+
"required" : [ "certification", "value" ],
535+
"type" : "object",
536+
"properties" : {
537+
"certification" : {
538+
"type" : "string",
539+
"description" : "Certified source of information",
540+
"enum" : [ "NONE", "SPID" ]
541+
},
542+
"value" : {
543+
"type" : "string",
544+
"description" : "Field value"
545+
}
546+
},
547+
"description" : "User email"
548+
},
549+
"UserId" : {
550+
"title" : "UserId",
551+
"required" : [ "id" ],
552+
"type" : "object",
553+
"properties" : {
554+
"id" : {
555+
"type" : "string",
556+
"description" : "User internal id",
557+
"format" : "uuid"
558+
}
559+
}
560+
},
506561
"SaveUserDto" : {
507-
"title" : "SaveUserDto",
508562
"required" : [ "fiscalCode" ],
509563
"type" : "object",
510564
"properties" : {
511565
"birthDate" : {
512-
"$ref" : "#/components/schemas/CertifiableFieldResourceOfLocalDate"
566+
"$ref" : "#/components/schemas/BirthDateCertifiableSchema"
513567
},
514568
"email" : {
515-
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
569+
"$ref" : "#/components/schemas/EmailCertifiableSchema"
516570
},
517571
"familyName" : {
518-
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
572+
"$ref" : "#/components/schemas/FamilyNameCertifiableSchema"
519573
},
520574
"fiscalCode" : {
521575
"type" : "string",
522576
"description" : "User fiscal code"
523577
},
524578
"name" : {
525-
"$ref" : "#/components/schemas/CertifiableFieldResourceOfstring"
579+
"$ref" : "#/components/schemas/NameCertifiableSchema"
526580
},
527581
"workContacts" : {
528582
"type" : "object",
@@ -569,20 +623,37 @@
569623
},
570624
"description" : "A \"problem detail\" as a way to carry machine-readable details of errors (https://datatracker.ietf.org/doc/html/rfc7807)"
571625
},
572-
"InvalidParam" : {
573-
"title" : "InvalidParam",
574-
"required" : [ "name", "reason" ],
626+
"FamilyNameCertifiableSchema" : {
627+
"required" : [ "certification", "value" ],
575628
"type" : "object",
576629
"properties" : {
577-
"name" : {
630+
"certification" : {
578631
"type" : "string",
579-
"description" : "Invalid parameter name."
632+
"description" : "Certified source of information",
633+
"enum" : [ "NONE", "SPID" ]
580634
},
581-
"reason" : {
635+
"value" : {
582636
"type" : "string",
583-
"description" : "Invalid parameter reason."
637+
"description" : "Field value"
584638
}
585-
}
639+
},
640+
"description" : "User family name"
641+
},
642+
"MobilePhoneCertifiableSchema" : {
643+
"required" : [ "certification", "value" ],
644+
"type" : "object",
645+
"properties" : {
646+
"certification" : {
647+
"type" : "string",
648+
"description" : "Certified source of information",
649+
"enum" : [ "NONE", "SPID" ]
650+
},
651+
"value" : {
652+
"type" : "string",
653+
"description" : "Field value"
654+
}
655+
},
656+
"description" : "User work mobile phone number"
586657
}
587658
},
588659
"securitySchemes" : {

0 commit comments

Comments
 (0)