import { JsonProperty } from "@tsed/common";

import { Customer } from '../entity/Customer';
import { Password } from "../util/password";

export class CustomerInsert {
    async toCustomer(): Promise<Customer> {
        const customer = new Customer()
        customer.phone = this.phone
        customer.name = this.name
        customer.phoneRelative = this.phoneRelative
        customer.email = this.email
        customer.address = this.address
        customer.gender = this.gender
        customer.password = await Password.hash(this.password)

        return customer
    }
    
    // PROPERTIES

    @JsonProperty()
    phone: string

    @JsonProperty()
    name: string;

    @JsonProperty()
    phoneRelative: string

    @JsonProperty()
    address: string

    @JsonProperty()
    password: string

    @JsonProperty()
    email: string

    @JsonProperty()
    gender: string

} // END FILE
