Skip to content

Commit

Permalink
Merge pull request #4 from CommonGateway/feature/NH-3/nationaliteit
Browse files Browse the repository at this point in the history
Check field nationality
  • Loading branch information
smisidjan authored Sep 1, 2023
2 parents 00c5724 + 57f3f47 commit f14ffd5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Installation/Mapping/stuf.haalCentraalToLa01.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "haalCentraalToLa01",
"$id": "https://commongateway.nl/mapping/stuf.haalCentraalToLa01.mapping.json",
"$schema": "https://docs.commongateway.nl/schemas/Mapping.schema.json",
"version": "0.0.2",
"version": "0.0.3",
"passTrough": false,
"mapping": {
"@xmlns": "http://www.egem.nl/StUF/sector/bg/0310",
Expand Down Expand Up @@ -38,6 +38,7 @@
"SOAP-ENV:Body.npsLa01-prs-GezinssituatieOpAdresAanvrager.antwoord.object.geboortedatum": "geboorte.datum.datum",
"SOAP-ENV:Body.npsLa01-prs-GezinssituatieOpAdresAanvrager.antwoord.object.inp.geboorteplaats": "geboorte.plaats.code",
"SOAP-ENV:Body.npsLa01-prs-GezinssituatieOpAdresAanvrager.antwoord.object.inp.geboorteLand": "geboorte.land.code",
"SOAP-ENV:Body.npsLa01-prs-GezinssituatieOpAdresAanvrager.antwoord.object.nederlandseNationaliteit": "nederlandseNationaliteit",
"SOAP-ENV:Body.npsLa01-prs-GezinssituatieOpAdresAanvrager.antwoord.object.overlijdensdatum": "",
"SOAP-ENV:Body.npsLa01-prs-GezinssituatieOpAdresAanvrager.antwoord.object.verblijfsadres.@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
"SOAP-ENV:Body.npsLa01-prs-GezinssituatieOpAdresAanvrager.antwoord.object.verblijfsadres.@xmlns:StUF": "http://www.egem.nl/StUF/StUF0301",
Expand Down
34 changes: 31 additions & 3 deletions src/Service/HaalCentraalToStufBGService.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,31 @@ public function getAllRelatives(Source $source, array $ingeschrevenPersoon): ?ar
}//end getAllRelatives()


/**
* Checks if the nationality of the ingeschreven persoon is Dutch.
*
* @param array $ingeschrevenPersoon Already fetched ingeschrevenPersoon to check the nationality.
*
* @return array|null If the nationality of a ingeschreven persoon is Dutch.
*/
public function checkDutchNationality(array $ingeschrevenPersoon): ?array
{
// Set the nationality default on false.
$dutchNationality = "false";
foreach ($ingeschrevenPersoon['nationaliteiten'] as $nationality) {
// If the omschrijving is 'Nederlandse' or the code is '0001' then set the bool to true.
if ($nationality['nationaliteit']['omschrijving'] === 'Nederlandse'
|| $nationality['nationaliteit']['code'] === '0001'
) {
$dutchNationality = "true";
}
}

return ['nederlandseNationaliteit' => $dutchNationality];

}//end checkDutchNationality()


/**
* An haalCentraal to stuf BG handler that is triggered by an action.
*
Expand Down Expand Up @@ -182,11 +207,14 @@ public function haalCentraalToStufBGHandler(array $data, array $configuration):
// 3. Check partners, parents and children. Fetch those.
$allRelatives = $this->getAllRelatives($source, $ingeschrevenPersoon);

// 4. Map them together into a stuf response.
$allRelatives = array_merge($allRelatives, $ingeschrevenPersoon, ['referentienummer' => $referentienummer]);
// 4. Check if the nationality of the ingeschrevenpersoon is Dutch.
$nationality = $this->checkDutchNationality($ingeschrevenPersoon);

// 5. Map them together into a stuf response.
$allRelatives = array_merge($nationality, $allRelatives, $ingeschrevenPersoon, ['referentienummer' => $referentienummer]);

Check warning on line 214 in src/Service/HaalCentraalToStufBGService.php

View workflow job for this annotation

GitHub Actions / build

Line exceeds 125 characters; contains 136 characters
$mappedAllRelatives = $this->mappingService->mapping($mapping, $allRelatives);

// 5. Create response
// 6. Create response
$xmlEncoder = new XmlEncoder(['xml_root_node_name' => 'SOAP-ENV:Envelope']);
$xmlString = $xmlEncoder->encode($mappedAllRelatives, 'xml', ['xml_encoding' => 'utf-8', 'remove_empty_tags' => true]);

Check warning on line 219 in src/Service/HaalCentraalToStufBGService.php

View workflow job for this annotation

GitHub Actions / build

Line exceeds 125 characters; contains 128 characters

Expand Down

0 comments on commit f14ffd5

Please sign in to comment.