import datetime
from fastapi.exceptions import HTTPException
from databases.sql_models.core_mixin import CrudCollection
from databases.sql_models.identity.identity import People, Users

user_dict = dict(
    user_tag="user_tag",
    email="email",
    phone_number="phone_number",
    via="via",
    avatar="avatar",
    hash_password="hash_password",
    password_token="password_token",
    remember_me=False,
    password_expires_day="password_expires_day",
    password_expiry_begins=datetime.datetime.now().__str__(),
    related_company="related_company",
)
person_dict = dict(
    firstname="firstname",
    surname="surname",
    middle_name="middle_name",
    sex_code="M",
    person_ref="person_ref",
    person_tag="person_tag",
    father_name="father_name",
    mother_name="mother_name",
    country_code="TR",
    national_identity_id="national_identity_id",
    birth_place="birth_place",
    tax_no="tax_no",
)
CrudCollection.http_exception = HTTPException
# CrudCollection.set_user_define_properties(token=None)

new_person_find_or_create = People.find_or_create(**person_dict)
new_person_find_or_create.save_via_metadata()

print("meta_data", new_person_find_or_create.meta_data)
print("new_person_find_or_create", new_person_find_or_create)

quit()
new_user_find_or_create = Users.find_or_create(**user_dict)
new_user_find_or_abort = Users.find_or_abort(**user_dict)
