import { DataTypes, Model } from 'sequelize';
import sequelize from '../../config/sequelize';

class Rental extends Model {
    public id!: number;
    public post_token!: string;
    public title!: string | null;
    public deposit!: number | null;
    public rent!: number | null;
    public is_full_rent!: boolean;
    public is_non_convertible!: boolean;
    public source_url!: string;
    public image_url!: string | null;
    public tags!: string | null;
    public posted_at!: string | null;
    public agent!: string | null;
    public is_promoted!: boolean;
    public elevator!: boolean | null;
    public parking!: boolean | null;
    public cabinet!: boolean | null;
    public balcony!: boolean | null;
    public phone!: string | null;
    public area!: number | null;
    public land_area!: number | null;
    public construction_year!: number | null;
    public rooms!: number | null;
    public floor!: number | null;
    public description!: string | null;
    public address!: string | null;
    public latitude!: number | null;
    public longitude!: number | null;
    public category_l1!: string | null;
    public category_l2!: string | null;
    public category_l3!: string | null;
    public image_count!: number | null;
    public fetched_at!: Date;
    public city_name!: string | null;
    public city_id!: string | null;
    public units_per_floor!: number | null;
    public building_direction!: string | null;
    public unit_status!: string | null;
    public floor_material!: string | null;
    public bathroom_type!: string | null;
    public heating_system!: string | null;
    public water_heater!: string | null;
}

Rental.init({
    id: {
        type: DataTypes.INTEGER,
        autoIncrement: true,
        primaryKey: true
    },
    post_token: {
        type: DataTypes.STRING,
        allowNull: false
    },
    title: DataTypes.STRING,
    deposit: DataTypes.BIGINT,
    rent: DataTypes.BIGINT,
    is_full_rent: DataTypes.BOOLEAN,
    is_non_convertible: DataTypes.BOOLEAN,
    source_url: {
        type: DataTypes.STRING,
        allowNull: false,
        unique: true
    },
    image_url: DataTypes.STRING,
    tags: DataTypes.TEXT,
    posted_at: DataTypes.STRING,
    agent: DataTypes.STRING,
    is_promoted: DataTypes.BOOLEAN,
    elevator: DataTypes.BOOLEAN,
    parking: DataTypes.BOOLEAN,
    cabinet: DataTypes.BOOLEAN,
    balcony: DataTypes.BOOLEAN,
    phone: DataTypes.STRING,
    area: DataTypes.INTEGER,
    land_area: DataTypes.INTEGER,
    construction_year: DataTypes.INTEGER,
    rooms: DataTypes.INTEGER,
    floor: DataTypes.INTEGER,
    description: DataTypes.TEXT,
    address: DataTypes.STRING,
    latitude: DataTypes.FLOAT,
    longitude: DataTypes.FLOAT,
    category_l1: DataTypes.STRING,
    category_l2: DataTypes.STRING,
    category_l3: DataTypes.STRING,
    image_count: DataTypes.INTEGER,
    fetched_at: DataTypes.DATE,
    city_name: DataTypes.STRING,
    city_id: DataTypes.STRING,
    units_per_floor: DataTypes.INTEGER,
    building_direction: DataTypes.STRING,
    unit_status: DataTypes.STRING,
    floor_material: DataTypes.STRING,
    bathroom_type: DataTypes.STRING,
    heating_system: DataTypes.STRING,
    water_heater: DataTypes.STRING
}, {
    sequelize,
    tableName: 'rentals',
    timestamps: true
});

export default Rental;