Commit 0fa62904 authored by Jo Sama's avatar Jo Sama 😱
Browse files

Add list and create methods for ExtraA

parent 7c296bac
......@@ -7,7 +7,8 @@ from typing import Optional, List, Iterator, Union
from urllib.parse import urljoin, urlparse
from .models import (Branch, BranchReference, Operator, OperatorGroup, PermissionGroup,
Person, Department, DepartmentRef, BudgetHolder, BudgetHolderRef)
Person, Department, DepartmentRef, BudgetHolder, BudgetHolderRef,
ExtraA, ExtraARef)
logger = logging.getLogger(__name__)
......@@ -67,6 +68,9 @@ class Endpoints:
operator_id + '/'),
def get_extra_fields_a(self):
return self._prepend_base_url('personExtraFieldAEntries/')
class TopDeskClient:
def __init__(self,
......@@ -421,5 +425,25 @@ class TopDeskClient:
def list_extra_fields_a(self) -> List[ExtraARef]:
r = self.get(self.urls.get_extra_fields_a(), return_response=True)
if r.status_code == 200:
return [ExtraARef.from_dict(x) for x in r.json()]
return None
def create_extra_fields_a(self, extra_a: ExtraA) -> List[ExtraA]:
r =,
headers={'Content-Type': 'application/json'},
if r.status_code == 201:
return ExtraA.from_dict(r.json())
return None
def get_client(config):
return TopDeskClient(**config)
......@@ -249,6 +249,25 @@ class BudgetHolderRef(BaseModel):
kwargs['include'] = {'id'}
return super().dict(*args, **kwargs)
class ExtraA(BaseModel):
id: Optional[str]
name: str
externalLink: List[ExternalLink] = []
def dict(self, *args, **kwargs):
kwargs['exclude'] = {'id'}
return super().dict(*args, **kwargs)
class ExtraARef(BaseModel):
id: str
name: Optional[str]
def dict(self, *args, **kwargs):
kwargs['include'] = {'id'}
return super().dict(*args, **kwargs)
class Person(BaseModel):
id: Optional[str]
......@@ -266,6 +285,7 @@ class Person(BaseModel):
department: Optional[DepartmentRef]
budgetHolder: Optional[BudgetHolderRef]
jobTitle: Optional[str]
personExtraFieldA: Optional[ExtraARef]
class Config:
fields = {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment