const ROOT_ROUTE = "/";
const ROOT_ROUTE_V2 = "/v2/";

const createRoute = (
  segments: (string | undefined)[],
  rootRoute: string = ROOT_ROUTE
): string => {
  return rootRoute + segments.filter(Boolean).join("/");
};

export const API_ROUTES = {
  session: (id?: string) => createRoute(["session", id], ROOT_ROUTE_V2),
  sessionPixels: () => createRoute(["session", "pixels"], ROOT_ROUTE_V2),
  authorization: () => createRoute(["users", "auth"]),
  paymentCheckout: () => createRoute(["payment", "checkout"], ROOT_ROUTE_V2),
  paymentSingleCheckout: () => createRoute(["payment", "checkout"]),
  funnel: () => createRoute(["session", "funnel"], ROOT_ROUTE_V2),
};
