new api service and logic implemented

This commit is contained in:
2025-01-23 22:27:25 +03:00
parent d91ecda9df
commit 32022ca521
245 changed files with 28004 additions and 0 deletions

View File

@@ -0,0 +1,121 @@
import enum
from typing import Optional, List, Any
from pydantic import BaseModel
# Company / Priority / Department / Duty / Employee / Occupant / Module / Endpoint are changeable dynamics
class UserType(enum.Enum):
employee = 1
occupant = 2
class Credentials(BaseModel):
person_id: int
person_name: str
class ApplicationToken(BaseModel):
# Application Token Object -> is the main object for the user
domain: Optional[str] = "app.evyos.com.tr"
lang: Optional[str] = "TR"
timezone: Optional[str] = "GMT+3"
user_type: int = UserType.occupant.value
credentials: dict = None
user_uu_id: str
user_id: int
person_id: int
person_uu_id: str
request: Optional[dict] = None # Request Info of Client
expires_at: Optional[float] = None # Expiry timestamp
class OccupantToken(BaseModel):
# Selection of the occupant type for a build part is made by the user
living_space_id: int # Internal use
living_space_uu_id: str # Outer use
occupant_type_id: int
occupant_type_uu_id: str
occupant_type: str
build_id: int
build_uuid: str
build_part_id: int
build_part_uuid: str
responsible_company_id: Optional[int] = None
responsible_company_uuid: Optional[str] = None
responsible_employee_id: Optional[int] = None
responsible_employee_uuid: Optional[str] = None
reachable_event_codes: Optional[list[str]] = None # ID list of reachable modules
reachable_event_endpoints: Optional[list[str]] = None
class CompanyToken(BaseModel): # Required Company Object for an employee
company_id: int
company_uu_id: str
department_id: int # ID list of departments
department_uu_id: str # ID list of departments
duty_id: int
duty_uu_id: str
staff_id: int
staff_uu_id: str
employee_id: int
employee_uu_id: str
bulk_duties_id: int
reachable_event_codes: Optional[list[str]] = None # ID list of reachable modules
reachable_event_endpoints: Optional[list[str]] = None
class OccupantTokenObject(ApplicationToken):
# Occupant Token Object -> Requires selection of the occupant type for a specific build part
available_occupants: dict = None
selected_occupant: Optional[OccupantToken] = None # Selected Occupant Type
@property
def is_employee(self) -> bool:
return False
@property
def is_occupant(self) -> bool:
return True
class EmployeeTokenObject(ApplicationToken):
# Full hierarchy Employee[staff_id] -> Staff -> Duty -> Department -> Company
companies_id_list: List[int] # List of company objects
companies_uu_id_list: List[str] # List of company objects
duty_id_list: List[int] # List of duty objects
duty_uu_id_list: List[str] # List of duty objects
selected_company: Optional[CompanyToken] = None # Selected Company Object
@property
def is_employee(self) -> bool:
return True
@property
def is_occupant(self) -> bool:
return False

View File

@@ -0,0 +1,83 @@
import json
from typing import Any, ClassVar, TypeVar, Dict, Tuple, List
from pydantic import BaseModel
from ErrorHandlers import HTTPExceptionApi
from ApiLibrary.common.line_number import get_line_number_for_error
from ApiValidations.Request.base_validations import CrudRecords, PydanticBaseModel
class ValidationParser:
def __init__(self, active_validation: BaseModel):
self.core_validation = active_validation
self.annotations = active_validation.model_json_schema()
self.annotations = json.loads(json.dumps(self.annotations))
self.schema = {}
self.parse()
def parse(self):
from ApiValidations.Request.base_validations import (
CrudRecords,
PydanticBaseModel,
)
properties = dict(self.annotations.get("properties")).items()
total_class_annotations = {
**self.core_validation.__annotations__,
**PydanticBaseModel.__annotations__,
**CrudRecords.__annotations__,
}
for key, value in properties:
default, required, possible_types = (
dict(value).get("default", None),
True,
[],
)
if dict(value).get("anyOf", None):
for _ in dict(value).get("anyOf") or []:
type_opt = json.loads(json.dumps(_))
if not type_opt.get("type") == "null":
possible_types.append(type_opt.get("type"))
field_type = possible_types[0]
required = False
else:
field_type = dict(value).get("type", "string")
attribute_of_class = total_class_annotations.get(key, None)
aoc = str(attribute_of_class) if attribute_of_class else None
if attribute_of_class:
if aoc in ("<class 'str'>", "typing.Optional[str]"):
field_type, required = "string", aoc == "<class 'str'>"
elif aoc in ("<class 'int'>", "typing.Optional[int]"):
field_type, required = "integer", aoc == "<class 'int'>"
elif aoc in ("<class 'bool'>", "typing.Optional[bool]"):
field_type, required = "boolean", aoc == "<class 'bool'>"
elif aoc in ("<class 'float'>", "typing.Optional[float]"):
field_type, required = "float", aoc == "<class 'float'>"
elif aoc in (
"<class 'datetime.datetime'>",
"typing.Optional[datetime.datetime]",
):
field_type, required = (
"datetime",
aoc == "<class 'datetime.datetime'>",
)
self.schema[key] = {
"type": field_type,
"required": required,
"default": default,
}
class ValidationModel:
def __init__(self, response_model: BaseModel, language_model, language_models):
self.response_model = response_model
self.validation = None
self.headers = language_model
self.language_models = language_models
self.get_validation()
def get_validation(self) -> Tuple:
self.headers = self.language_models
self.validation = ValidationParser(self.response_model).schema

View File

@@ -0,0 +1,239 @@
from .base_validations import (
BaseModelRegular,
PydanticBaseModel,
ListOptions,
CrudRecords,
)
from .address import (
InsertAddress,
UpdateAddress,
UpdatePostCode,
InsertPostCode,
SearchAddress,
)
from .application import (
SingleEnumUUID,
SingleEnumClassKey,
SingleEnumOnlyClass,
SingleOccupantTypeUUID,
SingleOccupantTypeClassKey,
)
from .area import (
InsertBuildArea,
InsertBuildSites,
UpdateBuildArea,
UpdateBuildSites,
)
from .authentication import (
Login,
Logout,
ChangePassword,
Remember,
Forgot,
CreatePassword,
OccupantSelection,
EmployeeSelection,
)
from .account_records import (
InsertAccountRecord,
UpdateAccountRecord,
)
from .build_living_space import (
InsertBuildLivingSpace,
UpdateBuildLivingSpace,
)
from .build_part import (
InsertBuildParts,
InsertBuildTypes,
UpdateBuildParts,
UpdateBuildTypes,
)
from .building import (
InsertBuild,
UpdateBuild,
)
from .company import (
MatchCompany2Company,
InsertCompany,
UpdateCompany,
)
from .decision_book import (
DecisionBookDecisionBookInvitations,
DecisionBookDecisionBookInvitationsUpdate,
DecisionBookDecisionBookInvitationsAttend,
DecisionBookDecisionBookInvitationsAssign,
UpdateDecisionBook,
UpdateBuildDecisionBookItems,
UpdateBuildDecisionBookItemDebits,
InsertBuildDecisionBookItems,
InsertBuildDecisionBookItemDebits,
InsertDecisionBookCompleted,
InsertDecisionBook,
InsertDecisionBookPerson,
ListDecisionBook,
RemoveDecisionBookPerson,
)
from .departments import (
DepartmentsPydantic,
)
from .employee import (
InsertDuties,
UpdateDuties,
InsertEmployees,
SelectDuties,
UnBindEmployees2People,
BindEmployees2People,
UpdateCompanyEmployees,
InsertCompanyEmployees,
InsertCompanyEmployeesSalaries,
InsertCompanyDuty,
UpdateCompanyEmployeesSalaries,
UpdateCompanyDuty,
)
from .events import (
# CreateEvents,
RegisterEvents2Employee,
RegisterEvents2Occupant,
)
from .people import (
UpdatePerson,
InsertPerson,
)
from .project_decision_book import (
InsertBuildDecisionBookProjectItemDebits,
UpdateBuildDecisionBookProjectItemDebits,
InsertBuildDecisionBookProjects,
UpdateBuildDecisionBookProjects,
InsertBuildDecisionBookProjectPerson,
UpdateBuildDecisionBookProjectPerson,
InsertBuildDecisionBookProjectItems,
UpdateBuildDecisionBookProjectItems,
ApprovalsBuildDecisionBookProjects,
)
from .rules import (
UpdateEndpointAccess,
UpdateEndpointAccessList,
InsertEndpointAccess,
CheckEndpointAccess,
)
from .services import (
RegisterServices2Employee,
RegisterServices2Occupant,
)
from .staff import (
InsertStaff,
SelectStaff,
)
from .user import (
InsertUsers,
UpdateUsers,
QueryUsers,
# ActiveUsers,
# ListUsers,
# DeleteUsers,
)
from .modules import (
RegisterModules2Occupant,
RegisterModules2Employee,
)
__all__ = [
"BaseModelRegular",
"PydanticBaseModel",
"ListOptions",
"CrudRecords",
"ListOptions",
"CrudRecords",
"PydanticBaseModel",
"BaseModelRegular",
"InsertAddress",
"UpdateAddress",
"UpdatePostCode",
"InsertPostCode",
"SearchAddress",
"SingleEnumUUID",
"SingleEnumClassKey",
"SingleEnumOnlyClass",
"SingleOccupantTypeUUID",
"SingleOccupantTypeClassKey",
"InsertBuildArea",
"InsertBuildSites",
"UpdateBuildArea",
"UpdateBuildSites",
"Login",
"Logout",
"ChangePassword",
"Remember",
"Forgot",
"CreatePassword",
"OccupantSelection",
"EmployeeSelection",
"InsertAccountRecord",
"UpdateAccountRecord",
"InsertBuildLivingSpace",
"UpdateBuildLivingSpace",
"InsertBuildParts",
"InsertBuildTypes",
"UpdateBuildParts",
"UpdateBuildTypes",
"InsertBuild",
"UpdateBuild",
"MatchCompany2Company",
"InsertCompany",
"UpdateCompany",
"DecisionBookDecisionBookInvitations",
"DecisionBookDecisionBookInvitationsUpdate",
"DecisionBookDecisionBookInvitationsAttend",
"DecisionBookDecisionBookInvitationsAssign",
"UpdateDecisionBook",
"UpdateBuildDecisionBookItems",
"UpdateBuildDecisionBookItemDebits",
"InsertBuildDecisionBookItems",
"InsertBuildDecisionBookItemDebits",
"InsertDecisionBookCompleted",
"InsertDecisionBook",
"InsertDecisionBookPerson",
"ListDecisionBook",
"RemoveDecisionBookPerson",
"DepartmentsPydantic",
"InsertDuties",
"UpdateDuties",
"InsertEmployees",
"SelectDuties",
"UnBindEmployees2People",
"BindEmployees2People",
"UpdateCompanyEmployees",
"InsertCompanyEmployees",
"InsertCompanyEmployeesSalaries",
"InsertCompanyDuty",
"UpdateCompanyEmployeesSalaries",
"UpdateCompanyDuty",
"RegisterEvents2Employee",
"RegisterEvents2Occupant",
"UpdatePerson",
"InsertPerson",
"InsertBuildDecisionBookProjectItems",
"UpdateBuildDecisionBookProjectItems",
"ApprovalsBuildDecisionBookProjects",
"InsertBuildDecisionBookProjectItemDebits",
"UpdateBuildDecisionBookProjectItemDebits",
"InsertBuildDecisionBookProjects",
"UpdateBuildDecisionBookProjects",
"InsertBuildDecisionBookProjectPerson",
"UpdateBuildDecisionBookProjectPerson",
"UpdateEndpointAccess",
"UpdateEndpointAccessList",
"InsertEndpointAccess",
"CheckEndpointAccess",
"RegisterServices2Employee",
"RegisterServices2Occupant",
"InsertStaff",
"SelectStaff",
"InsertUsers",
"UpdateUsers",
"QueryUsers",
"RegisterModules2Occupant",
"RegisterModules2Employee",
]

