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

import {
  ClientInfo,
  TransactionRequest,
  TransactionResponse,
} from '../model/types/bonus-client-info.type';

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

export const { useFetchMyBonusInfoQuery, useFetchBonusTransactionsQuery } =
  bonusApi;
