from Schemas import (
    AddressCity,
    AddressStreet,
    AddressLocality,
    AddressDistrict,
    AddressNeighborhood,
    AddressState,
    AddressCountry,
)


def create_one_address(db_session):

    address_list = []
    country = AddressCountry.find_or_create(
        country_name="TÜRKİYE", country_code="TR", db=db_session, is_confirmed=True
    )
    address_list.append(country)
    state = AddressState.find_or_create(
        state_name="TÜRKİYE",
        state_code="TR",
        phone_code="90",
        country_id=country.id,
        country_uu_id=str(country.uu_id),
        is_confirmed=True,
        db=db_session,
    )
    address_list.append(state)
    city = AddressCity.find_or_create(
        city_name="ANKARA",
        city_code="6",
        licence_plate="06",
        state_id=state.id,
        state_uu_id=str(state.uu_id),
        is_confirmed=True,
        db=db_session,
    )
    address_list.append(city)
    district = AddressDistrict.find_or_create(
        district_name="ÇANKAYA",
        district_code="1231",
        city_id=city.id,
        city_uu_id=str(city.uu_id),
        is_confirmed=True,
        db=db_session,
    )
    address_list.append(district)
    locality = AddressLocality.find_or_create(
        locality_name="MERKEZ",
        locality_code="2431",
        type_code="3",
        type_description=None,
        district_id=district.id,
        district_uu_id=str(district.uu_id),
        is_confirmed=True,
        db=db_session,
    )
    address_list.append(locality)
    neighborhood = AddressNeighborhood.find_or_create(
        neighborhood_name="AYRANCI MAHALLESİ",
        neighborhood_code="1522",
        type_code="1",
        type_description="MAHALLESİ",
        locality_id=locality.id,
        locality_uu_id=str(locality.uu_id),
        is_confirmed=True,
        db=db_session,
    )
    address_list.append(neighborhood)
    street = AddressStreet.find_or_create(
        street_name="REŞAT NURİ CADDESİ",
        type_description="CADDESİ",
        type_code="3",
        street_code="52270",
        neighborhood_id=neighborhood.id,
        neighborhood_uu_id=str(neighborhood.uu_id),
        is_confirmed=True,
        db=db_session,
    )
    address_list.append(street)
    for address_single in address_list:
        address_single.save(db=db_session)
    return