View File

@@ -0,0 +1,159 @@
from ApiValidations.Request import BaseModelRegular, PydanticBaseModel
from typing import Optional
class AccountValidation:
tr = {
"iban": "IBAN Numarası",
"bank_date": "Bank Tarih",
"currency_value": "Para Değeri",
"bank_balance": "Banka Bakiye",
"currency": "Para Birimi",
"additional_balance": "Ek Bakiye",
"channel_branch": "Kanal Şubesi",
"process_name": "İşlem Adı",
"process_type": "İşlem Tipi",
"process_comment": "İşlem Yorum",
"bank_reference_code": "Banka Referans Kodu",
"add_comment_note": "Yorum Not",
"is_receipt_mail_send": "Fiş Mail Gönderildi",
"found_from": "Bulunduğu Yer",
"similarity": "Benzerlik",
"remainder_balance": "Kalan Bakiye",
"bank_date_y": "Bank Tarih Yıl",
"bank_date_m": "Bank Tarih Ay",
"bank_date_w": "Bank Tarih Hafta",
"bank_date_d": "Bank Tarih Gün",
"approving_accounting_record": "Onaylayan Muhasebe Kaydı",
"accounting_receipt_date": "Muhasebe Fiş Tarihi",
"accounting_receipt_number": "Muhasebe Fiş Numarası",
"approved_record": "Onaylanmış Kayıt",
"import_file_name": "İçe Aktarım Dosya Adı",
"receive_debit_uu_id": "Alacak UUID",
"budget_type_uu_id": "Bütçe Tipi UUID",
"company_uu_id": "Şirket UUID",
"send_company_uu_id": "Gönderen Şirket UUID",
"customer_id": "Müşteri ID",
"customer_uu_id": "Müşteri UUID",
"send_person_uu_id": "Gönderen Kişi UUID",
"approving_accounting_person_uu_id": "Onaylayan Muhasebe Kişi UUID",
"build_parts_uu_id": "Daire UUID",
"build_decision_book_uu_id": "Karar Defteri UUID",
}
en = {
"iban": "IBAN Number",
"bank_date": "Bank Date",
"currency_value": "Currency Value",
"bank_balance": "Bank Balance",
"currency": "Currency",
"additional_balance": "Additional Balance",
"channel_branch": "Channel Branch",
"process_name": "Process Name",
"process_type": "Process Type",
"process_comment": "Process Comment",
"bank_reference_code": "Bank Reference Code",
"add_comment_note": "Comment Note",
"is_receipt_mail_send": "Receipt Mail Send",
"found_from": "Found From",
"similarity": "Similarity",
"remainder_balance": "Remainder Balance",
"bank_date_y": "Bank Date Year",
"bank_date_m": "Bank Date Month",
"bank_date_w": "Bank Date Week",
"bank_date_d": "Bank Date Day",
"approving_accounting_record": "Approving Accounting Record",
"accounting_receipt_date": "Accounting Receipt Date",
"accounting_receipt_number": "Accounting Receipt Number",
"approved_record": "Approved Record",
"import_file_name": "Import File Name",
"receive_debit_uu_id": "Receive Debit UUID",
"budget_type_uu_id": "Budget Type UUID",
"company_uu_id": "Company UUID",
"send_company_uu_id": "Send Company UUID",
"customer_id": "Customer ID",
"customer_uu_id": "Customer UUID",
"send_person_uu_id": "Send Person UUID",
"approving_accounting_person_uu_id": "Approving Accounting Person UUID",
"build_parts_uu_id": "Build Parts UUID",
"build_decision_book_uu_id": "Build Decision Book UUID",
}
class InsertAccountRecord(BaseModelRegular, AccountValidation):
iban: str
bank_date: str
currency_value: float
bank_balance: float
currency: str
additional_balance: float
channel_branch: str
process_name: str
process_type: str
process_comment: str
bank_reference_code: str
add_comment_note: Optional[str] = None
is_receipt_mail_send: Optional[bool] = None
found_from: Optional[str] = None
similarity: Optional[float] = None
remainder_balance: Optional[float] = None
bank_date_y: Optional[int] = None
bank_date_m: Optional[int] = None
bank_date_w: Optional[int] = None
bank_date_d: Optional[int] = None
approving_accounting_record: Optional[bool] = None
accounting_receipt_date: Optional[str] = None
accounting_receipt_number: Optional[int] = None
approved_record: Optional[bool] = None
import_file_name: Optional[str] = None
# receive_debit_uu_id: Optional[str] = None
budget_type_uu_id: Optional[str] = None
company_uu_id: Optional[str] = None
send_company_uu_id: Optional[str] = None
customer_id: Optional[str] = None
customer_uu_id: Optional[str] = None
send_person_uu_id: Optional[str] = None
approving_accounting_person_uu_id: Optional[str] = None
build_parts_uu_id: Optional[str] = None
build_decision_book_uu_id: Optional[str] = None
class UpdateAccountRecord(PydanticBaseModel, AccountValidation):
iban: Optional[str] = None
bank_date: Optional[str] = None
currency_value: Optional[float] = None
bank_balance: Optional[float] = None
currency: Optional[str] = None
additional_balance: Optional[float] = None
channel_branch: Optional[str] = None
process_name: Optional[str] = None
process_type: Optional[str] = None
process_comment: Optional[str] = None
bank_reference_code: Optional[str] = None
add_comment_note: Optional[str] = None
is_receipt_mail_send: Optional[bool] = None
found_from: Optional[str] = None
similarity: Optional[float] = None
remainder_balance: Optional[float] = None
bank_date_y: Optional[int] = None
bank_date_m: Optional[int] = None
bank_date_w: Optional[int] = None
bank_date_d: Optional[int] = None
approving_accounting_record: Optional[bool] = None
accounting_receipt_date: Optional[str] = None
accounting_receipt_number: Optional[int] = None
approved_record: Optional[bool] = None
import_file_name: Optional[str] = None
receive_debit_uu_id: Optional[str] = None
budget_type_uu_id: Optional[str] = None
company_uu_id: Optional[str] = None
send_company_uu_id: Optional[str] = None
customer_id: Optional[str] = None
customer_uu_id: Optional[str] = None
send_person_uu_id: Optional[str] = None
approving_accounting_person_uu_id: Optional[str] = None
build_parts_uu_id: Optional[str] = None
build_decision_book_uu_id: Optional[str] = None

View File

@@ -0,0 +1,128 @@
from typing import Optional
from ApiValidations.Request import PydanticBaseModel, ListOptions
from ApiValidations.handler import BaseModelRegular
class PostCodeValidation:
tr = {
"post_code": "Posta Kodu",
"street_uu_id": "Sokak UUID",
}
en = {
"post_code": "Post Code",
"street_uu_id": "Street UUID",
}
class InsertPostCode(BaseModelRegular, PostCodeValidation):
street_uu_id: str
post_code: str
class UpdatePostCode(PydanticBaseModel, PostCodeValidation):
street_uu_id: Optional[str] = None
post_code: Optional[str] = None
class SearchAddressValidation:
tr = {
"search": "Ara",
"list_options": "Liste Seçenekleri",
}
en = {
"search": "Search",
"list_options": "List Options",
}
class SearchAddress(PydanticBaseModel, SearchAddressValidation):
search: str
list_options: ListOptions
class StreetValidation:
tr = {
"street_code": "Sokak Kodu",
"street_name": "Sokak Adı",
"postcode": "Posta Kodu",
"type_code": "Tip Kodu",
"type_description": "Tip Açıklaması",
"gov_code": "Devlet Kodu",
"address_geographic_uu_id": "Coğrafi UUID",
}
en = {
"street_code": "Street Code",
"street_name": "Street Name",
"postcode": "Post Code",
"type_code": "Type Code",
"type_description": "Type Description",
"gov_code": "Government Code",
"address_geographic_uu_id": "Address Geographic UUID",
}
class InsertStreet(PydanticBaseModel, StreetValidation):
street_code: str
street_name: str
postcode: str
type_code: Optional[str] = None
type_description: Optional[str] = None
gov_code: Optional[str] = None
address_geographic_uu_id: Optional[str] = None
class AddressValidation:
tr = {
"post_code_uu_id": "Posta Kodu UUID",
"comment_address": "Adres Yorumu",
"letter_address": "Mektup Adresi",
"build_number": "Bina Numarası",
"door_number": "Kapı Numarası",
"floor_number": "Kat Numarası",
"short_letter_address": "Kısa Mektup Adresi",
"latitude": "Enlem",
"longitude": "Boylam",
}
en = {
"post_code_uu_id": "Post Code UUID",
"comment_address": "Address Comment",
"letter_address": "Letter Address",
"build_number": "Build Number",
"door_number": "Door Number",
"floor_number": "Floor Number",
"short_letter_address": "Short Letter Address",
"latitude": "Latitude",
"longitude": "Longitude",
}
class InsertAddress(BaseModelRegular, AddressValidation):
post_code_uu_id: str
comment_address: Optional[str] = None
letter_address: Optional[str] = None
build_number: str
door_number: Optional[str] = None
floor_number: Optional[str] = None
short_letter_address: Optional[str] = None
latitude: Optional[float] = None
longitude: Optional[float] = None
class UpdateAddress(PydanticBaseModel, AddressValidation):
post_code_uu_id: Optional[str] = None
comment_address: Optional[str] = None
letter_address: Optional[str] = None
build_number: Optional[str] = None
door_number: Optional[str] = None
floor_number: Optional[str] = None
short_letter_address: Optional[str] = None
latitude: Optional[float] = None
longitude: Optional[float] = None

View File

@@ -0,0 +1,69 @@
from ApiValidations.Request import BaseModelRegular
class SingleEnumClassKeyValidation:
tr = {
"class_name": "Sınıf Adı",
"key_name": "Anahtar Adı",
}
en = {
"class_name": "Class Name",
"key_name": "Key Name",
}
class SingleEnumClassKey(BaseModelRegular):
class_name: str
key_name: str
class SingleEnumUUIDValidation:
tr = {
"uu_id": "UUID",
}
en = {
"uu_id": "UUID",
}
class SingleEnumUUID(BaseModelRegular):
uu_id: str
class SingleEnumOnlyClassValidation:
tr = {
"class_name": "Sınıf Adı",
}
en = {
"class_name": "Class Name",
}
class SingleEnumOnlyClass(BaseModelRegular):
class_name: str
class SingleOccupantTypeClassKeyValidation:
tr = {
"type_code": "Tip Kodu",
}
en = {
"type_code": "Type Code",
}
class SingleOccupantTypeClassKey(BaseModelRegular):
type_code: str
class SingleOccupantTypeUUIDValidation:
tr = {
"uu_id": "Görev UUID",
}
en = {
"uu_id": "Occupant UUID",
}
class SingleOccupantTypeUUID(BaseModelRegular):
uu_id: str

View File

@@ -0,0 +1,73 @@
from typing import Optional
from ApiValidations.Request import BaseModelRegular, PydanticBaseModel
class BuildAreaValidation:
tr = {
"area_name": "Alan Adı",
"area_code": "Alan Kodu",
"area_type": "Alan Tipi",
"area_direction": "Alan Yönü",
"area_gross_size": "Brüt Alan",
"area_net_size": "Net Alan",
"width": "Genişlik",
"size": "En",
}
en = {
"area_name": "Area Name",
"area_code": "Area Code",
"area_type": "Area Type",
"area_direction": "Area Direction",
"area_gross_size": "Gross Size",
"area_net_size": "Net Size",
"width": "Width",
"size": "Size",
}
class InsertBuildArea(BaseModelRegular, BuildAreaValidation):
build_uu_id: str
area_name: str
area_code: str
area_type: str
area_direction: Optional[str] = None
area_gross_size: Optional[float] = None
area_net_size: Optional[float] = None
width: Optional[int] = None
size: Optional[int] = None
class UpdateBuildArea(PydanticBaseModel, BuildAreaValidation):
area_name: Optional[str] = None
area_code: Optional[str] = None
area_type: Optional[str] = None
area_direction: Optional[str] = None
area_gross_size: Optional[float] = None
area_net_size: Optional[float] = None
width: Optional[int] = None
size: Optional[int] = None
class BuildSites:
tr = {"address_uu_id": "Adres UU ID", "site_name": "Site Adı", "site_no": "Site No"}
en = {
"address_uu_id": "Address UU ID",
"site_name": "Site Name",
"site_no": "Site No",
}
class InsertBuildSites(BaseModelRegular, BuildSites):
address_uu_id: str
site_name: str
site_no: str
class UpdateBuildSites(PydanticBaseModel, BuildSites):
site_name: Optional[str] = None
site_no: Optional[str] = None

