Profile Service
Wrapper for the /user/{userId}/profile API. Cannot be used with the
Management API. (OIDC Client only)
List of all options:
- Get profile fields
- Update profile fields
Initialize service
TrivoreID sdk = TrivoreID.openIdClient();
ProfileServiceImpl profileService = new ProfileServiceImpl(sdk.profileService());
Profile management
// get profile of the authenticated user
Profile profile = profileService.get(userId);
// update profile
Mobile mobile = new Mobile("+3584012345678");
mobile.setTags(Arrays.asList("tag1", "tag2"));
Email email1 = new Email("[email protected]");
email1.setTags(Arrays.asList("tag3", "tag4"));
Email email2 = new Email("[email protected]");
email2.getTags().add("tag5");
Address address = new Address();
address.setCountry("Country");
address.setLocality("FI");
address.setPostalCode("12345");
address.setRegion("Region");
address.setStreetAddress("Street Address");
Name name = new Name();
name.setFamilyName("Smith");
name.setMiddleName("Jr.");
name.setGivenName("John");
Consents consents = new Consents();
consents.setLocationing(true);
consents.setMarketingEmail(true);
profile.setEmails(new LinkedHashSet<>(Arrays.asList(email1, email2)));
profile.getMobiles().add(mobile);
profile.getAddresses().add(address);
profile.setName(name);
profile.setConsents(consents);
profile.setNickName("nickName");
profile.setDateOfBirth("1900-12-29");
// update new fields
profileService.update(userId, profile);