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

import { ClientInfo } from '../model/types/bonus-client-info.type';
import {
  BonusTransactionRequest,
  BonusTransactionResponse,
} from '../model/types/bonus-transactions.type';

export const bonusApi = baseAPI.injectEndpoints({
  endpoints: (builder) => ({
    fetchMyBonusInfo: builder.query<ClientInfo, any>({
      query: () => {
        return {
          url: '/bonus/info',
        };
      },
    }),
    fetchBonusTransactions: builder.query<
      BonusTransactionResponse,
      BonusTransactionRequest
    >({
      query: (request) => {
        return {
          url: '/bonus/transactions',
          params: request,
        };
      },
    }),
  }),
});

export const { useFetchMyBonusInfoQuery, useFetchBonusTransactionsQuery } =
  bonusApi;