View File

@@ -0,0 +1,182 @@
from ApiValidations.Request import BaseModelRegular
from typing import Optional
from pydantic import BaseModel, ConfigDict, Field
class ChangePasswordValidation:
tr = {"old_password": "Eski Şifre", "new_password": "Yeni Şifre"}
en = {"old_password": "Old Password", "new_password": "New Password"}
class ChangePassword(BaseModelRegular, ChangePasswordValidation):
old_password: str = Field(..., example="current123")
new_password: str = Field(..., example="newpass456")
model_config = ConfigDict(
json_schema_extra={
"example": {"old_password": "current123", "new_password": "newpass456"}
}
)
class CreatePasswordValidation:
tr = {
"password_token": "Şifre Token",
"password": "Şifre",
"re_password": "Şifre Tekrar",
}
en = {
"password_token": "Password Token",
"password": "Password",
"re_password": "Re-Password",
}
class CreatePassword(BaseModelRegular, CreatePasswordValidation):
password_token: str = Field(..., example="abc123token")
password: str = Field(..., example="newpass123")
re_password: str = Field(..., example="newpass123")
model_config = ConfigDict(
json_schema_extra={
"example": {
"password_token": "abc123token",
"password": "newpass123",
"re_password": "newpass123",
}
}
)
class OccupantSelectionValidation:
tr = {"occupant_uu_id": "Kiracı UU ID", "build_part_uu_id": "Bölüm UU ID"}
en = {"occupant_uu_id": "Occupant UU ID", "build_part_uu_id": "Build Part UU ID"}
class OccupantSelection(BaseModel, OccupantSelectionValidation):
build_living_space_uu_id: str = Field(
..., example="987fcdeb-51a2-43e7-9876-543210987654"
)
model_config = ConfigDict(
json_schema_extra={
"example": [
{"company_uu_id": "abcdef12-3456-7890-abcd-ef1234567890"},
{"build_living_space_uu_id": "987fcdeb-51a2-43e7-9876-543210987654"},
],
}
)
@property
def is_employee(self):
return False
@property
def is_occupant(self):
return True
class EmployeeSelectionValidation:
tr = {"company_uu_id": "Şirket UU ID"}
en = {"company_uu_id": "Company UU ID"}
class EmployeeSelection(BaseModel, EmployeeSelectionValidation):
company_uu_id: str = Field(..., example="abcdef12-3456-7890-abcd-ef1234567890")
model_config = ConfigDict(
json_schema_extra={
"example": [
{"company_uu_id": "abcdef12-3456-7890-abcd-ef1234567890"},
{"build_living_space_uu_id": "987fcdeb-51a2-43e7-9876-543210987654"},
],
}
)
@property
def is_employee(self):
return True
@property
def is_occupant(self):
return False
class LoginValidation:
tr = {
"domain": "Domain",
"access_key": "Erişim Anahtarı",
"password": "Şifre",
"remember_me": "Beni Hatırla",
}
en = {
"domain": "Domain",
"access_key": "Access Key",
"password": "Password",
"remember_me": "Remember Me",
}
class Login(BaseModelRegular, LoginValidation):
domain: str = Field(..., example="example.com")
access_key: str = Field(..., example="user@example.com")
password: str = Field(..., example="password123")
remember_me: Optional[bool] = Field(False, example=True)
model_config = ConfigDict(
json_schema_extra={
"example": {
"domain": "evyos.com.tr",
"access_key": "karatay.berkay.sup@evyos.com.tr",
"password": "string",
"remember_me": False,
}
}
)
class LogoutValidation:
tr = {"domain": "Domain"}
en = {"domain": "Domain"}
class Logout(BaseModelRegular, LogoutValidation):
domain: str = Field(..., example="example.com")
model_config = ConfigDict(json_schema_extra={"example": {"domain": "example.com"}})
class RememberValidation:
tr = {"domain": "Domain", "refresh_token": "Yenileme Anahtarı"}
en = {"domain": "Domain", "refresh_token": "Refresh Token"}
class Remember(BaseModelRegular, RememberValidation):
domain: str = Field(..., example="example.com")
refresh_token: str = Field(..., example="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...")
model_config = ConfigDict(
json_schema_extra={
"example": {
"domain": "example.com",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
}
}
)
class ForgotValidation:
tr = {"domain": "Domain", "access_key": "Erişim Anahtarı"}
en = {"domain": "Domain", "access_key": "Access Key"}
class Forgot(BaseModelRegular, ForgotValidation):
domain: str = Field(..., example="example.com")
access_key: str = Field(..., example="user@example.com")
model_config = ConfigDict(
json_schema_extra={
"example": {"domain": "example.com", "access_key": "user@example.com"}
}
)

View File

@@ -0,0 +1,33 @@
from typing import Optional
from ApiValidations.handler import BaseModelRegular
class ListOptions(BaseModelRegular):
page: Optional[int] = 1
size: Optional[int] = 10
order_field: Optional[str] = "id"
order_type: Optional[str] = "asc"
include_joins: Optional[list] = None
query: Optional[dict] = None
class CrudRecords:
uu_id: Optional[str] = None
created_at: Optional[str] = None
updated_at: Optional[str] = None
created_by: Optional[str] = None
updated_by: Optional[str] = None
confirmed_by: Optional[str] = None
is_confirmed: Optional[bool] = None
active: Optional[bool] = None
is_notification_send: Optional[bool] = None
is_email_send: Optional[bool] = None
class PydanticBaseModel(BaseModelRegular):
active: Optional[bool] = None
deleted: Optional[bool] = None
expiry_starts: Optional[str] = None
# expiry_ends: Optional[str] = None
is_confirmed: Optional[bool] = None

View File

@@ -0,0 +1,22 @@
from typing import Optional
from ApiValidations.Request import BaseModelRegular
# from api_validations.validations_request import (
# PydanticBaseModel,
# PydanticBaseModelValidation,
# )
from ApiValidations.Request import BaseModelRegular, PydanticBaseModel
class InsertBuildLivingSpace(BaseModelRegular):
person_uu_id: str
build_parts_uu_id: str
occupant_type_uu_id: str
expiry_starts: str
expiry_ends: Optional[str] = None
class UpdateBuildLivingSpace(PydanticBaseModel):
is_tenant_live: Optional[bool] = None
build_parts_uu_id: Optional[str] = None
person_uu_id: Optional[str] = None

View File

@@ -0,0 +1,43 @@
from typing import Optional
from ApiValidations.Request import BaseModelRegular, PydanticBaseModel
class InsertBuildTypes(BaseModelRegular):
function_code: str
type_code: str
lang: str
type_name: str
class UpdateBuildTypes(PydanticBaseModel): ...
class InsertBuildParts(BaseModelRegular):
build_uu_id: str
address_gov_code: str
part_no: int
part_level: int
build_part_type_uu_id: str
part_gross_size: Optional[int] = None
part_net_size: Optional[int] = None
default_accessory: Optional[str] = None
human_livable: Optional[bool] = False
part_direction_uu_id: Optional[str] = None
ref_id: Optional[str] = None
class UpdateBuildParts(PydanticBaseModel):
address_gov_code: Optional[str] = None
part_no: Optional[int] = None
part_level: Optional[int] = None
build_part_type_uu_id: Optional[str] = None
part_code: Optional[int] = None
part_gross_size: Optional[int] = None
part_net_size: Optional[int] = None
default_accessory: Optional[str] = None
human_livable: Optional[bool] = False
part_direction: Optional[str] = None
current_owner_person_uu_id: Optional[str] = None
current_tenant_person_uu_id: Optional[str] = None

View File

@@ -0,0 +1,43 @@
from typing import Optional
from datetime import datetime
from ApiValidations.Request import BaseModelRegular, PydanticBaseModel
class InsertBuild(BaseModelRegular):
gov_address_code: str
build_name: str
build_types_uu_id: str
max_floor: int
underground_floor: int
address_uu_id: str
build_date: datetime
decision_period_date: datetime
tax_no: Optional[str] = None
lift_count: Optional[int] = None
heating_system: Optional[bool] = None
cooling_system: Optional[bool] = None
hot_water_system: Optional[bool] = None
block_service_man_count: Optional[int] = None
security_service_man_count: Optional[int] = None
garage_count: Optional[int] = None
class UpdateBuild(PydanticBaseModel):
gov_address_code: Optional[str] = None
build_name: Optional[str] = None
build_no: Optional[str] = None
build_types_uu_id: Optional[str] = None
max_floor: Optional[int] = None
underground_floor: Optional[int] = None
build_date: Optional[datetime] = None
tax_no: Optional[str] = None
lift_count: Optional[int] = None
heating_system: Optional[bool] = None
cooling_system: Optional[bool] = None
hot_water_system: Optional[bool] = None
block_service_man_count: Optional[int] = None
security_service_man_count: Optional[int] = None
garage_count: Optional[int] = None
address_uu_id: Optional[str] = None

View File

@@ -0,0 +1,32 @@
from typing import Optional, List
from ApiValidations.Request import BaseModelRegular, PydanticBaseModel
class InsertCompany(BaseModelRegular):
formal_name: str
company_type: str
commercial_type: str
tax_no: str
public_name: Optional[str] = None
company_tag: Optional[str] = None
default_lang_type: Optional[str] = None
default_money_type: Optional[str] = None
official_address_uu_id: Optional[str] = None
# parent_uu_id: Optional[int] = None
class UpdateCompany(PydanticBaseModel):
company_uu_id: str
public_name: Optional[str] = None
formal_name: Optional[str] = None
tax_no: Optional[str] = None
company_tag: Optional[str] = None
default_lang_type: Optional[str] = None
default_money_type: Optional[str] = None
official_address_uu_id: Optional[str] = None
class MatchCompany2Company(PydanticBaseModel):
match_company_uu_id: List[str]
duty_uu_id: str
show_only: Optional[bool] = None

View File

@@ -0,0 +1,116 @@
from typing import Optional
from ApiValidations.Request import BaseModelRegular
class ListOptionsValidation:
tr = {
"page": "Sayfa",
"size": "Boyut",
"order_field": "Sıralama Alanı",
"order_type": "Sıralama Türü",
"include_joins": "Alt İçerikleri",
"query": "Sorgu",
}
en = {
"page": "Page",
"size": "Size",
"order_field": "Order Field",
"order_type": "Order Type",
"include_joins": "Include Joins",
"query": "Query",
}
class ListOptions(BaseModelRegular, ListOptionsValidation):
page: Optional[int] = 1
size: Optional[int] = 10
order_field: Optional[str] = "id"
order_type: Optional[str] = "asc"
include_joins: Optional[list] = None
query: Optional[dict] = None
class CrudRecordValidation:
tr = {
"uu_id": "UUID",
"created_at": "Oluşturulma Tarihi",
"updated_at": "Güncellenme Tarihi",
"created_by": "Oluşturan",
"updated_by": "Güncelleyen",
"confirmed_by": "Onaylayan",
"is_confirmed": "Onay",
"expiry_starts": "Geçerlilik Başlangıç Tarihi",
"expiry_ends": "Geçerlilik Bitiş Tarihi",
"active": "Aktif",
"is_notification_send": "Bildirim Gönderildi",
"is_email_send": "E-posta Gönderildi",
}
en = {
"uu_id": "UUID",
"created_at": "Created At",
"updated_at": "Updated At",
"created_by": "Created By",
"updated_by": "Updated By",
"confirmed_by": "Confirmed By",
"is_confirmed": "Confirmed",
"expiry_starts": "Expiry Starts",
"expiry_ends": "Expiry Ends",
"active": "Active",
"is_notification_send": "Notification Send",
"is_email_send": "Email Send",
}
class CrudRecords:
uu_id: Optional[str] = None
created_at: Optional[str] = None
updated_at: Optional[str] = None
created_by: Optional[str] = None
updated_by: Optional[str] = None
confirmed_by: Optional[str] = None
is_confirmed: Optional[bool] = None
active: Optional[bool] = None
is_notification_send: Optional[bool] = None
is_email_send: Optional[bool] = None
class PydanticBaseModelValidation:
tr = {
"active": "Aktif",
"deleted": "Silinmiş",
"expiry_starts": "Geçerlilik Başlangıç Tarihi",
"expiry_ends": "Geçerlilik Bitiş Tarihi",
"is_confirmed": "Onay",
}
en = {
"active": "Active",
"deleted": "Deleted",
"expiry_starts": "Expiry Starts",
"expiry_ends": "Expiry Ends",
"is_confirmed": "Confirmed",
}
class PydanticBaseModel(BaseModelRegular):
active: Optional[bool] = None
deleted: Optional[bool] = None
expiry_starts: Optional[str] = None
# expiry_ends: Optional[str] = None
is_confirmed: Optional[bool] = None
class EndpointPydantic(BaseModelRegular):
data: Optional[dict] = None
class EndpointValidation(BaseModelRegular):
endpoint: Optional[str] = None
class PatchRecord(BaseModelRegular):
confirm: Optional[bool] = None
delete: Optional[bool] = None
active: Optional[bool] = None

