Skip to content

Commit

Permalink
feat: handle deceased response from BRP api
Browse files Browse the repository at this point in the history
  • Loading branch information
marnixdessing committed Mar 21, 2023
1 parent 5563ae1 commit a039853
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/app/issue/BrpApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export class BrpApi {
let data = await this.client.requestData(this.endpoint, { bsn: aBsn.bsn }, { 'Content-type': 'application/json' });
if (data?.Persoon) {
return data;
} else if (data?.Persoon?.overleden) {
throw new Error('Persoon lijkt overleden');
}
throw new Error('Het ophalen van persoonsgegevens is misgegaan.');
} catch (error: any) {
Expand Down
6 changes: 3 additions & 3 deletions src/app/issue/issueRequestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ async function handleLoggedinRequest(session: Session, brpApi: BrpApi, yiviApi:
}

// BRP request
let naam = 'Onbekende gebruiker';
let naam = undefined;
let brpData = undefined;
if (!error) {
const bsn = session.getValue('bsn');
brpData = await brpApi.getBrpData(bsn);
naam = brpData?.Persoon?.Persoonsgegevens?.Naam ?? naam;
if (brpData.error) {
naam = brpData?.Persoon?.Persoonsgegevens?.Naam;
if (brpData.error || !naam) {
error = 'Het ophalen van uw persoonsgegevens is mis gegaan. Propeer het later opnieuw.';
}
}
Expand Down

0 comments on commit a039853

Please sign in to comment.