All files / src/services/api/analytics campaigns.ts

25% Statements 2/8
0% Branches 0/2
0% Functions 0/1
28.57% Lines 2/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                3x                         3x                        
import { customInstance } from "..";
import { buildMerchantEndpoints } from "../utils.api";
 
interface IParams {
  filter?: string;
  productTypeName: string;
}
 
export const productTypeIDs = {
  fundraisers: 6,
  events: 5,
  invoices: 3,
  memberships: 4,
  sweepstakes: 2,
  "payment-forms": 1,
  standard: 1,
  products: 1,
};
 
// TODO: at this point we are not using this endpoint anymore
// So, it should be checked if it's needed or not
export const getCampaignStats = (params: IParams) => {
  const productTypeId =
    productTypeIDs[params.productTypeName as keyof typeof productTypeIDs];
  const baseURL = `product-types/${productTypeId}/stats`;
  let URL = baseURL;
  if (params?.filter) URL += `?${params.filter}`;
 
  return customInstance({
    url: buildMerchantEndpoints(URL),
    method: "GET",
  });
};