View File

@@ -0,0 +1,73 @@
import typing
from datetime import datetime
class ConvertField:
def __init__(self, match, default_val=None):
self.match = match
self.default_val = default_val
def typing_return(self):
typing_dict = {
"<class 'float'>": float,
"<class 'bool'>": bool,
"<class 'int'>": int,
"<class 'str'>": str,
"<class 'dict'>": dict,
"<class 'list'>": list,
"<class 'datetime.datetime'>": datetime,
"typing.Optional[datetime.datetime]": typing.Optional[datetime],
"typing.Optional[bool]": typing.Optional[bool],
"typing.Optional[list]": typing.Optional[list],
"typing.Optional[str]": typing.Optional[str],
"typing.Optional[int]": typing.Optional[int],
"typing.Optional[float]": typing.Optional[float],
"typing.Optional[dict]": typing.Optional[dict],
}
matches_with = typing_dict.get(self.match, typing.Optional[str])
default_value = getattr(self.default_val, "field_default_value", None)
return matches_with, default_value
#
# def create_model_from_database(model_id: typing.Union[int, str]):
# if isinstance(model_id, int):
# selected_model = Models.find_one(id=model_id)
# else:
# selected_model = Models.find_one(uu_id=str(model_id))
#
# if not selected_model:
# raise HTTPException(
# status_code=202,
# detail=f"Model {selected_model.model_name} not found in database. Please add model to api.",
# )
# pydantic_class = getattr(root_validates, selected_model.model_type, None)
# if not pydantic_class:
# raise HTTPException(
# status_code=202,
# detail=f"Pydantic class {selected_model.model_type} not found in database. Please add model to api.",
# )
#
# model_entities_records = ModelEntities.filter_all(
# ModelEntities.model_id == selected_model.id
# ).data
#
# if not model_entities_records:
# raise HTTPException(
# status_code=202,
# detail="Model has no entities registered. Please add entities to model.",
# )
#
# fields = {}
# for entity in model_entities_records:
# fields[entity.field_name] = ConvertField(
# entity.field_type, entity.field_default_value
# ).typing_return()
#
# return create_model(
# __model_name=selected_model.model_name, # pydantic_name(User)
# __module__=pydantic_class.__module__, # field_name(uu_id)
# **fields, # field_name = (field_type (Optional[str]), default_value(None))
# )

View File

@@ -0,0 +1,110 @@
from typing import Optional
from ApiValidations.Request import BaseModelRegular, PydanticBaseModel, ListOptions
class DecisionBookDecisionBookInvitations(BaseModelRegular):
build_decision_book_uu_id: str
message: str
planned_date: str
class DecisionBookDecisionBookInvitationsAttend(BaseModelRegular):
token: str
is_attend: bool
class DecisionBookDecisionBookInvitationsAssign(BaseModelRegular):
token: str
build_living_space_uu_id: str
occupant_type_uu_id: str
class DecisionBookDecisionBookInvitationsUpdate(PydanticBaseModel):
token: str
occupant_type_uu_id: Optional[str] = None
class ListDecisionBook(ListOptions):
build_decision_book_uu_id: Optional[str] = None
class InsertDecisionBook(PydanticBaseModel):
build_uu_id: str
decision_type: str
meeting_date: str
is_out_sourced: bool
resp_company_fix_wage: Optional[float] = None
resp_company_uu_id: Optional[str] = None
class InsertDecisionBookCompleted(BaseModelRegular):
build_decision_book_uu_id: str
meeting_completed_date: str
class InsertDecisionBookPerson(BaseModelRegular):
person_uu_id: str
build_decision_book_uu_id: str
management_typecode_uu_id: str
dues_discount_approval_date: Optional[str] = None
dues_fix_discount: Optional[float] = None
dues_percent_discount: Optional[int] = None
class UpdateDecisionBookPerson(PydanticBaseModel):
dues_fix_discount: Optional[float] = None
dues_percent_discount: Optional[int] = None
class RemoveDecisionBookPerson(PydanticBaseModel):
person_uu_id: str
build_decision_book_person_uu_id: str
class UpdateDecisionBook(PydanticBaseModel):
decision_book_pdf_path: Optional[str] = None
is_out_sourced: Optional[bool] = None
contact_agreement_path: Optional[str] = None
contact_agreement_date: Optional[str] = None
meeting_date: Optional[str] = None
decision_type: Optional[str] = None
resp_company_fix_wage: Optional[float] = None
resp_company_uu_id: Optional[str] = None
class InsertBuildDecisionBookItems(BaseModelRegular):
token: str
info_type_uu_id: str
item_comment: str
currency: Optional[str] = "TL"
unit_type: Optional[str] = "M2"
debit_start_date: Optional[str] = None
debit_end_date: Optional[str] = None
unit_price_is_fixed: Optional[bool] = False
unit_price: Optional[float] = 0.00
# build_decision_book_uu_id: str
# item_objection: Optional[str] = None
class UpdateBuildDecisionBookItems(PydanticBaseModel):
item_comment: Optional[str] = None
item_objection: Optional[str] = None
class InsertBuildDecisionBookItemDebits(BaseModelRegular):
build_decision_book_item_uu_id: str
dues_values: dict
# dues_types_uu_id: str
# decision_taken: Optional[bool] = None
class UpdateBuildDecisionBookItemDebits(PydanticBaseModel):
dues_types_uu_id: Optional[str] = None
dues_values: Optional[dict] = None
decision_taken: Optional[bool] = None

View File

@@ -0,0 +1,22 @@
from typing import Optional
from ApiValidations.Request import (
PydanticBaseModel,
)
class DepartmentsPydantic(PydanticBaseModel):
department_code: Optional[str]
department_name: Optional[str]
department_description: Optional[str] = None
company_uu_id: Optional[str] = None
parent_department_uu_id: Optional[int] = None
# class UpdateDepartments(PydanticBaseModel):
#
# department_code: Optional[str] = None
# department_name: Optional[str] = None
# department_description: Optional[str] = None
# company_uu_id: Optional[str] = None
# parent_department_uu_id: Optional[int] = None

View File

@@ -0,0 +1,77 @@
from typing import Optional
from ApiValidations.Request import BaseModelRegular, PydanticBaseModel
class BindEmployees2People(PydanticBaseModel):
staff_uu_id: str
people_uu_id: str
expiry_starts: Optional[str] = None
class UnBindEmployees2People(PydanticBaseModel):
people_uu_id: str
expiry_ends: str
class InsertEmployees(BaseModelRegular):
staff_uu_id: str
people_uu_id: Optional[str] = None
class InsertCompanyDuty(BaseModelRegular):
duty_code: str
duty_name: str
duty_description: Optional[str] = None
class SelectDuties(BaseModelRegular):
duty_uu_id: Optional[str] = None
class InsertDuties(BaseModelRegular):
duties_uu_id: str
department_uu_id: str
is_default_duty: Optional[bool] = False
class UpdateDuties(PydanticBaseModel):
duties_uu_id: Optional[str] = None
department_uu_id: Optional[str] = None
is_default_duty: Optional[bool] = None
class UpdateCompanyDuty(PydanticBaseModel):
duty_code: Optional[str] = None
duty_name: Optional[str] = None
duty_description: Optional[str] = None
class InsertCompanyEmployeesSalaries(BaseModelRegular):
gross_salary: float
net_salary: float
start_date: str
stop_date: Optional[str] = None
people_id: int
class UpdateCompanyEmployeesSalaries(PydanticBaseModel):
gross_salary: Optional[float] = None
net_salary: Optional[float] = None
start_date: Optional[str] = None
stop_date: Optional[str] = None
people_id: Optional[int] = None
class InsertCompanyEmployees(BaseModelRegular):
employee_description: Optional[str] = None
person_uu_id: str
duty_uu_id: str
start_date: Optional[str] = None
stop_date: Optional[str] = None
class UpdateCompanyEmployees(PydanticBaseModel):
stop_date: Optional[str] = None
employee_description: Optional[str] = None

View File

@@ -0,0 +1,37 @@
from typing import Optional
from ApiValidations.Request import BaseModelRegular
class RegisterEvents2EmployeeValidation:
tr = {
"event_uu_id_list": "Etkinlikler Listesi",
"employee_uu_id": "Çalışan UU ID",
}
en = {
"event_uu_id_list": "Event List",
"employee_uu_id": "Employee UU ID",
}
class RegisterEvents2Employee(BaseModelRegular, RegisterEvents2EmployeeValidation):
event_uu_id_list: list[str] = None
employee_uu_id: Optional[str] = None
class RegisterEvents2OccupantValidation:
tr = {
"event_uu_id_list": "Etkinlikler Listesi",
"build_part_uu_id": "Bina Parça UU ID",
"occupant_uu_id": "Apartman Sakini UU ID",
}
en = {
"event_uu_id_list": "Event List",
"build_part_uu_id": "Building Part UU ID",
"occupant_uu_id": "Occupant UU ID",
}
class RegisterEvents2Occupant(BaseModelRegular, RegisterEvents2OccupantValidation):
event_uu_id_list: list[str] = None
build_part_uu_id: Optional[str] = None
occupant_uu_id: Optional[str] = None

View File

@@ -0,0 +1,36 @@
from ApiValidations.Request import BaseModelRegular
class RegisterModules2OccupantValidation:
tr = {
"modules_uu_id": "Modül Listesi",
"occupant_uu_id": "Mülk Sahibi",
"build_part_uu_id": "Daire UUID",
}
en = {
"modules_uu_id": "Module List",
"occupant_uu_id": "Occupant",
"build_part_uu_id": "Flat UUID",
}
class RegisterModules2Occupant(BaseModelRegular, RegisterModules2OccupantValidation):
modules_uu_id: str
occupant_uu_id: str
build_part_uu_id: str
class RegisterModules2EmployeeValidation:
tr = {
"modules_uu_id": "Modül Listesi",
"employee_uu_id": "Çalışan",
}
en = {
"modules_uu_id": "Module List",
"employee_uu_id": "Employee",
}
class RegisterModules2Employee(BaseModelRegular, RegisterModules2EmployeeValidation):
modules_uu_id: str
employee_uu_id: str

View File

@@ -0,0 +1,66 @@
from typing import Optional
from ApiValidations.Request import BaseModelRegular, PydanticBaseModel
class InsertPerson(BaseModelRegular):
firstname: str
surname: str
sex_code: str
national_identity_id: str
middle_name: Optional[str] = None
father_name: Optional[str] = None
mother_name: Optional[str] = None
country_code: Optional[str] = "TR"
birth_place: Optional[str] = None
birth_date: Optional[str] = None
tax_no: Optional[str] = None
ref_id: Optional[str] = None
class UpdatePerson(PydanticBaseModel):
firstname: Optional[str] = None
surname: Optional[str] = None
middle_name: Optional[str]
father_name: Optional[str] = None
mother_name: Optional[str] = None
sex_code: Optional[str] = None
country_code: Optional[str] = None
national_identity_id: Optional[str] = None
birth_place: Optional[str] = None
birth_date: Optional[str] = None
tax_no: Optional[str] = None
#
# class QueryPeople(PydanticBaseModel):
# uu_id: Optional[str] = None
#
#
# class InsertPeople(PydanticBaseModel):
# key_id: Optional[str] = None
# query: Optional[dict] = None
# data: Optional[_InsertPerson] = None
#
#
# class UpdatePeople(PydanticBaseModel):
# key_id: Optional[str] = None
# query: Optional[QueryPeople] = None
# data: Optional[_UpdatePerson] = None
#
#
# class DeletePeople(PydanticBaseModel):
# key_id: Optional[str] = None
# query: Optional[List[QueryPeople]] = None
# data: Optional[dict] = None
#
#
# class ListPeople(PydanticBaseModel):
# key_id: Optional[str] = None
# query: Optional[QueryPeople] = None
# data: Optional[ListOptions] = None
#
#
# class ActivePeople(PydanticBaseModel):
# key_id: Optional[str] = None
# query: Optional[List[QueryPeople]] = None
# data: Optional[dict] = None

View File

@@ -0,0 +1,99 @@
from typing import Optional
from ApiValidations.Request import BaseModelRegular, PydanticBaseModel
class InsertBuildDecisionBookProjectItems(BaseModelRegular):
build_decision_book_project_uu_id: str
item_header: str
item_comment: str
attachment_pdf_path: Optional[str] = None
item_objection: Optional[str] = None
class UpdateBuildDecisionBookProjectItems(PydanticBaseModel):
item_header: Optional[str] = None
item_comment: Optional[str] = None
attachment_pdf_path: Optional[str] = None
item_estimated_cost: Optional[float] = None
build_decision_book_project_uu_id: Optional[str] = None
class InsertBuildDecisionBookProjectPerson(BaseModelRegular):
dues_percent_discount: Optional[int] = None
job_fix_wage: Optional[float] = None
bid_price: Optional[float] = None
decision_price: Optional[float] = None
build_decision_book_project_uu_id: str
living_space_uu_id: str
project_team_type_uu_id: str
class UpdateBuildDecisionBookProjectPerson(PydanticBaseModel):
dues_percent_discount: Optional[int] = None
job_fix_wage: Optional[float] = None
bid_price: Optional[float] = None
decision_price: Optional[float] = None
build_decision_book_project_uu_id: Optional[str] = None
living_space_uu_id: Optional[str] = None
project_team_type_uu_id: Optional[str] = None
class InsertBuildDecisionBookProjects(BaseModelRegular):
build_decision_book_item_uu_id: str
project_responsible_person_uu_id: str
project_name: str
project_start_date: str
project_stop_date: str
project_type: str
is_out_sourced: Optional[bool] = False
project_note: Optional[str] = None
decision_book_pdf_path: Optional[str] = None
resp_company_fix_wage: Optional[float] = None
contact_agreement_path: Optional[str] = None
contact_agreement_date: Optional[str] = None
meeting_date: Optional[str] = None
currency: Optional[str] = None
bid_price: Optional[float] = None
resp_company_uu_id: Optional[str] = None
class UpdateBuildDecisionBookProjects(PydanticBaseModel):
build_decision_book_project_uu_id: str
is_out_sourced: Optional[bool] = False
project_note: Optional[str] = None
# decision_book_pdf_path: Optional[str] = None
status_id: Optional[int] = None
resp_company_fix_wage: Optional[float] = None
contact_agreement_path: Optional[str] = None
contact_agreement_date: Optional[str] = None
contact_uu_id: Optional[str] = None
resp_company_uu_id: Optional[str] = None
approved_price: Optional[float] = None
class ApprovalsBuildDecisionBookProjects(PydanticBaseModel):
build_decision_book_project_uu_id: str
project_stop_date: str
status_code: Optional[int] = None
final_price_list: Optional[list[dict]] = (
None # {"date": "2021-01-01", "price": 1000}
)
class InsertBuildDecisionBookProjectItemDebits(PydanticBaseModel):
build_decision_book_project_item_uu_id: str
payment_date: str
dues_values: dict
is_official: Optional[bool] = False
discount_value: Optional[float] = None
discount_fix: Optional[float] = None
decision_taken: Optional[bool] = None
class UpdateBuildDecisionBookProjectItemDebits(PydanticBaseModel):
dues_values: Optional[str] = None
discount_value: Optional[float] = None
discount_fix: Optional[float] = None
decision_taken: Optional[bool] = None
is_official: Optional[bool] = None

View File

@@ -0,0 +1,23 @@
from typing import Optional, List
from ApiValidations.Request import BaseModelRegular
from ApiValidations.Request import BaseModelRegular, PydanticBaseModel
class CheckEndpointAccess(BaseModelRegular):
endpoint: str
class InsertEndpointAccess(PydanticBaseModel):
duty_uu_id: str
endpoint_restriction_list_uu_ids: list
class UpdateEndpointAccess(PydanticBaseModel):
endpoint_restriction_uu_id: Optional[str] = None
deleted: Optional[bool] = None
active: Optional[bool] = None
is_confirmed: Optional[bool] = None
class UpdateEndpointAccessList(PydanticBaseModel):
endpoint_restriction_list: List[UpdateEndpointAccess]

View File

@@ -0,0 +1,36 @@
from ApiValidations.Request import BaseModelRegular
class RegisterServices2OccupantValidation:
tr = {
"service_uu_id": "Hizmet UUID",
"occupant_uu_id": "Müşteri UUID",
"build_part_uu_id": "Bina Parça UUID",
}
en = {
"service_uu_id": "Service UUID",
"occupant_uu_id": "Occupant UUID",
"build_part_uu_id": "Building Part UUID",
}
class RegisterServices2Occupant(BaseModelRegular, RegisterServices2OccupantValidation):
service_uu_id: str
occupant_uu_id: str
build_part_uu_id: str
class RegisterServices2EmployeeValidation:
tr = {
"service_uu_id": "Hizmet UUID",
"employee_uu_id": "Personel UUID",
}
en = {
"service_uu_id": "Service UUID",
"employee_uu_id": "Employee UUID",
}
class RegisterServices2Employee(BaseModelRegular, RegisterServices2EmployeeValidation):
service_uu_id: str
employee_uu_id: str

View File

@@ -0,0 +1,39 @@
from typing import Optional
from ApiValidations.Request import BaseModelRegular, PydanticBaseModel
class InsertStaffValidation:
tr = {
"staff_name": "Kadro Adı",
"staff_description": "Kadro Açıklaması",
"staff_code": "Kadro Kodu",
"duties_uu_id": "Görev UUID",
}
en = {
"staff_name": "Staff Name",
"staff_description": "Staff Description",
"staff_code": "Staff Code",
"duties_uu_id": "Duties UUID",
}
class InsertStaff(BaseModelRegular, InsertStaffValidation):
staff_name: str
staff_description: Optional[str] = None
staff_code: Optional[str] = None
duties_uu_id: str
class SelectStaffValidation:
tr = {
"duties_uu_id": "Görev UUID",
}
en = {
"duties_uu_id": "Duties UUID",
}
class SelectStaff(PydanticBaseModel, SelectStaffValidation):
duties_uu_id: str

View File

@@ -0,0 +1,68 @@
from typing import Optional
from ApiValidations.Request import PydanticBaseModel
class InsertUsersValidation:
tr = {
"people_uu_id": "Kişi UUID",
"user_tag": "Kullanıcı Etiketi",
"email": "E-posta",
"phone_number": "Telefon Numarası",
"avatar": "Avatar",
}
en = {
"people_uu_id": "People UUID",
"user_tag": "User Tag",
"email": "Email",
"phone_number": "Phone Number",
"avatar": "Avatar",
}
class InsertUsers(PydanticBaseModel, InsertUsersValidation):
people_uu_id: str
user_tag: str
email: Optional[str] = None
phone_number: Optional[str] = None
avatar: Optional[str] = None
class UpdateUsersValidation:
tr = {
"people_uu_id": "Kişi UUID",
"nick_name": "Kullanıcı Etiketi",
"domain_name": "Domain Adı",
"email": "E-posta",
"phone_number": "Telefon Numarası",
"avatar": "Avatar",
}
en = {
"people_uu_id": "People UUID",
"nick_name": "User Tag",
"domain_name": "Domain Name",
"email": "Email",
"phone_number": "Phone Number",
"avatar": "Avatar",
}
class UpdateUsers(PydanticBaseModel, UpdateUsersValidation):
people_uu_id: Optional[str] = None
nick_name: Optional[str] = None
domain_name: Optional[str] = None
email: Optional[str] = None
phone_number: Optional[str] = None
avatar: Optional[str] = None
class QueryUsersValidation:
tr = {
"uu_id": "UUID",
}
en = {
"uu_id": "UUID",
}
class QueryUsers(PydanticBaseModel):
uu_id: Optional[str] = None

View File

@@ -0,0 +1,16 @@
from .account_responses import AccountRecordResponse
from .address_responses import ListAddressResponse
from .auth_responses import (
AuthenticationLoginResponse,
AuthenticationRefreshResponse,
AuthenticationUserInfoResponse,
)
__all__ = [
"AccountRecordResponse",
"ListAddressResponse",
"AuthenticationLoginResponse",
"AuthenticationRefreshResponse",
"AuthenticationUserInfoResponse",
]

View File

