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

Prepare for nullability of UserId in Profile API - user contact point lookups #644

Merged
merged 8 commits into from
Nov 14, 2024

Conversation

hggutvik
Copy link
Contributor

@hggutvik hggutvik commented Nov 12, 2024

Description

Current state

The Profile API is in the process of phasing out setting actual data in the UserId field when looking up user contact points (i.e. when POSTing to profile/api/v1/users/contactpoint/lookup and profile/api/v1/users/contactpoint/availability)

Notifications uses a domain model (UserContactPoints) with no nullable-declared properties, which also serves as the deserialization model when looking up user contact points in the ProfileClient. This leads to a runtime exception if/when the relevant Profile API endpoints start returning userId: null, as the domain model expects an integer value. The other properties of the (UserContactPoints) domain model are capable of receiving null values from the Profile API, as they are initialized to string.Empty.

To avoid this breaking change in the UserId property, the Profile API is currently returning userId: 0 for user contact points lookups.

Changes in this PR

Add a DTO / API model UserContactPointsDTO that represents/reflects the current/soon-to-be API contract from the Profile API when looking up user contact points. The DTO explicitly declares nullable properties. An explicit mapper (for DTO -> domain model) is defined (currently implemented as an extension method on the DTO class) and used by the ProfileClient when returning the data to the caller (the Core ContactPointsService).

Using this separate API / DTO model, as compared to modifying the domain model UserContactPoints, has the advantage of decoupling the current direct binding between the Profile API interface and our core / domain model in this application.

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

@hggutvik hggutvik changed the title Declare nullability on properties after changes in Profile API Prepare for nullability of UserId in Profile API - user contact point lookups Nov 13, 2024
Copy link
Member

@SandGrainOne SandGrainOne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good.

Copy link

sonarcloud bot commented Nov 14, 2024

@hggutvik hggutvik merged commit 45aff84 into main Nov 14, 2024
7 checks passed
@hggutvik hggutvik deleted the feature/616-handle-profile-krr-changes branch November 14, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants