Altinn / altinn-notifications

Altinn platform microservice for handling notifications (mail, sms, etc)
MIT License
2 stars 3 forks source link

Find correct endpoints for sourcing data for keywords #589

Closed olebhansen closed 3 months ago

olebhansen commented 3 months ago

Description

Identify if we can use an existing endpoint or if we need to create a new endpoint for Notifications to use when performing keyword replacements.

We're in need of the following pieces of information:

Keyword Description Source
$recipientFirstName$ The first name of a person Register.Party.Person
$recipientMiddleName$ The middle name of a person Register.Party.Person
$recipientLastName$ The surname of a person Register.Party.Person
$recipientName$ The full name of the recipient Register.Party.Person or Register.Party.Organization
$recipientNumber$ The organization number when recipient is an organization. Left empty if recipient is a person. Notifications.OrderRequest
$recipientEmail$
$recipientMobileNumber$
The phone number or email address of the recipient ContactPoints

Another requirement is the ability to retrieve a list of independent parties. It's also important that we can handle both party types through the same call.

Analysis

This is a list of endpoints that can return data based on a national identity or organization number.

  1. register/api/v1/organizations/{orgNo} Returns organization information based on the organization number. No support for lookup of a person.
  2. register/api/v1/persons Returns person information based on national identity number and last name. No support for lookup of an organization.
  3. register/api/v1/parties/lookup Returns a full party object that include either Person or Organization based on the party type. The issue here is that it doesn't support more than one Party in each request.
  4. register/api/v1/parties/nameslookup Returns a list of parties, but with a custom model that is missing first, middle and last name as separate properties.
  5. register/api/v1/parties/identifiers Returns a specialized model without the names of parties.

Missing first name

After some testing of the SblBridge endpoints available we see that the first name and middle name properties are left empty in many cases. Endpoints created for lists of individual parties are based on a call chain in Altinn 2 where the first name and middle name properties are left out.

There are currently no suitable endpoints in Altinn II that we can use. We've been hit with this limitation in an other issue: https://github.com/Altinn/altinn-register/issues/89 . In that case we request one person at time, so the fix were to change what endpoint we use in Altinn II.

Options

We would need to either perform multiple individual calls from Notifications to Register for each person we need the name for or we need to make changes to Altinn II. It's important to note here that the issue isn't isolated to SblBridge, but goes all the way down to the database query being used.

It's also possible to perform a party id lookup first and then do a party list lookup based on the list of party id values.

Conclusion

We need a new endpoint in Register and potentially changes in Altinn II.