@@ -0,0 +1,260 @@
from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime
from decimal import Decimal
from uuid import UUID
from pydantic import BaseModel
class AccountBooksResponse(BaseModel):
"""Response model for account books"""
country: str
branch_type: int
company_id: int
company_uu_id: str
branch_id: Optional[int]
branch_uu_id: Optional[str]
class AccountCodesResponse(BaseModel):
"""Response model for account codes"""
account_code: str
comment_line: str
is_receive_or_debit: bool
product_id: int = 0
nvi_id: str = ""
status_id: int = 0
account_code_seperator: str = "."
system_id: int = 0
locked: bool = False
company_id: Optional[int]
company_uu_id: str
customer_id: Optional[int]
customer_uu_id: str
person_id: Optional[int]
person_uu_id: str
class AccountCodeParserResponse(BaseModel):
"""Response model for account code parser"""
account_code_1: str
account_code_2: str
account_code_3: str
account_code_4: str = ""
account_code_5: str = ""
account_code_6: str = ""
account_code_id: int
account_code_uu_id: str
class AccountMasterResponse(BaseModel):
"""Response model for account master"""
doc_date: datetime
plug_type: str
plug_number: int
special_code: str = ""
authorization_code: str = ""
doc_code: str = ""
doc_type: int = 0
comment_line1: str = ""
comment_line2: str = ""
comment_line3: str = ""
comment_line4: str = ""
comment_line5: str = ""
comment_line6: str = ""
project_code: str = ""
module_no: str = ""
journal_no: int = 0
status_id: int = 0
canceled: bool = False
print_count: int = 0
total_active: Decimal = Decimal("0")
total_passive: Decimal = Decimal("0")
total_active_1: Decimal = Decimal("0")
total_passive_1: Decimal = Decimal("0")
total_active_2: Decimal = Decimal("0")
total_passive_2: Decimal = Decimal("0")
total_active_3: Decimal = Decimal("0")
total_passive_3: Decimal = Decimal("0")
total_active_4: Decimal = Decimal("0")
total_passive_4: Decimal = Decimal("0")
cross_ref: int = 0
data_center_id: str = ""
data_center_rec_num: int = 0
account_header_id: int
account_header_uu_id: str
project_item_id: Optional[int]
project_item_uu_id: Optional[str]
department_id: Optional[int]
department_uu_id: Optional[str]
class AccountDetailResponse(BaseModel):
"""Response model for account detail"""
doc_date: datetime
line_no: int
receive_debit: str
debit: Decimal
department: str = ""
special_code: str = ""
account_ref: int = 0
account_fiche_ref: int = 0
center_ref: int = 0
general_code: str = ""
credit: Decimal = Decimal("0")
currency_type: str = "TL"
exchange_rate: Decimal = Decimal("0")
debit_cur: Decimal = Decimal("0")
credit_cur: Decimal = Decimal("0")
discount_cur: Decimal = Decimal("0")
amount: Decimal = Decimal("0")
cross_account_code: str = ""
inf_index: Decimal = Decimal("0")
not_inflated: int = 0
not_calculated: int = 0
comment_line1: str = ""
comment_line2: str = ""
comment_line3: str = ""
comment_line4: str = ""
comment_line5: str = ""
comment_line6: str = ""
owner_acc_ref: int = 0
from_where: int = 0
orj_eid: int = 0
canceled: int = 0
cross_ref: int = 0
data_center_id: str = ""
data_center_rec_num: str = "0"
status_id: int = 0
plug_type_id: Optional[int]
plug_type_uu_id: str
account_header_id: int
account_header_uu_id: str
account_code_id: int
account_code_uu_id: str
account_master_id: int
account_master_uu_id: str
project_id: Optional[int]
project_uu_id: Optional[str]
class AccountRecordResponse(BaseModel):
"""Response model for account financial records.
This model represents a financial transaction record in the system,
including bank transaction details, amounts, and related metadata.
Attributes:
iban (str): International Bank Account Number
bank_date (datetime): Date when the transaction occurred at the bank
currency_value (Decimal): Original transaction amount
bank_balance (Decimal): Account balance after the transaction
currency (str): Currency code (e.g., "TRY", "USD")
additional_balance (Decimal): Any additional balance adjustments
channel_branch (str): Bank branch or channel where transaction occurred
process_name (str): Name/type of the transaction
process_type (str): Classification of the transaction
process_comment (str): Additional transaction details or notes
bank_reference_code (str): Bank's reference code for the transaction
add_comment_note (Optional[str]): Additional internal notes
is_receipt_mail_send (Optional[bool]): Whether receipt was emailed
found_from (Optional[str]): Source of the transaction record
similarity (Optional[float]): Matching confidence for duplicate detection
remainder_balance (Optional[Decimal]): Remaining balance if partial
bank_date_y (Optional[int]): Year of bank transaction
bank_date_m (Optional[int]): Month of bank transaction
bank_date_w (Optional[int]): Week of bank transaction
bank_date_d (Optional[int]): Day of bank transaction
approving_accounting_record (Optional[bool]): Accounting approval status
accounting_receipt_date (Optional[datetime]): When receipt was processed
accounting_receipt_number (Optional[int]): Receipt reference number
approved_record (Optional[bool]): Whether record is approved
import_file_name (Optional[str]): Source file if imported
receive_debit_uu_id (Optional[str]): Related debit record ID
budget_type_uu_id (Optional[str]): Associated budget type ID
company_uu_id (Optional[str]): Associated company ID
send_company_uu_id (Optional[str]): Sending company ID
customer_id (Optional[str]): Associated customer ID
customer_uu_id (Optional[str]): Associated customer UUID
send_person_uu_id (Optional[str]): Sending person ID
approving_accounting_person_uu_id (Optional[str]): Approver ID
build_parts_uu_id (Optional[str]): Related building part ID
build_decision_book_uu_id (Optional[str]): Related decision book ID
"""
iban: str
bank_date: datetime
currency_value: Decimal
bank_balance: Decimal
currency: str = "TRY"
additional_balance: Decimal = Decimal("0")
channel_branch: str
process_name: str
process_type: str
process_comment: str
bank_reference_code: str
add_comment_note: Optional[str]
is_receipt_mail_send: Optional[bool] = False
found_from: Optional[str]
similarity: Optional[float]
remainder_balance: Optional[Decimal]
bank_date_y: Optional[int]
bank_date_m: Optional[int]
bank_date_w: Optional[int]
bank_date_d: Optional[int]
approving_accounting_record: Optional[bool]
accounting_receipt_date: Optional[datetime]
accounting_receipt_number: Optional[int]
approved_record: Optional[bool]
import_file_name: Optional[str]
receive_debit_uu_id: Optional[str]
budget_type_uu_id: Optional[str]
company_uu_id: Optional[str]
send_company_uu_id: Optional[str]
customer_id: Optional[str]
customer_uu_id: Optional[str]
send_person_uu_id: Optional[str]
approving_accounting_person_uu_id: Optional[str]
build_parts_uu_id: Optional[str]
build_decision_book_uu_id: Optional[str]
class AccountRecordExchangeResponse(BaseModel):
"""Response model for currency exchange records.
This model represents a currency exchange transaction, tracking
exchange rates and converted amounts for financial records.
Attributes:
account_record_id (int): ID of the related account record
account_record_uu_id (str): UUID of the related account record
exchange_rate (Decimal): Applied exchange rate
exchange_currency (str): Target currency code
exchange_value (Decimal): Converted amount
exchange_date (datetime): When the exchange was calculated
"""
account_record_id: int
account_record_uu_id: str
exchange_rate: Decimal
exchange_currency: str = "TRY"
exchange_value: Decimal
exchange_date: datetime
class AccountRecordsListResponse(BaseModel):
"""Response model for account records list endpoint"""
uu_id: UUID
account_name: str
account_code: str
company_id: int
company_uu_id: str
created_at: datetime
updated_at: Optional[datetime]
deleted: bool = False

View File

@@ -0,0 +1,20 @@
from typing import Optional
from pydantic import BaseModel
class ListAddressResponse(BaseModel):
build_number: Optional[str] = None
door_number: Optional[str] = None
floor_number: Optional[str] = None
comment_address: Optional[str] = None
letter_address: Optional[str] = None
short_letter_address: Optional[str] = None
latitude: Optional[float] = None
longitude: Optional[float] = None
street_uu_id: Optional[str] = None
class AddressPostCodeResponse:
street_id: Optional[int] = None
street_uu_id: Optional[str] = None
postcode: Optional[str] = None

View File

@@ -0,0 +1,36 @@
from pydantic import BaseModel
from typing import Optional, List, Dict, Any
from datetime import datetime
from uuid import UUID
class AuthenticationLoginResponse(BaseModel):
"""Response model for authentication login endpoint"""
token: str
refresh_token: str
token_type: str
expires_in: int
user_info: Dict[str, Any]
class AuthenticationRefreshResponse(BaseModel):
"""Response model for authentication refresh endpoint"""
token: str
refresh_token: str
token_type: str
expires_in: int
class AuthenticationUserInfoResponse(BaseModel):
"""Response model for authentication user info endpoint"""
user_id: int
username: str
email: str
first_name: str
last_name: str
is_active: bool
created_at: datetime
updated_at: Optional[datetime]

View File

@@ -0,0 +1,105 @@
from pydantic import BaseModel
from typing import Optional, TypeVar, Generic, List
from datetime import datetime
from uuid import UUID
T = TypeVar("T")
class BaseResponse(BaseModel):
"""Base response model that all response models inherit from.
This model provides common fields that are present in all database records,
including tracking information (created/updated timestamps), user actions
(created by, updated by, confirmed by), and record status (active, deleted).
Attributes:
uu_id (str): Unique identifier for the record, typically a UUID
created_at (datetime): Timestamp when the record was created
updated_at (Optional[datetime]): Timestamp when the record was last updated
created_by (Optional[str]): Username or identifier of the user who created the record
updated_by (Optional[str]): Username or identifier of the user who last updated the record
confirmed_by (Optional[str]): Username or identifier of the user who confirmed the record
is_confirmed (Optional[bool]): Whether the record has been confirmed/approved
active (Optional[bool]): Whether the record is currently active
deleted (Optional[bool]): Whether the record has been marked as deleted
expiry_starts (Optional[datetime]): When the record becomes valid/active
expiry_ends (Optional[datetime]): When the record expires/becomes inactive
is_notification_send (Optional[bool]): Whether notifications have been sent for this record
is_email_send (Optional[bool]): Whether emails have been sent for this record
"""
uu_id: str
created_at: datetime
updated_at: Optional[datetime]
created_by: Optional[str]
updated_by: Optional[str]
confirmed_by: Optional[str]
is_confirmed: Optional[bool] = None
active: Optional[bool] = True
deleted: Optional[bool] = False
expiry_starts: Optional[datetime]
expiry_ends: Optional[datetime]
is_notification_send: Optional[bool] = False
is_email_send: Optional[bool] = False
class Config:
"""Pydantic configuration for the base response model.
Attributes:
from_attributes (bool): Enables ORM mode for SQLAlchemy integration
"""
from_attributes = True
class CrudCollection(BaseModel, Generic[T]):
"""Base collection model for paginated responses.
This model is used to return collections of items with pagination information.
It is generic over the type of items in the collection, allowing it to be
used with any response model.
Type Parameters:
T: The type of items in the collection
Attributes:
page (int): Current page number, 1-based indexing
size (int): Number of items per page
total (int): Total number of items across all pages
order_field (str): Field used for sorting the collection
order_type (str): Sort direction ('asc' or 'desc')
items (List[T]): List of items in the current page
Example:
```python
class UserResponse(BaseResponse):
name: str
email: str
users = CrudCollection[UserResponse](
page=1,
size=10,
total=100,
order_field="name",
order_type="asc",
items=[...]
)
```
"""
page: int = 1
size: int = 10
total: int = 0
order_field: str = "id"
order_type: str = "asc"
items: List[T] = []
class Config:
"""Pydantic configuration for the collection model.
Attributes:
from_attributes (bool): Enables ORM mode for SQLAlchemy integration
"""
from_attributes = True

View File

@@ -0,0 +1,90 @@
from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime
from uuid import UUID
from decimal import Decimal
from .base_responses import BaseResponse, CrudCollection
class DecisionBookBudgetBooksResponse(BaseResponse):
"""Response model for decision book budget books"""
country: str
branch_type: int = 0
company_id: int
company_uu_id: str
branch_id: Optional[int]
branch_uu_id: Optional[str]
build_decision_book_id: int
build_decision_book_uu_id: Optional[str]
class DecisionBookBudgetBooksCollection(
CrudCollection[DecisionBookBudgetBooksResponse]
):
"""Collection of decision book budget books"""
pass
class DecisionBookBudgetCodesResponse(BaseResponse):
"""Response model for decision book budget codes"""
budget_code: str
comment_line: str
budget_type: str
budget_code_seperator: str = "."
system_id: int = 0
locked: bool = False
company_id: Optional[int]
company_uu_id: str
customer_id: Optional[int]
customer_uu_id: str
class DecisionBookBudgetCodesCollection(
CrudCollection[DecisionBookBudgetCodesResponse]
):
"""Collection of decision book budget codes"""
pass
class DecisionBookBudgetMasterResponse(BaseResponse):
"""Response model for decision book budget master"""
budget_type: str
currency: str = "TRY"
total_budget: Decimal
tracking_period_id: Optional[int]
tracking_period_uu_id: Optional[str]
budget_books_id: int
budget_books_uu_id: Optional[str]
department_id: int
department_uu_id: Optional[str]
class DecisionBookBudgetMasterCollection(
CrudCollection[DecisionBookBudgetMasterResponse]
):
"""Collection of decision book budget masters"""
pass
class DecisionBookBudgetsResponse(BaseResponse):
"""Response model for decision book budgets"""
process_date: datetime
budget_codes_id: int
total_budget: Decimal
used_budget: Decimal = Decimal("0")
remaining_budget: Decimal = Decimal("0")
decision_book_budget_master_id: int
decision_book_budget_master_uu_id: Optional[str]
class DecisionBookBudgetsCollection(CrudCollection[DecisionBookBudgetsResponse]):
"""Collection of decision book budgets"""
pass

View File

