Skip to content

Commit ad85b29

Browse files
👌 fix: use client for base path generation and uuid extraction
1 parent 279caf2 commit ad85b29

File tree

1 file changed

+5
-9
lines changed
  • backend/src/openbeheer/catalogi/api

1 file changed

+5
-9
lines changed

backend/src/openbeheer/catalogi/api/views.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class CatalogChoicesView(MsgspecAPIView):
5757
def get(self, request: Request, slug: str) -> Response:
5858
# TODO for now, we only support one Open Zaak, so the slug
5959
# is not used.
60-
client = ztc_client()
60+
client = ztc_client(slug)
6161

6262
response = client.get("catalogussen")
6363
# TODO error handling on OZ unexpected response (Github #51)
@@ -81,14 +81,10 @@ def get(self, request: Request, slug: str) -> Response:
8181
# OZ API specs say that url is not required, but VNG specs say it is.
8282
# In practice, it is always present.
8383
url = catalogue.url
84+
path = f"{client.base_url}catalogussen/"
85+
uuid = url.removeprefix(path)
86+
assert uuid
8487

85-
# Extract the UUID by removing service API root and known endpoint.
86-
# We only support 1 ZTC for now.
87-
# TODO: Provide util for this?
88-
service = Service.objects.get(api_type=APITypes.ztc)
89-
value = url.removeprefix(service.api_root + "catalogussen/")
90-
assert value
91-
92-
results.append(OBOption(label=label, value=value))
88+
results.append(OBOption(label=label, value=uuid))
9389

9490
return Response(results)

0 commit comments

Comments
 (0)