import { AddressType } from '../value-objects/address-type';

export class Address {
  constructor(
    public readonly id: string,
    public readonly address: string,
    public readonly type: AddressType,
    public readonly walletId: string,
    public readonly isPrimary: boolean,
    public readonly createdAt: Date,
    public readonly updatedAt: Date,
  ) {}

  public static create(
    id: string,
    address: string,
    type: AddressType,
    walletId: string,
    isPrimary = false,
  ): Address {
    const now = new Date();
    return new Address(id, address, type, walletId, isPrimary, now, now);
  }

  public setPrimary(isPrimary: boolean): Address {
    return new Address(
      this.id,
      this.address,
      this.type,
      this.walletId,
      isPrimary,
      this.createdAt,
      new Date(),
    );
  }
}
