Commit aa749ca4 authored by Jonas Braathen's avatar Jonas Braathen
Browse files

Add models related to branches

parent b1e38a9b
from enum import Enum
import datetime
import json
import pydantic
from typing import List
from typing import List, Optional
class BaseModel(pydantic.BaseModel):
......@@ -15,14 +17,128 @@ class BaseModel(pydantic.BaseModel):
return cls.from_dict(data)
class Identifier(BaseModel):
""" An object with only an ID that references some entity. """
id: str
class Reference(BaseModel):
""" Also called a searchlist. """
id: str
name: str
class OptionalFields(BaseModel):
""" An abomination. """
boolean1: Optional[bool]
boolean2: Optional[bool]
boolean3: Optional[bool]
boolean4: Optional[bool]
boolean5: Optional[bool]
number1: Optional[int]
number2: Optional[int]
number3: Optional[int]
number4: Optional[int]
number5: Optional[int]
date1: Optional[datetime.datetime]
date2: Optional[datetime.datetime]
date3: Optional[datetime.datetime]
date4: Optional[datetime.datetime]
date5: Optional[datetime.datetime]
text1: Optional[str]
text2: Optional[str]
text3: Optional[str]
text4: Optional[str]
text5: Optional[str]
searchlist1: Optional[Reference]
searchlist2: Optional[Reference]
searchlist3: Optional[Reference]
searchlist4: Optional[Reference]
searchlist5: Optional[Reference]
class AddressTypeEnum(str, Enum):
gb = 'GB'
nl = 'NL'
memo = 'MEMO'
class Address(BaseModel):
street: str
number: str
country: Reference
city: str
county: str
postcode: str
memo: str
type: AddressTypeEnum
class Config:
fields = {
'memo': {'alias': 'addressMemo'},
'type': {'alias': 'addressType'},
}
class BranchTypeEnum(str, Enum):
independent = 'independentBranch'
head = 'headBranch'
has_a_head = 'hasAHeadBranch'
class Branch(BaseModel):
identity: str
id: str
name: str
specification: str
client_reference_number: str
timezone: str
extra_a: Reference
extra_b: Reference
phone: str
fax: str
address: Address
postal_address: Address
email: str
website: str
type: BranchTypeEnum
head_branch: Identifier
creator: Reference
creationDate: datetime.datetime
modificationDate: datetime.datetime
modifier: Reference
optional_fields_1: OptionalFields
optional_fields_2: OptionalFields
class Config:
fields = {
'client_reference_number': {'alias': 'clientReferenceNumber'},
'timezone': {'alias': 'timeZone'},
'extra_a': {'alias': 'extraA'},
'extra_b': {'alias': 'extraB'},
'postal_address': {'alias': 'postalAddress'},
'type': {'alias': 'branchType'},
'head_branch': {'alias': 'headBranch'},
'optional_fields_1': {'alias': 'optionalFields1'},
'optional_fields_2': {'alias': 'optionalFields2'},
'created': {'alias': 'creationDate'},
'modified': {'alias': 'modificationDate'},
}
class BranchReference(BaseModel):
id: str
name: str
client_reference_number: str
timezone: str
extra_a: Reference
extra_b: Reference
class Config:
fields = {
'identity': {'alias': 'id'},
'name': {'alias': 'name'}
'client_reference_number': {'alias': 'clientReferenceNumber'},
'timezone': {'alias': 'timeZone'},
'extra_a': {'alias': 'extraA'},
'extra_b': {'alias': 'extraB'},
}
......@@ -33,7 +149,7 @@ class Operator(BaseModel):
phone: str
mobile: str
email: pydantic.EmailStr
branch: Branch
branch: BranchReference
class Config:
fields = {
......@@ -42,6 +158,4 @@ class Operator(BaseModel):
'user_name': {'alias': 'loginName'},
'phone': {'alias': 'telephone'},
'mobile': {'alias': 'mobileNumber'},
'email': {'alias': 'email'},
'branch': {'alias': 'branch'}
}
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