-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1404 from maykinmedia/tasks/2758-expand-openklant…
…2-resources [#2758] Add the KlantContact and related resources to the openklant2 client
- Loading branch information
Showing
81 changed files
with
27,311 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import uuid | ||
from typing import cast | ||
|
||
from ape_pie import APIClient | ||
|
||
from openklant2._resources.base import ResourceMixin | ||
from openklant2.types.pagination import PaginatedResponseBody | ||
from openklant2.types.resources.actor import Actor, ActorListParams, CreateActorData | ||
|
||
|
||
class ActorResource(ResourceMixin): | ||
http_client: APIClient | ||
base_path: str = "/actoren" | ||
|
||
def create( | ||
self, | ||
*, | ||
data: CreateActorData, | ||
) -> Actor: | ||
response = self._post(self.base_path, data=data) | ||
return cast(Actor, self.process_response(response)) | ||
|
||
def retrieve(self, /, uuid: str | uuid.UUID) -> Actor: | ||
response = self._get(f"{self.base_path}/{str(uuid)}") | ||
return cast(Actor, self.process_response(response)) | ||
|
||
def list( | ||
self, *, params: ActorListParams | None = None | ||
) -> PaginatedResponseBody[Actor]: | ||
response = self._get(f"{self.base_path}", params=params) | ||
return cast( | ||
PaginatedResponseBody[Actor], | ||
self.process_response(response), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import uuid | ||
from typing import cast | ||
|
||
from ape_pie import APIClient | ||
|
||
from openklant2._resources.base import ResourceMixin | ||
from openklant2.types.pagination import PaginatedResponseBody | ||
from openklant2.types.resources.betrokkene import Betrokkene, BetrokkeneCreateData | ||
|
||
|
||
class BetrokkeneResource(ResourceMixin): | ||
http_client: APIClient | ||
base_path: str = "/betrokkenen" | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.list_iter = self._make_list_iter(self.list) | ||
|
||
def create( | ||
self, | ||
*, | ||
data: BetrokkeneCreateData, | ||
) -> Betrokkene: | ||
response = self._post(self.base_path, data=data) | ||
return cast(Betrokkene, self.process_response(response)) | ||
|
||
def retrieve(self, /, uuid: str | uuid.UUID) -> Betrokkene: | ||
response = self._get(f"{self.base_path}/{str(uuid)}") | ||
return cast(Betrokkene, self.process_response(response)) | ||
|
||
def list(self) -> PaginatedResponseBody[Betrokkene]: | ||
response = self._get(f"{self.base_path}") | ||
return cast( | ||
PaginatedResponseBody[Betrokkene], | ||
self.process_response(response), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import uuid | ||
from typing import cast | ||
|
||
from ape_pie import APIClient | ||
|
||
from openklant2._resources.base import ResourceMixin | ||
from openklant2.types.pagination import PaginatedResponseBody | ||
from openklant2.types.resources.interne_taak import CreateInterneTaakData, InterneTaak | ||
|
||
|
||
class InterneTaakResource(ResourceMixin): | ||
http_client: APIClient | ||
base_path: str = "/internetaken" | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.list_iter = self._make_list_iter(self.list) | ||
|
||
def create( | ||
self, | ||
*, | ||
data: CreateInterneTaakData, | ||
) -> InterneTaak: | ||
response = self._post(self.base_path, data=data) | ||
return cast(InterneTaak, self.process_response(response)) | ||
|
||
def retrieve(self, /, uuid: str | uuid.UUID) -> InterneTaak: | ||
response = self._get(f"{self.base_path}/{str(uuid)}") | ||
return cast(InterneTaak, self.process_response(response)) | ||
|
||
def list(self) -> PaginatedResponseBody[InterneTaak]: | ||
response = self._get(f"{self.base_path}") | ||
return cast( | ||
PaginatedResponseBody[InterneTaak], | ||
self.process_response(response), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import uuid | ||
from typing import cast | ||
|
||
from ape_pie import APIClient | ||
|
||
from openklant2._resources.base import ResourceMixin | ||
from openklant2.types.pagination import PaginatedResponseBody | ||
from openklant2.types.resources.klant_contact import ( | ||
CreateKlantContactData, | ||
KlantContact, | ||
ListKlantContactParams, | ||
RetrieveKlantContactParams, | ||
) | ||
|
||
|
||
class KlantContactResource(ResourceMixin): | ||
http_client: APIClient | ||
base_path: str = "/klantcontacten" | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.list_iter = self._make_list_iter(self.list) | ||
|
||
def create( | ||
self, | ||
*, | ||
data: CreateKlantContactData, | ||
) -> KlantContact: | ||
response = self._post(self.base_path, data=data) | ||
return cast(KlantContact, self.process_response(response)) | ||
|
||
def retrieve( | ||
self, | ||
/, | ||
uuid: str | uuid.UUID, | ||
*, | ||
params: RetrieveKlantContactParams | None = None, | ||
) -> KlantContact: | ||
response = self._get(f"{self.base_path}/{str(uuid)}", params=params) | ||
return cast(KlantContact, self.process_response(response)) | ||
|
||
def list( | ||
self, *, params: ListKlantContactParams | None = None | ||
) -> PaginatedResponseBody[KlantContact]: | ||
response = self._get(f"{self.base_path}", params=params) | ||
return cast( | ||
PaginatedResponseBody[KlantContact], | ||
self.process_response(response), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import uuid | ||
from typing import cast | ||
|
||
from ape_pie import APIClient | ||
|
||
from openklant2._resources.base import ResourceMixin | ||
from openklant2.types.pagination import PaginatedResponseBody | ||
from openklant2.types.resources.onderwerp_object import ( | ||
CreateOnderwerpObjectData, | ||
OnderwerpObject, | ||
OnderwerpobjectIdentificatorListParams, | ||
) | ||
|
||
|
||
class OnderwerpObjectResource(ResourceMixin): | ||
http_client: APIClient | ||
base_path: str = "/onderwerpobjecten" | ||
|
||
def create( | ||
self, | ||
*, | ||
data: CreateOnderwerpObjectData, | ||
) -> OnderwerpObject: | ||
response = self._post(self.base_path, data=data) | ||
return cast(OnderwerpObject, self.process_response(response)) | ||
|
||
def retrieve(self, /, uuid: str | uuid.UUID) -> OnderwerpObject: | ||
response = self._get(f"{self.base_path}/{str(uuid)}") | ||
return cast(OnderwerpObject, self.process_response(response)) | ||
|
||
def list( | ||
self, *, params: OnderwerpobjectIdentificatorListParams | None = None | ||
) -> PaginatedResponseBody[OnderwerpObject]: | ||
response = self._get(f"{self.base_path}", params=params) | ||
return cast( | ||
PaginatedResponseBody[OnderwerpObject], | ||
self.process_response(response), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import factory | ||
import factory.fuzzy | ||
|
||
from openklant2.factories.common import IdentificationNumber | ||
from openklant2.factories.helpers import validator | ||
from openklant2.types.resources.actor import CreateActorDataValidator | ||
|
||
|
||
class ActorIdentificatorFactory(factory.Factory): | ||
class Meta: | ||
model = dict | ||
|
||
objectId = IdentificationNumber() | ||
codeObjecttype = factory.Faker("word") | ||
codeRegister = factory.Faker("word") | ||
codeSoortObjectId = factory.Faker("word") | ||
|
||
|
||
@validator(CreateActorDataValidator) | ||
class CreateActorDataFactory(factory.Factory): | ||
class Meta: | ||
model = dict | ||
|
||
naam = factory.Faker("name") | ||
soortActor = factory.fuzzy.FuzzyChoice( | ||
["medewerker", "geautomatiseerde_actor", "organisatorische_eenheid"] | ||
) | ||
indicatieActief = True | ||
actoridentificator = factory.SubFactory(ActorIdentificatorFactory) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import factory | ||
import factory.faker | ||
import factory.fuzzy | ||
|
||
from openklant2.factories.common import ForeignKeyRef | ||
from openklant2.factories.helpers import FuzzyLiteral, validator | ||
from openklant2.types.resources.betrokkene import ( | ||
BetrokkeneCreateDataValidator, | ||
BetrokkeneRol, | ||
) | ||
|
||
|
||
class ContactnaamFactory(factory.Factory): | ||
class Meta: | ||
model = dict | ||
|
||
voorletters = factory.Faker("prefix") | ||
voornaam = factory.Faker("first_name") | ||
voorvoegselAchternaam = factory.Faker("prefix") | ||
achternaam = factory.Faker("last_name") | ||
|
||
|
||
@validator(BetrokkeneCreateDataValidator) | ||
class BetrokkeneCreateDataFactory(factory.Factory): | ||
class Meta: | ||
model = dict | ||
|
||
wasPartij = factory.SubFactory(ForeignKeyRef) | ||
hadKlantcontact = factory.SubFactory(ForeignKeyRef) | ||
bezoekadres = None | ||
correspondentieadres = None | ||
contactnaam = factory.SubFactory(ContactnaamFactory) | ||
rol = FuzzyLiteral(BetrokkeneRol) | ||
organisatienaam = factory.Faker("company") | ||
initiator = factory.fuzzy.FuzzyChoice((True, False)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.