-
Tore.Brede authoredTore.Brede authored
from typing import Optional
from scim_client import ScimClient
from scim_client.models import User
from greg.models import Identity
from .iga import IgaImplementation, IgaPerson
class UibSebra(IgaImplementation):
def __init__(self, config) -> None:
self.client = ScimClient(**config)
self.idtype_methodmap = {
Identity.IdentityType.NORWEGIAN_NATIONAL_ID_NUMBER: self.client.get_by_nin,
Identity.IdentityType.PASSPORT_NUMBER: None, # not supported by uib scim
}
def extid_search(
self, id_type: Identity.IdentityType, extid: str
) -> Optional[IgaPerson]:
search = self.idtype_methodmap.get(id_type)
if not search:
return None
user: User = search(extid)
if not user:
return None
return IgaPerson(
first=user.name.given_name if user.name else None,
last=user.name.family_name if user.name else None,
)