import { request } from './index';

export type TransactionType = {
  id: number;
  amount: number;
  date: string;
  paidFor: string;
};

export type SettleRequestType = {
  id: number;
  status: boolean;
  iban: string;
  transaction: TransactionType | null;
  created: string;
};

export async function fetchSettleRequests(): Promise<SettleRequestType[]> {
  return await request(true, { url: '/introducers/settle-requests' });
}

export type CreateSettleRequestDataType = { iban: string };

export async function createSettleRequest(
  data: CreateSettleRequestDataType
): Promise<SettleRequestType> {
  return await request(true, {
    url: '/introducers/settle-requests',
    method: 'POST',
    data
  });
}