@@ -0,0 +1,309 @@
from typing import Optional, List, Generic
from datetime import datetime
from uuid import UUID
from decimal import Decimal
from api_validations.validations_response.base_responses import (
BaseResponse,
CrudCollection,
)
from api_validations.validations_request import PydanticBaseModel
class ListBuildingResponse(PydanticBaseModel):
gov_address_code: str
build_name: str
build_types_uu_id: Optional[str] = None
build_no: Optional[str] = None
max_floor: Optional[int] = None
underground_floor: Optional[int] = None
address_uu_id: Optional[str] = None
build_date: Optional[str] = None
decision_period_date: Optional[str] = None
tax_no: Optional[str] = None
lift_count: Optional[int] = None
heating_system: Optional[bool] = None
cooling_system: Optional[bool] = None
hot_water_system: Optional[bool] = None
block_service_man_count: Optional[int] = None
security_service_man_count: Optional[int] = None
garage_count: Optional[int] = None
site_uu_id: Optional[str] = None
class BuildAreaListResponse(BaseResponse):
"""Response model for building area list endpoint"""
uu_id: UUID
build_id: int
build_uu_id: str
area_name: str
area_value: float
created_at: datetime
updated_at: Optional[datetime]
deleted: bool = False
class BuildAreaListCollection(CrudCollection[BuildAreaListResponse]):
"""Collection of building area list"""
pass
class BuildSitesListResponse(BaseResponse):
"""Response model for building sites list endpoint"""
uu_id: UUID
address_id: int
site_name: str
site_value: float
created_at: datetime
updated_at: Optional[datetime]
deleted: bool = False
class BuildSitesListCollection(CrudCollection[BuildSitesListResponse]):
"""Collection of building sites list"""
pass
class BuildTypesListResponse(BaseResponse):
"""Response model for building types list endpoint"""
uu_id: UUID
type_name: str
type_value: str
created_at: datetime
updated_at: Optional[datetime]
deleted: bool = False
class BuildTypesListCollection(CrudCollection[BuildTypesListResponse]):
"""Collection of building types list"""
pass
class BuildTypesResponse(BaseResponse):
"""Response model for building types"""
function_code: str
type_code: str
lang: str = "TR"
class BuildTypesCollection(CrudCollection[BuildTypesResponse]):
"""Collection of building types"""
pass
class Part2EmployeeResponse(BaseResponse):
"""Response model for part to employee mapping"""
build_id: int
part_id: int
employee_id: int
class Part2EmployeeCollection(CrudCollection[Part2EmployeeResponse]):
"""Collection of part to employee mappings"""
pass
class RelationshipEmployee2BuildResponse(BaseResponse):
"""Response model for employee to build relationship"""
company_id: int
employee_id: int
member_id: int
relationship_type: Optional[str] = "Employee"
show_only: bool = False
class RelationshipEmployee2BuildCollection(
CrudCollection[RelationshipEmployee2BuildResponse]
):
"""Collection of employee to build relationships"""
pass
class BuildResponse(BaseResponse):
"""Response model for buildings"""
gov_address_code: str = ""
build_name: str
build_no: str
max_floor: int = 1
underground_floor: int = 0
build_date: datetime
decision_period_date: datetime
tax_no: str = ""
lift_count: int = 0
heating_system: bool = True
cooling_system: bool = False
hot_water_system: bool = False
block_service_man_count: int = 0
security_service_man_count: int = 0
garage_count: int = 0
management_room_id: Optional[int]
site_id: Optional[int]
site_uu_id: Optional[str]
address_id: int
address_uu_id: str
build_types_id: int
build_types_uu_id: Optional[str]
class BuildCollection(CrudCollection[BuildResponse]):
"""Collection of buildings"""
pass
class BuildPartsResponse(BaseResponse):
"""Response model for building parts"""
address_gov_code: str
part_no: int = 0
part_level: int = 0
part_code: str
part_gross_size: int = 0
part_net_size: int = 0
default_accessory: str = "0"
human_livable: bool = True
due_part_key: str
build_id: int
build_uu_id: str
part_direction_id: Optional[int]
part_direction_uu_id: Optional[str]
part_type_id: int
part_type_uu_id: str
class BuildPartsCollection(CrudCollection[BuildPartsResponse]):
"""Collection of building parts"""
pass
class BuildLivingSpaceResponse(BaseResponse):
"""Response model for building living space"""
fix_value: Decimal = Decimal("0")
fix_percent: Decimal = Decimal("0")
agreement_no: str = ""
marketing_process: bool = False
marketing_layer: int = 0
build_parts_id: int
build_parts_uu_id: str
person_id: int
person_uu_id: str
occupant_type: int
occupant_type_uu_id: str
class BuildLivingSpaceCollection(CrudCollection[BuildLivingSpaceResponse]):
"""Collection of building living spaces"""
pass
class BuildManagementResponse(BaseResponse):
"""Response model for building management"""
discounted_percentage: Decimal = Decimal("0.00")
discounted_price: Decimal = Decimal("0.00")
calculated_price: Decimal = Decimal("0.00")
occupant_type: int
occupant_type_uu_id: str
build_id: int
build_uu_id: str
build_parts_id: int
build_parts_uu_id: str
class BuildManagementCollection(CrudCollection[BuildManagementResponse]):
"""Collection of building management records"""
pass
class BuildAreaResponse(BaseResponse):
"""Response model for building area"""
area_name: str = ""
area_code: str = ""
area_type: str = "GREEN"
area_direction: str = "NN"
area_gross_size: Decimal = Decimal("0")
area_net_size: Decimal = Decimal("0")
width: int = 0
size: int = 0
build_id: int
build_uu_id: str
part_type_id: Optional[int]
part_type_uu_id: Optional[str]
class BuildAreaCollection(CrudCollection[BuildAreaResponse]):
"""Collection of building areas"""
pass
class BuildSitesResponse(BaseResponse):
"""Response model for building sites"""
site_name: str
site_no: str
address_id: int
address_uu_id: Optional[str]
class BuildSitesCollection(CrudCollection[BuildSitesResponse]):
"""Collection of building sites"""
pass
class BuildCompaniesProvidingResponse(BaseResponse):
"""Response model for building companies providing services"""
build_id: int
build_uu_id: Optional[str]
company_id: int
company_uu_id: Optional[str]
provide_id: Optional[int]
provide_uu_id: Optional[str]
contract_id: Optional[int]
class BuildCompaniesProvidingCollection(
CrudCollection[BuildCompaniesProvidingResponse]
):
"""Collection of building companies providing services"""
pass
class BuildPersonProvidingResponse(BaseResponse):
"""Response model for building person providing services"""
build_id: int
build_uu_id: Optional[str]
people_id: int
people_uu_id: Optional[str]
provide_id: Optional[int]
provide_uu_id: Optional[str]
contract_id: Optional[int]
class BuildPersonProvidingCollection(CrudCollection[BuildPersonProvidingResponse]):
"""Collection of building person providing services"""
pass

View File

@@ -0,0 +1,59 @@
from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime
from uuid import UUID
class CompanyListResponse(BaseModel):
"""Response model for company list endpoint"""
uu_id: UUID
company_name: str
company_code: str
company_email: str
company_phone: str
company_address: str
created_at: datetime
updated_at: Optional[datetime]
deleted: bool = False
class CompanyDepartmentListResponse(BaseModel):
"""Response model for company department list endpoint"""
uu_id: UUID
department_name: str
department_code: str
company_id: int
company_uu_id: str
created_at: datetime
updated_at: Optional[datetime]
deleted: bool = False
class CompanyDutyListResponse(BaseModel):
"""Response model for company duty list endpoint"""
uu_id: UUID
duty_name: str
duty_code: str
department_id: int
department_uu_id: str
created_at: datetime
updated_at: Optional[datetime]
deleted: bool = False
class CompanyEmployeeListResponse(BaseModel):
"""Response model for company employee list endpoint"""
uu_id: UUID
employee_id: int
employee_uu_id: str
company_id: int
company_uu_id: str
duty_id: int
duty_uu_id: str
created_at: datetime
updated_at: Optional[datetime]
deleted: bool = False

View File

@@ -0,0 +1,204 @@
from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime
from uuid import UUID
from decimal import Decimal
from .base_responses import BaseResponse, CrudCollection
class BuildDecisionBookResponse(BaseResponse):
"""Response model for building decision book"""
decision_book_pdf_path: Optional[str] = ""
resp_company_fix_wage: float = 0
contact_agreement_path: Optional[str] = ""
contact_agreement_date: Optional[datetime]
meeting_date: Optional[str]
decision_type: Optional[str]
class BuildDecisionBookCollection(CrudCollection[BuildDecisionBookResponse]):
"""Collection of building decision books"""
pass
class BuildDecisionBookInvitationsResponse(BaseResponse):
"""Response model for building decision book invitations"""
build_id: int
build_uu_id: Optional[str]
decision_book_id: int
decision_book_uu_id: Optional[str]
invitation_type: str
invitation_attempt: int = 1
living_part_count: int = 1
living_part_percentage: Decimal = Decimal("0.51")
message: Optional[str]
planned_date: datetime
planned_date_expires: datetime
class BuildDecisionBookInvitationsCollection(
CrudCollection[BuildDecisionBookInvitationsResponse]
):
"""Collection of building decision book invitations"""
pass
class BuildDecisionBookPersonResponse(BaseResponse):
"""Response model for building decision book person"""
dues_percent_discount: int = 0
dues_fix_discount: Decimal = Decimal("0")
dues_discount_approval_date: datetime
send_date: datetime
is_attending: bool = False
confirmed_date: Optional[datetime]
token: str = ""
vicarious_person_id: Optional[int]
vicarious_person_uu_id: Optional[str]
invite_id: int
invite_uu_id: str
build_decision_book_id: int
build_decision_book_uu_id: str
build_living_space_id: int
build_living_space_uu_id: Optional[str]
person_id: int
class BuildDecisionBookPersonCollection(
CrudCollection[BuildDecisionBookPersonResponse]
):
"""Collection of building decision book persons"""
pass
class BuildDecisionBookPersonOccupantsResponse(BaseResponse):
"""Response model for building decision book person occupants"""
build_decision_book_person_id: int
build_decision_book_person_uu_id: Optional[str]
invite_id: Optional[int]
invite_uu_id: Optional[str]
occupant_type_id: int
occupant_type_uu_id: Optional[str]
class BuildDecisionBookPersonOccupantsCollection(
CrudCollection[BuildDecisionBookPersonOccupantsResponse]
):
"""Collection of building decision book person occupants"""
pass
class BuildDecisionBookItemsResponse(BaseResponse):
"""Response model for building decision book items"""
item_order: int
item_comment: str
item_objection: Optional[str]
info_is_completed: bool = False
is_payment_created: bool = False
info_type_id: Optional[int]
info_type_uu_id: Optional[str]
build_decision_book_id: int
build_decision_book_uu_id: Optional[str]
item_short_comment: Optional[str]
class BuildDecisionBookItemsCollection(CrudCollection[BuildDecisionBookItemsResponse]):
"""Collection of building decision book items"""
pass
class BuildDecisionBookItemsUnapprovedResponse(BaseResponse):
"""Response model for building decision book items unapproved"""
item_objection: str
item_order: int
decision_book_item_id: int
decision_book_item_uu_id: Optional[str]
person_id: int
person_uu_id: Optional[str]
build_decision_book_item: int
build_decision_book_item_uu_id: Optional[str]
class BuildDecisionBookItemsUnapprovedCollection(
CrudCollection[BuildDecisionBookItemsUnapprovedResponse]
):
"""Collection of building decision book items unapproved"""
pass
class BuildDecisionBookPaymentsResponse(BaseResponse):
"""Response model for building decision book payments"""
payment_plan_time_periods: str
process_date: datetime
payment_amount: Decimal
currency: str = "TRY"
payment_types_id: Optional[int]
payment_types_uu_id: Optional[str]
period_time: str
process_date_y: int
process_date_m: int
build_decision_book_item_id: int
build_decision_book_item_uu_id: str
build_parts_id: int
build_parts_uu_id: str
decision_book_project_id: Optional[int]
decision_book_project_uu_id: Optional[str]
account_records_id: Optional[int]
account_records_uu_id: Optional[str]
class BuildDecisionBookPaymentsCollection(
CrudCollection[BuildDecisionBookPaymentsResponse]
):
"""Collection of building decision book payments"""
pass
class BuildDecisionBookLegalResponse(BaseResponse):
"""Response model for building decision book legal"""
period_start_date: datetime
lawsuits_decision_number: str
lawsuits_decision_date: datetime
period_stop_date: datetime
decision_book_pdf_path: Optional[str] = ""
resp_company_total_wage: Optional[Decimal] = Decimal("0")
contact_agreement_path: Optional[str] = ""
contact_agreement_date: Optional[datetime]
meeting_date: str
lawsuits_type: str = "C"
lawsuits_name: str
lawsuits_note: str
lawyer_cost: Decimal
mediator_lawyer_cost: Decimal
other_cost: Decimal
legal_cost: Decimal
approved_cost: Decimal
total_price: Decimal
build_db_item_id: int
build_db_item_uu_id: Optional[str]
resp_attorney_id: int
resp_attorney_uu_id: Optional[str]
resp_attorney_company_id: int
resp_attorney_company_uu_id: Optional[str]
mediator_lawyer_person_id: int
mediator_lawyer_person_uu_id: Optional[str]
class BuildDecisionBookLegalCollection(CrudCollection[BuildDecisionBookLegalResponse]):
"""Collection of building decision book legal records"""
pass

