import {
  TransactionRequest,
  TransactionResponse,
} from '@/entities/transactions/model/types';

import { baseAPI } from '@/shared/api/base-api';

import { CorporateInfoResponse } from '../model/types/corporate-client-info.type';

export const corporateApi = baseAPI.injectEndpoints({
  endpoints: (builder) => ({
    fetchMyCorporateInfo: builder.query<CorporateInfoResponse, any>({
      query: () => {
        return {
          url: '/corporate/info',
        };
      },
    }),
    fetchCorporateTransactions: builder.query<
      TransactionResponse,
      TransactionRequest
    >({
      query: (request) => {
        return {
          url: '/corporate/transactions',
          params: request,
        };
      },
    }),
  }),
});

export const {
  useFetchMyCorporateInfoQuery,
  useFetchCorporateTransactionsQuery,
} = corporateApi;
