/** ID of Invoice */
export type InvoiceID = number;

/** Possible Invoice statuses */
export enum InvoiceEnumStatus {
  created = 'created',
  binded = 'binded',
  success = 'success',
  failed = 'failed',
  pending = 'pending',
  canceled = 'canceled',
  declined = 'declined',
}

/** Invoice type represents invoice data */
export type Invoice = {
  domain?: string;
  id: InvoiceID;
  code?: string;
  webhook?: string;
  amount: bigint;
  order_id?: bigint;
  status?: InvoiceEnumStatus;
  transaction?: unknown; // any json object
  createdAt?: number; // UTC time
  updatedAt?: number; // UTC time
  user_from_id?: bigint;
  user_to_id?: bigint;
  wallet_from_id?: number;
  wallet_to_id?: number;
  user_from?: {
    first_name: string;
    last_name?: string;
    photo_url?: string;
  };
  wallet_from?: {
    address?: string;
  };
};

/** CreateInvoiceData represents data needed to create invoice. */
export type CreateInvoiceData = {
  order_id: number;
  amount: number;
};

/** InvoiceStats represents statistical data about invoices. */
export type InvoiceStats = {
  count: number;
  invoice_sum: number;
};

/** DataContainer includes data and validation status. */
export type DataContainer<R> = {
  data: R | null;
  isValid: boolean;
  error?: unknown;
};

export type InvoiceUpdate = {
  data: {
    status: InvoiceEnumStatus;
    code: string; // internal track of transaction
    amount: number; // amount you will receive once payment is completed
    order_id: number; // your internal track of invoice
    sign: string;
  };
};
