import { CardStatus, CardTypes, BankCodeUZ, BankCodeGEO } from "@/enums";
import { Money } from "./Money";

export interface CardBalance {
  cardId: string;
  status: CardStatus;
  amount: Money;
  isSalaryLoanCard: boolean;
}

export interface Card {
  cardId: string;
  correlationId: string;
  iban: string;
  balance: Money;
  mask: string;
  pan: string;
  expirationDate: string;
  status: CardStatus;
  isBlocked: true;
  type: CardTypes;
  bankCode: BankCodeUZ;
  bankCodeString: string;
  title: string;
  isDefault: true;
  designImageUrl: string;
  color: string;
  uzTokenCorrelationId: string;
  usable: true;
  isSalaryLoanCard: true;
}

export interface CreateCardRequest {
  pickUpPointId?: number;
  latitude?: number;
  longitude?: number;
  city?: string;
  region?: string;
  address?: string;
  orderCard?: boolean;
  referrerUserName?: string;
}

export class CheckCardRequest {
  number: string | number;
  expiryMonth: string;
  expiryYear: string;
  externalIdentifier: string;

  constructor(
    number: string | number,
    expiryMonth: string,
    expiryYear: string,
    externalIdentifier?: string
  ) {
    this.number = number;
    this.expiryMonth = expiryMonth.padStart(2, "0");
    this.expiryYear = expiryYear.padStart(2, "0");
    this.externalIdentifier = externalIdentifier;
  }
}

export interface CheckCardResponse {
  phoneNumber: string;
}

export class AddCardRequest {
  number: string | number;
  expiryMonth: string;
  expiryYear: string;
  otpToken: string;
  cardType: CardTypes;
  externalIdentifier: string;

  constructor(data: {
    number?: string | number;
    expiryMonth?: number;
    expiryYear?: number;
    otpToken?: string;
    cardType?: CardTypes;
    externalIdentifier?: string;
  }) {
    this.number = data.number;
    this.expiryMonth = data.expiryMonth
      ? data.expiryMonth.toString().padStart(2, "0")
      : null;
    this.expiryYear = data.expiryYear
      ? (data.expiryYear % 100).toString().padStart(2, "0")
      : null;
    this.otpToken = data.otpToken;
    this.cardType = data.cardType;
    this.externalIdentifier = data.externalIdentifier;
  }
}

export interface CardResponse {
  card: Card;
}
