const request = async (method, path, body, options = {}) => {
  const response = await globalThis.fetch((options.baseUrl || "") + path, {
    method,
    headers: { "content-type": "application/json", ...(options.headers || {}) },
    body: body === undefined ? undefined : JSON.stringify(body),
  });
  const value = await response.json();
  if (!response.ok)
    throw Object.assign(new Error(value?.error?.message || "API request failed"), {
      status: response.status,
      body: value,
    });
  return value.data ?? value;
};
export const postWebhooksPayment = (params = {}, body, options = {}) => {
  void params;
  return request("POST", `/api/webhooks/payment`, body, options);
};
export const getUsersCsr = (params = {}, body, options = {}) => {
  void params;
  return request("GET", `/api/users/csr`, body, options);
};
export const getUsersSsr = (params = {}, body, options = {}) => {
  void params;
  return request("GET", `/api/users/ssr`, body, options);
};
export const postGraphqlExample = (params = {}, body, options = {}) => {
  void params;
  return request("POST", `/api/graphql-example`, body, options);
};
export const postTypedUser = (params = {}, body, options = {}) => {
  void params;
  return request("POST", `/api/typed-user`, body, options);
};
export const postLogout = (params = {}, body, options = {}) => {
  void params;
  return request("POST", `/api/logout`, body, options);
};
export const getHello = (params = {}, body, options = {}) => {
  void params;
  return request("GET", `/api/hello`, body, options);
};
export const postLogin = (params = {}, body, options = {}) => {
  void params;
  return request("POST", `/api/login`, body, options);
};
export const getEcho = (params = {}, body, options = {}) => {
  void params;
  return request("GET", `/api/echo`, body, options);
};
export const postEcho = (params = {}, body, options = {}) => {
  void params;
  return request("POST", `/api/echo`, body, options);
};
export const getMe = (params = {}, body, options = {}) => {
  void params;
  return request("GET", `/api/me`, body, options);
};
