Skip to content

Commit

Permalink
[#262] Add partijIdentificatoren to the expand options for Partij
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmursa-dev committed Feb 28, 2025
1 parent 1e01be8 commit e6f410b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ class PartijSerializer(NestedGegevensGroepMixin, PolymorphicSerializer):
"digitale_adressen": f"{SERIALIZER_PATH}.digitaal_adres.DigitaalAdresSerializer",
"betrokkenen": f"{SERIALIZER_PATH}.klantcontacten.BetrokkeneSerializer",
"categorie_relaties": f"{SERIALIZER_PATH}.partijen.CategorieRelatieSerializer",
"partij_identificatoren": f"{SERIALIZER_PATH}.partijen.PartijIdentificatorSerializer",
# 2 levels
"betrokkenen.had_klantcontact": f"{SERIALIZER_PATH}.klantcontacten.KlantcontactSerializer",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,54 @@ def _get_detail_url(partij: Partij) -> str:
received_adressen[0]["url"], f"http://testserver{expected_url}"
)

def test_partij_identificator_inclusion_param(self):
partij = PartijFactory.create()
detail_url = reverse(
"klantinteracties:partij-detail", kwargs={"uuid": str(partij.uuid)}
)

response = self.client.get(detail_url, data={"expand": "partijIdentificatoren"})
self.assertEqual(response.status_code, status.HTTP_200_OK)
response_data = response.json()

self.assertEqual(partij.partijidentificator_set.count(), 0)
self.assertEqual(response_data["_expand"], {"partijIdentificatoren": []})

partij_identificator = PartijIdentificator.objects.create(
partij=partij,
partij_identificator_code_objecttype="natuurlijk_persoon",
partij_identificator_code_soort_object_id="bsn",
partij_identificator_object_id="296648875",
partij_identificator_code_register="brp",
)

response = self.client.get(detail_url, data={"expand": "partijIdentificatoren"})
self.assertEqual(response.status_code, status.HTTP_200_OK)
response_data = response.json()

self.assertEqual(len(partij_identificatoren), 1)
partij_identificatoren = response_data["_expand"]["partijIdentificatoren"]
test_url = "http://testserver/klantinteracties/api/v1"
self.assertEqual(
partij_identificatoren[0],
{
"uuid": str(partij_identificator.uuid),
"url": f"{test_url}/partij-identificatoren/{str(partij_identificator.uuid)}",
"identificeerdePartij": {
"uuid": str(partij.uuid),
"url": f"{test_url}/partijen/{str(partij.uuid)}",
},
"anderePartijIdentificator": "",
"partijIdentificator": {
"codeObjecttype": "natuurlijk_persoon",
"codeSoortObjectId": "bsn",
"objectId": "296648875",
"codeRegister": "brp",
},
"subIdentificatorVan": None,
},
)


class PartijIdentificatorTests(APITestCase):
def test_list_partij_identificator(self):
Expand Down
18 changes: 16 additions & 2 deletions src/openklant/components/klantinteracties/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,7 @@ paths:
- betrokkenen.hadKlantcontact
- categorieRelaties
- digitaleAdressen
- partijIdentificatoren
description: |+
Sluit de gespecifieerde gerelateerde resources in in het antwoord.
Expand Down Expand Up @@ -2432,6 +2433,7 @@ paths:
- betrokkenen.hadKlantcontact
- categorieRelaties
- digitaleAdressen
- partijIdentificatoren
description: |+
Sluit de gespecifieerde gerelateerde resources in in het antwoord.
Expand Down Expand Up @@ -3819,6 +3821,12 @@ components:
readOnly: true
description: 'De Categorie relaties van een partij: Let op: Dit attribuut
is EXPERIMENTEEL.'
partij_identificatoren:
type: array
items:
$ref: '#/components/schemas/PartijIdentificator'
readOnly: true
description: Partij-identificatoren die hoorde bij deze partij.
GeautomatiseerdeActor:
type: object
properties:
Expand Down Expand Up @@ -4758,7 +4766,10 @@ components:
allOf:
- $ref: '#/components/schemas/PartijIdentificatorForeignkey'
nullable: true
description: Relatie sub_identificator_van
description: The parent PartijIdentificator under which this PartijIdentificator
is unique (e.g. the parent identificator could specify a KVK number and
the child identificator could specify a vestigingsnummer that is unique
for the KVK number).
required:
- identificeerdePartij
- partijIdentificator
Expand Down Expand Up @@ -5310,7 +5321,10 @@ components:
allOf:
- $ref: '#/components/schemas/PartijIdentificatorForeignkey'
nullable: true
description: Relatie sub_identificator_van
description: The parent PartijIdentificator under which this PartijIdentificator
is unique (e.g. the parent identificator could specify a KVK number and
the child identificator could specify a vestigingsnummer that is unique
for the KVK number).
PatchedRekeningnummer:
type: object
properties:
Expand Down

0 comments on commit e6f410b

Please sign in to comment.