|
1 | | -from kikinzage.client.base import BaseClient |
| 1 | +from typing import Any |
| 2 | +from typing import Literal |
| 3 | +from typing import Optional |
| 4 | +from typing import Type |
| 5 | +from typing import Union |
2 | 6 |
|
| 7 | +import httpx |
| 8 | +from httpx import USE_CLIENT_DEFAULT |
| 9 | +from httpx._client import UseClientDefault |
3 | 10 |
|
4 | | -class AsyncClient(BaseClient): |
| 11 | +from .. import models |
| 12 | +from ..models import Formaat |
| 13 | +from ..models import ResponseType |
| 14 | +from .base import KikinzageBaseClient |
| 15 | + |
| 16 | + |
| 17 | +FormaatDefault: Literal["FormaatFormaatDefault"] = "FormaatFormaatDefault" |
| 18 | +Klantreferentie: Literal["Klantreferentie"] = "Klantreferentie" |
| 19 | + |
| 20 | + |
| 21 | +class AsyncClient(KikinzageBaseClient): |
5 | 22 | """Client for async requests""" |
| 23 | + |
| 24 | + client: httpx.AsyncClient |
| 25 | + |
| 26 | + def __init__( |
| 27 | + self, |
| 28 | + username: str, |
| 29 | + password: str, |
| 30 | + base_url: str = "https://service10.kadaster.nl/kik-inzage-eto/v6/", |
| 31 | + formaat: Formaat = Formaat.JSON, |
| 32 | + klantreferentie: Optional[str] = None, |
| 33 | + gebruikeridentificatie: Optional[str] = None, |
| 34 | + hyperlinkopproduct: Optional[bool] = None, |
| 35 | + inkoopnummer: Optional[str] = None, |
| 36 | + referentienummer: Optional[str] = None, |
| 37 | + **httpx_kwargs: Any, |
| 38 | + ) -> None: |
| 39 | + super().__init__( |
| 40 | + username=username, |
| 41 | + password=password, |
| 42 | + base_url=base_url, |
| 43 | + formaat=formaat, |
| 44 | + klantreferentie=klantreferentie, |
| 45 | + gebruikeridentificatie=gebruikeridentificatie, |
| 46 | + hyperlinkopproduct=hyperlinkopproduct, |
| 47 | + inkoopnummer=inkoopnummer, |
| 48 | + referentienummer=referentienummer, |
| 49 | + ) |
| 50 | + |
| 51 | + httpx_kwargs.setdefault("base_url", base_url) |
| 52 | + httpx_kwargs.setdefault("auth", (self.username, self.password)) |
| 53 | + |
| 54 | + self.client = self.create_client(**httpx_kwargs) |
| 55 | + |
| 56 | + def create_client(self, **httpx_kwargs: Any) -> httpx.AsyncClient: |
| 57 | + return httpx.AsyncClient(**httpx_kwargs) |
| 58 | + |
| 59 | + async def eigendomsinformatie_kadastraalobjectidentificatie_get( |
| 60 | + self, |
| 61 | + kadastraalobjectidentificatie: str, |
| 62 | + formaat: Union[Formaat, UseClientDefault] = USE_CLIENT_DEFAULT, |
| 63 | + klantreferentie: Union[str, UseClientDefault] = USE_CLIENT_DEFAULT, |
| 64 | + gebruikeridentificatie: Optional[str] = None, |
| 65 | + hyperlinkopproduct: Optional[bool] = None, |
| 66 | + inkoopnummer: Optional[str] = None, |
| 67 | + referentienummer: Optional[str] = None, |
| 68 | + ) -> models.Eigendomsinformatie: |
| 69 | + """GET /eigendomsinformatie/kadastraalobjectidentificatie/{kadastraalobjectidentificatie}""" |
| 70 | + |
| 71 | + request = self.request_eigendomsinformatie_kadastraalobjectidentificatie( |
| 72 | + kadastraalobjectidentificatie=kadastraalobjectidentificatie, |
| 73 | + formaat=formaat, |
| 74 | + klantreferentie=klantreferentie, |
| 75 | + gebruikeridentificatie=gebruikeridentificatie, |
| 76 | + hyperlinkopproduct=hyperlinkopproduct, |
| 77 | + inkoopnummer=inkoopnummer, |
| 78 | + referentienummer=referentienummer, |
| 79 | + ) |
| 80 | + |
| 81 | + return await self.send(request, models.Eigendomsinformatie) |
| 82 | + |
| 83 | + async def send( |
| 84 | + self, |
| 85 | + request: httpx.Request, |
| 86 | + model: Type[ResponseType], |
| 87 | + status_code_success: int = 200, |
| 88 | + ) -> ResponseType: |
| 89 | + response = await self.client.send(request) |
| 90 | + |
| 91 | + return self.process_response(response, model, status_code_success) |
0 commit comments