View File

@@ -0,0 +1,175 @@
from ast import Dict
from typing import Any, Optional
from fastapi import status
from fastapi.responses import JSONResponse
class BaseEndpointResponse:
def __init__(self, code: str, lang: str):
self.code = code
self.lang = lang
def retrieve_message(self):
messages = {}
return messages[self.code][self.lang]
# 1. 200 OK
class EndpointSuccessResponse(BaseEndpointResponse):
def as_dict(self, data: Optional[Dict[str, Any]] = None):
return JSONResponse(
status_code=status.HTTP_200_OK,
content=dict(
completed=True,
message=self.retrieve_message(),
lang=self.lang,
data=data
)
)
# 2. 201 Created
class EndpointCreatedResponse(BaseEndpointResponse):
def as_dict(self, data: Optional[Dict[str, Any]] = None):
return JSONResponse(
status_code=status.HTTP_201_CREATED,
content=dict(
completed=True,
message=self.retrieve_message(),
lang=self.lang,
data=data
)
)
# 3. 202 Accepted
class EndpointAcceptedResponse(BaseEndpointResponse):
def as_dict(self, data: Optional[Dict[str, Any]] = None):
return JSONResponse(
status_code=status.HTTP_202_ACCEPTED,
content=dict(
completed=True,
message=self.retrieve_message(),
lang=self.lang,
data=data
)
)
# 4. 400 Bad Request
class EndpointBadRequestResponse(BaseEndpointResponse):
def as_dict(self, data: Optional[Dict[str, Any]] = None):
return JSONResponse(
status_code=status.HTTP_400_BAD_REQUEST,
content=dict(
completed=False,
message=self.retrieve_message(),
lang=self.lang,
data=data
)
)
# 5. 401 Unauthorized
class EndpointUnauthorizedResponse(BaseEndpointResponse):
def as_dict(self):
return JSONResponse(
status_code=status.HTTP_401_UNAUTHORIZED,
content=dict(
completed=False,
message=self.retrieve_message(),
lang=self.lang
)
)
# 6. 404 Not Found
class EndpointNotFoundResponse(BaseEndpointResponse):
def as_dict(self):
return JSONResponse(
status_code=status.HTTP_404_NOT_FOUND,
content=dict(
completed=False,
message=self.retrieve_message(),
lang=self.lang
)
)
# 3. 403 Forbidden
class EndpointForbiddenResponse(BaseEndpointResponse):
def as_dict(self):
return JSONResponse(
status_code=status.HTTP_403_FORBIDDEN,
content=dict(
completed=False,
message=self.retrieve_message(),
lang=self.lang
)
)
# 6. 409 Conflict
class EndpointConflictResponse(BaseEndpointResponse):
def as_dict(self):
return JSONResponse(
status_code=status.HTTP_409_CONFLICT,
content=dict(
completed=False,
message=self.retrieve_message(),
lang=self.lang
)
)
# 7. 429 Too Many Requests
class EndpointTooManyRequestsResponse(BaseEndpointResponse):
def __init__(self, retry_after: int):
self.retry_after = retry_after
def as_dict(self):
return JSONResponse(
status_code=status.HTTP_429_TOO_MANY_REQUESTS,
headers={"Retry-After": str(self.retry_after)},
content=dict(
completed=False,
message=self.retrieve_message(),
lang=self.lang
)
)
# 7. 500 Internal Server Error
class EndpointInternalErrorResponse(BaseEndpointResponse):
def as_dict(self):
return JSONResponse(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
content=dict(
completed=False,
message=self.retrieve_message(),
lang=self.lang
)
)
class EndpointErrorResponse(BaseEndpointResponse):
def as_dict(self):
return JSONResponse(
status_code=status.HTTP_304_NOT_MODIFIED,
content=dict(
completed=False,
message=self.retrieve_message(),
lang=self.lang
)
)

View File

@@ -0,0 +1,52 @@
from typing import Optional
from api_validations.core_validations import BaseModelRegular
from api_validations.validations_request import (
CrudRecordValidation,
CrudRecords,
)
class LivingSpaceListValidation:
tr = {
**CrudRecordValidation.tr,
"fix_value": "Sabit Değer",
"fix_percent": "Sabit Yüzde",
"agreement_no": "Anlaşma No",
"marketing_process": "Pazarlama Süreci",
"marketing_layer": "Pazarlama Katmanı",
"build_parts_id": "Bölüm ID",
"build_parts_uu_id": "Bölüm UUID",
"person_id": "Sorumlu Kişi ID",
"person_uu_id": "Sorumlu Kişi UUID",
"occupant_type": "Kiracı Tipi",
"occupant_type_uu_id": "Kiracı Tipi UUID",
}
en = {
**CrudRecordValidation.en,
"fix_value": "Fixed Value",
"fix_percent": "Fixed Percent",
"agreement_no": "Agreement No",
"marketing_process": "Marketing Process",
"marketing_layer": "Marketing Layer",
"build_parts_id": "Part ID",
"build_parts_uu_id": "Part UUID",
"person_id": "Responsible Person ID",
"person_uu_id": "Responsible Person UUID",
"occupant_type": "Occupant Type",
"occupant_type_uu_id": "Occupant Type UUID",
}
class LivingSpaceListResponse(BaseModelRegular, CrudRecords, LivingSpaceListValidation):
fix_value: Optional[float] = None
fix_percent: Optional[float] = None
agreement_no: Optional[str] = None
marketing_process: Optional[str] = None
marketing_layer: Optional[str] = None
build_parts_id: Optional[int] = None
build_parts_uu_id: Optional[str] = None
person_id: Optional[int] = None
person_uu_id: Optional[str] = None
occupant_type: Optional[str] = None
occupant_type_uu_id: Optional[str] = None

View File

@@ -0,0 +1,54 @@
from typing import Optional
from api_validations.core_validations import BaseModelRegular
from api_validations.validations_request import (
CrudRecordValidation,
CrudRecords,
)
class BuildPartsListValidation:
tr = {
**CrudRecordValidation.tr,
"address_gov_code": "Adres Kapı Kodu",
"part_no": "Bölüm No",
"part_level": "Bölüm Seviyesi",
"part_code": "Bölüm Kodu",
"part_gross": "Bölüm Brüt",
"part_net": "Bölüm Net",
"default_accessory": "Varsayılan Aksesuar",
"human_livable": "İnsan Yaşamı",
"due_part_key": "Sabit Ödeme Grubu",
"build_uu_id": "Bina UUID",
"part_direction_uu_id": "Bölüm Yönü UUID",
"part_type_uu_id": "Bölüm Tipi UUID",
}
en = {
**CrudRecordValidation.en,
"address_gov_code": "Address Government Code",
"part_no": "Part Number",
"part_level": "Part Level",
"part_code": "Part Code",
"part_gross": "Part Gross",
"part_net": "Part Net",
"default_accessory": "Default Accessory",
"human_livable": "Human Livable",
"due_part_key": "Constant Payment Group",
"build_uu_id": "Building UUID",
"part_direction_uu_id": "Part Direction UUID",
"part_type_uu_id": "Part Type UUID",
}
class BuildPartsListResponse(BaseModelRegular, CrudRecords, BuildPartsListValidation):
address_gov_code: Optional[str] = None
part_no: Optional[int] = None
part_level: Optional[int] = None
part_code: Optional[str] = None
part_gross: Optional[int] = None
part_net: Optional[int] = None
default_accessory: Optional[str] = None
human_livable: Optional[bool] = None
due_part_key: Optional[str] = None
build_uu_id: Optional[str] = None
part_direction_uu_id: Optional[str] = None
part_type_uu_id: Optional[str] = None

View File

@@ -0,0 +1,57 @@
from typing import Optional
from api_validations.core_validations import BaseModelRegular
from api_validations.validations_request import (
CrudRecordValidation,
CrudRecords,
)
class PeopleListValidation:
tr = {
**CrudRecordValidation.tr,
"firstname": "Ad",
"surname": "Soyad",
"middle_name": "Orta İsim",
"sex_code": "Cinsiyet Kodu",
"person_ref": "Kişi Referansı",
"person_tag": "Kişi Etiketi",
"father_name": "Baba Adı",
"mother_name": "Anne Adı",
"country_code": "Ülke Kodu",
"national_identity_id": "Kimlik Numarası",
"birth_place": "Doğum Yeri",
"birth_date": "Doğum Tarihi",
"tax_no": "Vergi Numarası",
}
en = {
**CrudRecordValidation.en,
"firstname": "First Name",
"surname": "Surname",
"middle_name": "Middle Name",
"sex_code": "Sex Code",
"person_ref": "Person Reference",
"person_tag": "Person Tag",
"father_name": "Father's Name",
"mother_name": "Mother's Name",
"country_code": "Country Code",
"national_identity_id": "National Identity ID",
"birth_place": "Birth Place",
"birth_date": "Birth Date",
"tax_no": "Tax Number",
}
class PeopleListResponse(BaseModelRegular, CrudRecords, PeopleListValidation):
firstname: Optional[str] = None
surname: Optional[str] = None
middle_name: Optional[str] = None
sex_code: Optional[str] = None
person_ref: Optional[str] = None
person_tag: Optional[str] = None
father_name: Optional[str] = None
mother_name: Optional[str] = None
country_code: Optional[str] = None
national_identity_id: Optional[str] = None
birth_place: Optional[str] = None
birth_date: Optional[str] = None
tax_no: Optional[str] = None

View File

View File

@@ -0,0 +1,58 @@
"""
Base validation models and utilities.
"""
from pydantic import BaseModel, ConfigDict
def rewrite_input_data(data):
"""Remove empty and None values from input data."""
return {
item[0]: item[1]
for item in data.items()
if not item[1] == "" and item[1] is not None
}
class BaseModelRegular(BaseModel):
"""Base model for all validation models with proper schema handling."""
model_config = ConfigDict(
json_schema_extra={"example": {}} # Will be populated by subclasses
)
def __init__(self, **kwargs):
super().__init__(**rewrite_input_data(kwargs))
def excluded_dump(self):
return self.model_dump(exclude_unset=True, exclude_none=True)
def dump(self):
return self.model_dump()
@classmethod
def model_json_schema(cls, *args, **kwargs):
"""Generate JSON schema with proper examples."""
schema = super().model_json_schema(*args, **kwargs)
# Add examples based on field types
if "properties" in schema:
example = {}
for field_name, field_schema in schema["properties"].items():
field_type = field_schema.get("type")
if field_type == "string":
example[field_name] = f"example_{field_name}"
elif field_type == "integer":
example[field_name] = 0
elif field_type == "number":
example[field_name] = 0.0
elif field_type == "boolean":
example[field_name] = False
elif field_type == "array":
example[field_name] = []
elif field_type == "object":
example[field_name] = {}
schema["example"] = example
return schema