Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

178 KB
Raw Blame
/**
 * Generated by orval v7.21.0 🍺
 * Do not edit manually.
 * authentication_service
 * OpenAPI spec version: 0.1.0
 */
import type {
  AgentApiKey,
  AgentSetupResponse,
  AiBillingErrorBody,
  AppleLoginRequest,
  ChangePlanRequest,
  ChangePlanResponse,
  CheckoutSessionV2Response,
  CodexConfigRequest,
  CodexConnectionStatus,
  CodexEnvironment,
  CodexLoginPoll,
  CodexLoginStart,
  CreateAccountMergeRequest,
  CreateCheckoutSessionV2Request,
  CreatedTeamInviteLinkResponse,
  CreateGtmInviteLinkRequest,
  CreateInProgressLinkResponse,
  CreatePortalSessionRequest,
  CreateProfilePictureUploadRequest,
  CreateTeamRequest,
  CreditCheckoutRequestBody,
  CreditCheckoutResponse,
  CreditPurchaseRequestBody,
  CreditPurchaseResponse,
  CurrentSystemStatus,
  CursorApiKeyStatus,
  CursorModelsResponse,
  EmailConnectionProviders,
  EmailConnectionProvidersParams,
  EmptyResponse,
  EnrichGithubPullRequestsProxyRequest,
  EnrichGithubPullRequestsResponse,
  ErrorResponse,
  GenerateEmailLinkRequest,
  GenericSuccessResponse,
  GetLegacyUserPermissionsResponse,
  GetNamesWithEmailRequestBody,
  GetProfilePicturesRequestBody,
  GetTeamInvitesParams,
  GetUserInfo,
  GetUserLinkExistsParams,
  GithubLinkStatusResponse,
  GithubPullRequestMergeabilityRequest,
  GithubPullRequestMergeabilityResponse,
  GmailLinkStatusResponse,
  GtmInviteLink,
  GtmInviteLinkList,
  GtmInviteOffer,
  GtmInviteOfferStatus,
  InitGithubLinkParams,
  InitGithubLinkResponse,
  InitGmailLinkParams,
  InitGmailLinkResponse,
  InitOutlookLinkParams,
  InitOutlookLinkResponse,
  InviteToTeamRequest,
  JoinTeamByInviteLinkResponse,
  ListGtmInviteLinksParams,
  MacroApiTokenParams,
  MacroApiTokenResponse,
  MergeGithubPullRequestRequest,
  MergeGithubPullRequestResponse,
  PasswordlessCallbackParams,
  PasswordlessRequest,
  PasswordlessStartedResponse,
  PasswordRequest,
  PatchTeamCrmSettingsRequest,
  PatchTeamCrmSettingsResponse,
  PatchTeamMemberPlanRequest,
  PatchTeamRequest,
  PatchUserGroupRequest,
  PatchUserOnboardingRequest,
  PatchUserTutorialRequest,
  Permission,
  PlanCatalogResponse,
  PostGetNamesRequestBody,
  ProfilePictures,
  ProfilePictureUpload,
  PublicGtmInviteLink,
  PutAgentApiKeyRequest,
  PutCursorApiKeyRequest,
  PutCursorDefaultModelRequest,
  PutProfilePictureFileRequest,
  PutProfilePictureParams,
  PutUserNameParams,
  RedeemGtmInviteLinkRequest,
  ResendFusionauthVerifyUserEmailRequest,
  SendDomainNoticeResponse,
  SendInviteBody,
  SendMobileWelcomeEmailRequest,
  SendMobileWelcomeEmailResponse,
  SetGithubPullRequestDraftRequest,
  SetGithubPullRequestDraftResponse,
  SetGithubPullRequestStateRequest,
  SetGithubPullRequestStateResponse,
  SsoLoginParams,
  SsoRequiredResponse,
  StatusUpdate,
  StripeSessionResponse,
  SubscriptionStatus,
  SystemStatus,
  SystemStatusHistory,
  Team,
  TeamInviteLinkResponse,
  TeamInviteLinkTeam,
  TeamInviteLinkTokenRequest,
  TeamInvitesResponse,
  TeamMember,
  TeamWithMembers,
  ToggleAutoJoinDomainResponse,
  ToggleNonAdminInvitesResponse,
  TrialEligibility,
  UpdateAutoReloadRequest,
  UpdateOverageRequest,
  UpstreamErrorResponse,
  UsageSnapshot,
  UserLanguage,
  UserLinkResponse,
  UserName,
  UserNames,
  UserOrganizationResponse,
  UserQuota,
  UserTokensResponse,
} from './schemas';

/**
 * @summary The agent's API key, if it has one, and whether its plan allows one.
 */
export type getAgentApiKeyResponse200 = {
  data: AgentApiKey;
  status: 200;
};

export type getAgentApiKeyResponse401 = {
  data: string;
  status: 401;
};

export type getAgentApiKeyResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type getAgentApiKeyResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type getAgentApiKeyResponseSuccess = getAgentApiKeyResponse200 & {
  headers: Headers;
};
export type getAgentApiKeyResponseError = (
  | getAgentApiKeyResponse401
  | getAgentApiKeyResponse403
  | getAgentApiKeyResponse404
) & {
  headers: Headers;
};

export type getAgentApiKeyResponse =
  | getAgentApiKeyResponseSuccess
  | getAgentApiKeyResponseError;

export const getGetAgentApiKeyUrl = (agentId: string) => {
  return `/agents/${agentId}/api-key`;
};

export const getAgentApiKey = async (
  agentId: string,
  options?: RequestInit
): Promise<getAgentApiKeyResponse> => {
  const res = await fetch(getGetAgentApiKeyUrl(agentId), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getAgentApiKeyResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getAgentApiKeyResponse;
};

/**
 * @summary Registers or replaces the agent's API key, for its model's provider.
Only in-memory agents on an Anthropic or OpenAI model, on a paid plan.
 */
export type putAgentApiKeyResponse200 = {
  data: AgentApiKey;
  status: 200;
};

export type putAgentApiKeyResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type putAgentApiKeyResponse401 = {
  data: string;
  status: 401;
};

export type putAgentApiKeyResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type putAgentApiKeyResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type putAgentApiKeyResponseSuccess = putAgentApiKeyResponse200 & {
  headers: Headers;
};
export type putAgentApiKeyResponseError = (
  | putAgentApiKeyResponse400
  | putAgentApiKeyResponse401
  | putAgentApiKeyResponse403
  | putAgentApiKeyResponse404
) & {
  headers: Headers;
};

export type putAgentApiKeyResponse =
  | putAgentApiKeyResponseSuccess
  | putAgentApiKeyResponseError;

export const getPutAgentApiKeyUrl = (agentId: string) => {
  return `/agents/${agentId}/api-key`;
};

export const putAgentApiKey = async (
  agentId: string,
  putAgentApiKeyRequest: PutAgentApiKeyRequest,
  options?: RequestInit
): Promise<putAgentApiKeyResponse> => {
  const res = await fetch(getPutAgentApiKeyUrl(agentId), {
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(putAgentApiKeyRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: putAgentApiKeyResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as putAgentApiKeyResponse;
};

/**
 * @summary Forgets the agent's API key. Does not revoke it at the provider; succeeds
when there was none.
 */
export type deleteAgentApiKeyResponse200 = {
  data: AgentApiKey;
  status: 200;
};

export type deleteAgentApiKeyResponse401 = {
  data: string;
  status: 401;
};

export type deleteAgentApiKeyResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type deleteAgentApiKeyResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type deleteAgentApiKeyResponseSuccess = deleteAgentApiKeyResponse200 & {
  headers: Headers;
};
export type deleteAgentApiKeyResponseError = (
  | deleteAgentApiKeyResponse401
  | deleteAgentApiKeyResponse403
  | deleteAgentApiKeyResponse404
) & {
  headers: Headers;
};

export type deleteAgentApiKeyResponse =
  | deleteAgentApiKeyResponseSuccess
  | deleteAgentApiKeyResponseError;

export const getDeleteAgentApiKeyUrl = (agentId: string) => {
  return `/agents/${agentId}/api-key`;
};

export const deleteAgentApiKey = async (
  agentId: string,
  options?: RequestInit
): Promise<deleteAgentApiKeyResponse> => {
  const res = await fetch(getDeleteAgentApiKeyUrl(agentId), {
    ...options,
    method: 'DELETE',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: deleteAgentApiKeyResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as deleteAgentApiKeyResponse;
};

/**
 * @summary Turn automatic credit reloads on with the given
thresholds, or off. Payer only. Enabling settles right away, so a balance
already under the minimum reloads immediately.
 */
export type updateAiBillingAutoReloadResponse200 = {
  data: UsageSnapshot;
  status: 200;
};

export type updateAiBillingAutoReloadResponse400 = {
  data: AiBillingErrorBody;
  status: 400;
};

export type updateAiBillingAutoReloadResponse401 = {
  data: void;
  status: 401;
};

export type updateAiBillingAutoReloadResponse402 = {
  data: AiBillingErrorBody;
  status: 402;
};

export type updateAiBillingAutoReloadResponse403 = {
  data: AiBillingErrorBody;
  status: 403;
};

export type updateAiBillingAutoReloadResponse500 = {
  data: AiBillingErrorBody;
  status: 500;
};

export type updateAiBillingAutoReloadResponseSuccess =
  updateAiBillingAutoReloadResponse200 & {
    headers: Headers;
  };
export type updateAiBillingAutoReloadResponseError = (
  | updateAiBillingAutoReloadResponse400
  | updateAiBillingAutoReloadResponse401
  | updateAiBillingAutoReloadResponse402
  | updateAiBillingAutoReloadResponse403
  | updateAiBillingAutoReloadResponse500
) & {
  headers: Headers;
};

export type updateAiBillingAutoReloadResponse =
  | updateAiBillingAutoReloadResponseSuccess
  | updateAiBillingAutoReloadResponseError;

export const getUpdateAiBillingAutoReloadUrl = () => {
  return `/ai-billing/auto-reload`;
};

export const updateAiBillingAutoReload = async (
  updateAutoReloadRequest: UpdateAutoReloadRequest,
  options?: RequestInit
): Promise<updateAiBillingAutoReloadResponse> => {
  const res = await fetch(getUpdateAiBillingAutoReloadUrl(), {
    ...options,
    method: 'PATCH',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(updateAutoReloadRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: updateAiBillingAutoReloadResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as updateAiBillingAutoReloadResponse;
};

/**
 * @summary Start a Stripe Checkout for a credit pack. Payer only.
 */
export type createAiCreditCheckoutResponse200 = {
  data: CreditCheckoutResponse;
  status: 200;
};

export type createAiCreditCheckoutResponse400 = {
  data: AiBillingErrorBody;
  status: 400;
};

export type createAiCreditCheckoutResponse401 = {
  data: void;
  status: 401;
};

export type createAiCreditCheckoutResponse402 = {
  data: AiBillingErrorBody;
  status: 402;
};

export type createAiCreditCheckoutResponse403 = {
  data: AiBillingErrorBody;
  status: 403;
};

export type createAiCreditCheckoutResponse500 = {
  data: AiBillingErrorBody;
  status: 500;
};

export type createAiCreditCheckoutResponseSuccess =
  createAiCreditCheckoutResponse200 & {
    headers: Headers;
  };
export type createAiCreditCheckoutResponseError = (
  | createAiCreditCheckoutResponse400
  | createAiCreditCheckoutResponse401
  | createAiCreditCheckoutResponse402
  | createAiCreditCheckoutResponse403
  | createAiCreditCheckoutResponse500
) & {
  headers: Headers;
};

export type createAiCreditCheckoutResponse =
  | createAiCreditCheckoutResponseSuccess
  | createAiCreditCheckoutResponseError;

export const getCreateAiCreditCheckoutUrl = () => {
  return `/ai-billing/credits/checkout`;
};

export const createAiCreditCheckout = async (
  creditCheckoutRequestBody: CreditCheckoutRequestBody,
  options?: RequestInit
): Promise<createAiCreditCheckoutResponse> => {
  const res = await fetch(getCreateAiCreditCheckoutUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(creditCheckoutRequestBody),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: createAiCreditCheckoutResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as createAiCreditCheckoutResponse;
};

/**
 * @summary Buy a credit pack now, charged to the payer's card on file. Any paid team
member may buy, within the team's monthly credit limit.
 */
export type purchaseAiCreditsResponse200 = {
  data: CreditPurchaseResponse;
  status: 200;
};

export type purchaseAiCreditsResponse400 = {
  data: AiBillingErrorBody;
  status: 400;
};

export type purchaseAiCreditsResponse401 = {
  data: void;
  status: 401;
};

export type purchaseAiCreditsResponse402 = {
  data: AiBillingErrorBody;
  status: 402;
};

export type purchaseAiCreditsResponse409 = {
  data: AiBillingErrorBody;
  status: 409;
};

export type purchaseAiCreditsResponse500 = {
  data: AiBillingErrorBody;
  status: 500;
};

export type purchaseAiCreditsResponseSuccess = purchaseAiCreditsResponse200 & {
  headers: Headers;
};
export type purchaseAiCreditsResponseError = (
  | purchaseAiCreditsResponse400
  | purchaseAiCreditsResponse401
  | purchaseAiCreditsResponse402
  | purchaseAiCreditsResponse409
  | purchaseAiCreditsResponse500
) & {
  headers: Headers;
};

export type purchaseAiCreditsResponse =
  | purchaseAiCreditsResponseSuccess
  | purchaseAiCreditsResponseError;

export const getPurchaseAiCreditsUrl = () => {
  return `/ai-billing/credits/purchase`;
};

export const purchaseAiCredits = async (
  creditPurchaseRequestBody: CreditPurchaseRequestBody,
  options?: RequestInit
): Promise<purchaseAiCreditsResponse> => {
  const res = await fetch(getPurchaseAiCreditsUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(creditPurchaseRequestBody),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: purchaseAiCreditsResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as purchaseAiCreditsResponse;
};

/**
 * @summary Retired direct-usage opt-in. Enabling is rejected; disabling remains supported.
 */
export type updateAiBillingOverageResponse200 = {
  data: UsageSnapshot;
  status: 200;
};

export type updateAiBillingOverageResponse400 = {
  data: AiBillingErrorBody;
  status: 400;
};

export type updateAiBillingOverageResponse401 = {
  data: void;
  status: 401;
};

export type updateAiBillingOverageResponse402 = {
  data: AiBillingErrorBody;
  status: 402;
};

export type updateAiBillingOverageResponse403 = {
  data: AiBillingErrorBody;
  status: 403;
};

export type updateAiBillingOverageResponse500 = {
  data: AiBillingErrorBody;
  status: 500;
};

export type updateAiBillingOverageResponseSuccess =
  updateAiBillingOverageResponse200 & {
    headers: Headers;
  };
export type updateAiBillingOverageResponseError = (
  | updateAiBillingOverageResponse400
  | updateAiBillingOverageResponse401
  | updateAiBillingOverageResponse402
  | updateAiBillingOverageResponse403
  | updateAiBillingOverageResponse500
) & {
  headers: Headers;
};

export type updateAiBillingOverageResponse =
  | updateAiBillingOverageResponseSuccess
  | updateAiBillingOverageResponseError;

export const getUpdateAiBillingOverageUrl = () => {
  return `/ai-billing/overage`;
};

export const updateAiBillingOverage = async (
  updateOverageRequest: UpdateOverageRequest,
  options?: RequestInit
): Promise<updateAiBillingOverageResponse> => {
  const res = await fetch(getUpdateAiBillingOverageUrl(), {
    ...options,
    method: 'PATCH',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(updateOverageRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: updateAiBillingOverageResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as updateAiBillingOverageResponse;
};

/**
 * @summary The plan catalog, credit packs, overage cap bounds, and automatic reload
defaults and bounds.
 */
export type getAiBillingPlansResponse200 = {
  data: PlanCatalogResponse;
  status: 200;
};

export type getAiBillingPlansResponseSuccess = getAiBillingPlansResponse200 & {
  headers: Headers;
};

export type getAiBillingPlansResponse = getAiBillingPlansResponseSuccess;

export const getGetAiBillingPlansUrl = () => {
  return `/ai-billing/plans`;
};

export const getAiBillingPlans = async (
  options?: RequestInit
): Promise<getAiBillingPlansResponse> => {
  const res = await fetch(getGetAiBillingPlansUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getAiBillingPlansResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getAiBillingPlansResponse;
};

/**
 * Runs a settlement first so the position reflects any credits or overage
that were waiting to be booked.
 * @summary The caller's current-period AI usage, credits, and overage settings.
 */
export type getAiBillingSummaryResponse200 = {
  data: UsageSnapshot;
  status: 200;
};

export type getAiBillingSummaryResponse401 = {
  data: void;
  status: 401;
};

export type getAiBillingSummaryResponse500 = {
  data: AiBillingErrorBody;
  status: 500;
};

export type getAiBillingSummaryResponseSuccess =
  getAiBillingSummaryResponse200 & {
    headers: Headers;
  };
export type getAiBillingSummaryResponseError = (
  | getAiBillingSummaryResponse401
  | getAiBillingSummaryResponse500
) & {
  headers: Headers;
};

export type getAiBillingSummaryResponse =
  | getAiBillingSummaryResponseSuccess
  | getAiBillingSummaryResponseError;

export const getGetAiBillingSummaryUrl = () => {
  return `/ai-billing/summary`;
};

export const getAiBillingSummary = async (
  options?: RequestInit
): Promise<getAiBillingSummaryResponse> => {
  const res = await fetch(getGetAiBillingSummaryUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getAiBillingSummaryResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getAiBillingSummaryResponse;
};

export type getCodexConnectionResponse200 = {
  data: CodexConnectionStatus;
  status: 200;
};

export type getCodexConnectionResponseSuccess =
  getCodexConnectionResponse200 & {
    headers: Headers;
  };

export type getCodexConnectionResponse = getCodexConnectionResponseSuccess;

export const getGetCodexConnectionUrl = () => {
  return `/codex`;
};

export const getCodexConnection = async (
  options?: RequestInit
): Promise<getCodexConnectionResponse> => {
  const res = await fetch(getGetCodexConnectionUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getCodexConnectionResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getCodexConnectionResponse;
};

export type disconnectCodexResponse204 = {
  data: void;
  status: 204;
};

export type disconnectCodexResponseSuccess = disconnectCodexResponse204 & {
  headers: Headers;
};

export type disconnectCodexResponse = disconnectCodexResponseSuccess;

export const getDisconnectCodexUrl = () => {
  return `/codex`;
};

export const disconnectCodex = async (
  options?: RequestInit
): Promise<disconnectCodexResponse> => {
  const res = await fetch(getDisconnectCodexUrl(), {
    ...options,
    method: 'DELETE',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: disconnectCodexResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as disconnectCodexResponse;
};

export type configureCodexResponse200 = {
  data: CodexConnectionStatus;
  status: 200;
};

export type configureCodexResponseSuccess = configureCodexResponse200 & {
  headers: Headers;
};

export type configureCodexResponse = configureCodexResponseSuccess;

export const getConfigureCodexUrl = () => {
  return `/codex/config`;
};

export const configureCodex = async (
  codexConfigRequest: CodexConfigRequest,
  options?: RequestInit
): Promise<configureCodexResponse> => {
  const res = await fetch(getConfigureCodexUrl(), {
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(codexConfigRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: configureCodexResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as configureCodexResponse;
};

export type listCodexEnvironmentsResponse200 = {
  data: CodexEnvironment[];
  status: 200;
};

export type listCodexEnvironmentsResponseSuccess =
  listCodexEnvironmentsResponse200 & {
    headers: Headers;
  };

export type listCodexEnvironmentsResponse =
  listCodexEnvironmentsResponseSuccess;

export const getListCodexEnvironmentsUrl = () => {
  return `/codex/environments`;
};

export const listCodexEnvironments = async (
  options?: RequestInit
): Promise<listCodexEnvironmentsResponse> => {
  const res = await fetch(getListCodexEnvironmentsUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: listCodexEnvironmentsResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as listCodexEnvironmentsResponse;
};

export type startCodexLoginResponse200 = {
  data: CodexLoginStart;
  status: 200;
};

export type startCodexLoginResponseSuccess = startCodexLoginResponse200 & {
  headers: Headers;
};

export type startCodexLoginResponse = startCodexLoginResponseSuccess;

export const getStartCodexLoginUrl = () => {
  return `/codex/login`;
};

export const startCodexLogin = async (
  options?: RequestInit
): Promise<startCodexLoginResponse> => {
  const res = await fetch(getStartCodexLoginUrl(), {
    ...options,
    method: 'POST',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: startCodexLoginResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as startCodexLoginResponse;
};

export type pollCodexLoginResponse200 = {
  data: CodexLoginPoll;
  status: 200;
};

export type pollCodexLoginResponseSuccess = pollCodexLoginResponse200 & {
  headers: Headers;
};

export type pollCodexLoginResponse = pollCodexLoginResponseSuccess;

export const getPollCodexLoginUrl = (attemptId: string) => {
  return `/codex/login/${attemptId}`;
};

export const pollCodexLogin = async (
  attemptId: string,
  options?: RequestInit
): Promise<pollCodexLoginResponse> => {
  const res = await fetch(getPollCodexLoginUrl(attemptId), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: pollCodexLoginResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as pollCodexLoginResponse;
};

export type cancelCodexLoginResponse204 = {
  data: void;
  status: 204;
};

export type cancelCodexLoginResponseSuccess = cancelCodexLoginResponse204 & {
  headers: Headers;
};

export type cancelCodexLoginResponse = cancelCodexLoginResponseSuccess;

export const getCancelCodexLoginUrl = (attemptId: string) => {
  return `/codex/login/${attemptId}`;
};

export const cancelCodexLogin = async (
  attemptId: string,
  options?: RequestInit
): Promise<cancelCodexLoginResponse> => {
  const res = await fetch(getCancelCodexLoginUrl(attemptId), {
    ...options,
    method: 'DELETE',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: cancelCodexLoginResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as cancelCodexLoginResponse;
};

/**
 * Never returns the key, or any part of it. There is no screen that needs one,
and a masked key still leaks its length and alphabet.
 * @summary Whether the caller has a Cursor API key registered.
 */
export type getCursorApiKeyResponse200 = {
  data: CursorApiKeyStatus;
  status: 200;
};

export type getCursorApiKeyResponse401 = {
  data: string;
  status: 401;
};

export type getCursorApiKeyResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type getCursorApiKeyResponseSuccess = getCursorApiKeyResponse200 & {
  headers: Headers;
};
export type getCursorApiKeyResponseError = (
  | getCursorApiKeyResponse401
  | getCursorApiKeyResponse403
) & {
  headers: Headers;
};

export type getCursorApiKeyResponse =
  | getCursorApiKeyResponseSuccess
  | getCursorApiKeyResponseError;

export const getGetCursorApiKeyUrl = () => {
  return `/cursor-api-key`;
};

export const getCursorApiKey = async (
  options?: RequestInit
): Promise<getCursorApiKeyResponse> => {
  const res = await fetch(getGetCursorApiKeyUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getCursorApiKeyResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getCursorApiKeyResponse;
};

/**
 * The key is validated on shape alone — this cannot distinguish a live key
from forty random characters behind the right prefix. Confirming it against
Cursor's `GET /v1/me` is the obvious improvement, and is what would let this
report the connected account rather than only that a key exists.
 * @summary Registers or replaces the caller's Cursor API key.
 */
export type putCursorApiKeyResponse200 = {
  data: CursorApiKeyStatus;
  status: 200;
};

export type putCursorApiKeyResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type putCursorApiKeyResponse401 = {
  data: string;
  status: 401;
};

export type putCursorApiKeyResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type putCursorApiKeyResponseSuccess = putCursorApiKeyResponse200 & {
  headers: Headers;
};
export type putCursorApiKeyResponseError = (
  | putCursorApiKeyResponse400
  | putCursorApiKeyResponse401
  | putCursorApiKeyResponse403
) & {
  headers: Headers;
};

export type putCursorApiKeyResponse =
  | putCursorApiKeyResponseSuccess
  | putCursorApiKeyResponseError;

export const getPutCursorApiKeyUrl = () => {
  return `/cursor-api-key`;
};

export const putCursorApiKey = async (
  putCursorApiKeyRequest: PutCursorApiKeyRequest,
  options?: RequestInit
): Promise<putCursorApiKeyResponse> => {
  const res = await fetch(getPutCursorApiKeyUrl(), {
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(putCursorApiKeyRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: putCursorApiKeyResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as putCursorApiKeyResponse;
};

/**
 * This does **not** revoke the key at Cursor — it keeps working everywhere
else it is used, and only Cursor can revoke it. Any UI offering this has to
say so rather than implying otherwise.

Deleting when there is nothing to delete succeeds: the caller's intent is
"I should have no key registered", and that is already true.
 * @summary Forgets the caller's Cursor API key.
 */
export type deleteCursorApiKeyResponse200 = {
  data: CursorApiKeyStatus;
  status: 200;
};

export type deleteCursorApiKeyResponse401 = {
  data: string;
  status: 401;
};

export type deleteCursorApiKeyResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type deleteCursorApiKeyResponseSuccess =
  deleteCursorApiKeyResponse200 & {
    headers: Headers;
  };
export type deleteCursorApiKeyResponseError = (
  | deleteCursorApiKeyResponse401
  | deleteCursorApiKeyResponse403
) & {
  headers: Headers;
};

export type deleteCursorApiKeyResponse =
  | deleteCursorApiKeyResponseSuccess
  | deleteCursorApiKeyResponseError;

export const getDeleteCursorApiKeyUrl = () => {
  return `/cursor-api-key`;
};

export const deleteCursorApiKey = async (
  options?: RequestInit
): Promise<deleteCursorApiKeyResponse> => {
  const res = await fetch(getDeleteCursorApiKeyUrl(), {
    ...options,
    method: 'DELETE',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: deleteCursorApiKeyResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as deleteCursorApiKeyResponse;
};

/**
 * Stores the id only; its parameters are resolved from Cursor's own default
variant at session start. Not validated against the live model list here —
the settings dropdown offers only real ids, and a stale id degrades to the
deployment default at spawn rather than failing, so a round trip to Cursor
on every save would buy nothing.
 * @summary Choose the model this user's `@cursor` sessions start on.
 */
export type putCursorDefaultModelResponse200 = {
  data: CursorApiKeyStatus;
  status: 200;
};

export type putCursorDefaultModelResponse401 = {
  data: string;
  status: 401;
};

export type putCursorDefaultModelResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type putCursorDefaultModelResponse409 = {
  data: ErrorResponse;
  status: 409;
};

export type putCursorDefaultModelResponseSuccess =
  putCursorDefaultModelResponse200 & {
    headers: Headers;
  };
export type putCursorDefaultModelResponseError = (
  | putCursorDefaultModelResponse401
  | putCursorDefaultModelResponse403
  | putCursorDefaultModelResponse409
) & {
  headers: Headers;
};

export type putCursorDefaultModelResponse =
  | putCursorDefaultModelResponseSuccess
  | putCursorDefaultModelResponseError;

export const getPutCursorDefaultModelUrl = () => {
  return `/cursor-api-key/default-model`;
};

export const putCursorDefaultModel = async (
  putCursorDefaultModelRequest: PutCursorDefaultModelRequest,
  options?: RequestInit
): Promise<putCursorDefaultModelResponse> => {
  const res = await fetch(getPutCursorDefaultModelUrl(), {
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(putCursorDefaultModelRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: putCursorDefaultModelResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as putCursorDefaultModelResponse;
};

/**
 * Reached only from the settings dropdown, so it decrypts the user's own key
and asks Cursor directly — the list is per-account and changes, so there is
nothing to cache statically. Reuses the harness's Cursor client rather than
reimplementing the `/v1/models` parse, keeping one source of truth for what
a model is.
 * @summary List the models the caller's Cursor account offers.
 */
export type listCursorModelsResponse200 = {
  data: CursorModelsResponse;
  status: 200;
};

export type listCursorModelsResponse401 = {
  data: string;
  status: 401;
};

export type listCursorModelsResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type listCursorModelsResponse409 = {
  data: ErrorResponse;
  status: 409;
};

export type listCursorModelsResponse502 = {
  data: ErrorResponse;
  status: 502;
};

export type listCursorModelsResponseSuccess = listCursorModelsResponse200 & {
  headers: Headers;
};
export type listCursorModelsResponseError = (
  | listCursorModelsResponse401
  | listCursorModelsResponse403
  | listCursorModelsResponse409
  | listCursorModelsResponse502
) & {
  headers: Headers;
};

export type listCursorModelsResponse =
  | listCursorModelsResponseSuccess
  | listCursorModelsResponseError;

export const getListCursorModelsUrl = () => {
  return `/cursor-api-key/models`;
};

export const listCursorModels = async (
  options?: RequestInit
): Promise<listCursorModelsResponse> => {
  const res = await fetch(getListCursorModelsUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: listCursorModelsResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as listCursorModelsResponse;
};

/**
 * @summary Verifies the user's primary email for FusionAuth
 */
export type verifyFusionauthUserEmailResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type verifyFusionauthUserEmailResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type verifyFusionauthUserEmailResponseSuccess =
  verifyFusionauthUserEmailResponse200 & {
    headers: Headers;
  };
export type verifyFusionauthUserEmailResponseError =
  verifyFusionauthUserEmailResponse500 & {
    headers: Headers;
  };

export type verifyFusionauthUserEmailResponse =
  | verifyFusionauthUserEmailResponseSuccess
  | verifyFusionauthUserEmailResponseError;

export const getVerifyFusionauthUserEmailUrl = (verificationId: string) => {
  return `/email/fusionauth/verify/${verificationId}`;
};

export const verifyFusionauthUserEmail = async (
  verificationId: string,
  options?: RequestInit
): Promise<verifyFusionauthUserEmailResponse> => {
  const res = await fetch(getVerifyFusionauthUserEmailUrl(verificationId), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: verifyFusionauthUserEmailResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as verifyFusionauthUserEmailResponse;
};

/**
 * @summary Resend the user's primary email verification for FusionAuth
 */
export type resendFusionauthVerifyUserEmailResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type resendFusionauthVerifyUserEmailResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type resendFusionauthVerifyUserEmailResponseSuccess =
  resendFusionauthVerifyUserEmailResponse200 & {
    headers: Headers;
  };
export type resendFusionauthVerifyUserEmailResponseError =
  resendFusionauthVerifyUserEmailResponse500 & {
    headers: Headers;
  };

export type resendFusionauthVerifyUserEmailResponse =
  | resendFusionauthVerifyUserEmailResponseSuccess
  | resendFusionauthVerifyUserEmailResponseError;

export const getResendFusionauthVerifyUserEmailUrl = () => {
  return `/email/fusionauth_resend`;
};

export const resendFusionauthVerifyUserEmail = async (
  resendFusionauthVerifyUserEmailRequest: ResendFusionauthVerifyUserEmailRequest,
  options?: RequestInit
): Promise<resendFusionauthVerifyUserEmailResponse> => {
  const res = await fetch(getResendFusionauthVerifyUserEmailUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(resendFusionauthVerifyUserEmailRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: resendFusionauthVerifyUserEmailResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as resendFusionauthVerifyUserEmailResponse;
};

/**
 * @summary Generates an email link for the user to verify their email address.
 */
export type generateEmailLinkResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type generateEmailLinkResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type generateEmailLinkResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type generateEmailLinkResponseSuccess = generateEmailLinkResponse200 & {
  headers: Headers;
};
export type generateEmailLinkResponseError = (
  | generateEmailLinkResponse400
  | generateEmailLinkResponse500
) & {
  headers: Headers;
};

export type generateEmailLinkResponse =
  | generateEmailLinkResponseSuccess
  | generateEmailLinkResponseError;

export const getGenerateEmailLinkUrl = () => {
  return `/email/generate/link`;
};

export const generateEmailLink = async (
  generateEmailLinkRequest: GenerateEmailLinkRequest,
  options?: RequestInit
): Promise<generateEmailLinkResponse> => {
  const res = await fetch(getGenerateEmailLinkUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(generateEmailLinkRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: generateEmailLinkResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as generateEmailLinkResponse;
};

/**
 * @summary Verifies the user's email for a user profile
 */
export type verifyEmailLinkResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type verifyEmailLinkResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type verifyEmailLinkResponseSuccess = verifyEmailLinkResponse200 & {
  headers: Headers;
};
export type verifyEmailLinkResponseError = verifyEmailLinkResponse500 & {
  headers: Headers;
};

export type verifyEmailLinkResponse =
  | verifyEmailLinkResponseSuccess
  | verifyEmailLinkResponseError;

export const getVerifyEmailLinkUrl = (verificationId: string) => {
  return `/email/verify/${verificationId}`;
};

export const verifyEmailLink = async (
  verificationId: string,
  options?: RequestInit
): Promise<verifyEmailLinkResponse> => {
  const res = await fetch(getVerifyEmailLinkUrl(verificationId), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: verifyEmailLinkResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as verifyEmailLinkResponse;
};

/**
 * @summary Converts a GitHub pull request to a draft, or marks it ready for review,
as the authenticated user with their own GitHub grant.
 */
export type setGithubPullRequestDraftResponse200 = {
  data: SetGithubPullRequestDraftResponse;
  status: 200;
};

export type setGithubPullRequestDraftResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type setGithubPullRequestDraftResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type setGithubPullRequestDraftResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type setGithubPullRequestDraftResponse422 = {
  data: ErrorResponse;
  status: 422;
};

export type setGithubPullRequestDraftResponse428 = {
  data: ErrorResponse;
  status: 428;
};

export type setGithubPullRequestDraftResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type setGithubPullRequestDraftResponse502 = {
  data: UpstreamErrorResponse;
  status: 502;
};

export type setGithubPullRequestDraftResponse503 = {
  data: UpstreamErrorResponse;
  status: 503;
};

export type setGithubPullRequestDraftResponseSuccess =
  setGithubPullRequestDraftResponse200 & {
    headers: Headers;
  };
export type setGithubPullRequestDraftResponseError = (
  | setGithubPullRequestDraftResponse401
  | setGithubPullRequestDraftResponse403
  | setGithubPullRequestDraftResponse404
  | setGithubPullRequestDraftResponse422
  | setGithubPullRequestDraftResponse428
  | setGithubPullRequestDraftResponse500
  | setGithubPullRequestDraftResponse502
  | setGithubPullRequestDraftResponse503
) & {
  headers: Headers;
};

export type setGithubPullRequestDraftResponse =
  | setGithubPullRequestDraftResponseSuccess
  | setGithubPullRequestDraftResponseError;

export const getSetGithubPullRequestDraftUrl = () => {
  return `/github_pull_requests/draft`;
};

export const setGithubPullRequestDraft = async (
  setGithubPullRequestDraftRequest: SetGithubPullRequestDraftRequest,
  options?: RequestInit
): Promise<setGithubPullRequestDraftResponse> => {
  const res = await fetch(getSetGithubPullRequestDraftUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(setGithubPullRequestDraftRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: setGithubPullRequestDraftResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as setGithubPullRequestDraftResponse;
};

/**
 * @summary Enriches GitHub pull request references with live GitHub data for the authenticated user.
 */
export type enrichGithubPullRequestsResponse200 = {
  data: EnrichGithubPullRequestsResponse;
  status: 200;
};

export type enrichGithubPullRequestsResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type enrichGithubPullRequestsResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type enrichGithubPullRequestsResponse428 = {
  data: ErrorResponse;
  status: 428;
};

export type enrichGithubPullRequestsResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type enrichGithubPullRequestsResponse502 = {
  data: UpstreamErrorResponse;
  status: 502;
};

export type enrichGithubPullRequestsResponse503 = {
  data: UpstreamErrorResponse;
  status: 503;
};

export type enrichGithubPullRequestsResponseSuccess =
  enrichGithubPullRequestsResponse200 & {
    headers: Headers;
  };
export type enrichGithubPullRequestsResponseError = (
  | enrichGithubPullRequestsResponse401
  | enrichGithubPullRequestsResponse404
  | enrichGithubPullRequestsResponse428
  | enrichGithubPullRequestsResponse500
  | enrichGithubPullRequestsResponse502
  | enrichGithubPullRequestsResponse503
) & {
  headers: Headers;
};

export type enrichGithubPullRequestsResponse =
  | enrichGithubPullRequestsResponseSuccess
  | enrichGithubPullRequestsResponseError;

export const getEnrichGithubPullRequestsUrl = () => {
  return `/github_pull_requests/enrich`;
};

export const enrichGithubPullRequests = async (
  enrichGithubPullRequestsProxyRequest: EnrichGithubPullRequestsProxyRequest,
  options?: RequestInit
): Promise<enrichGithubPullRequestsResponse> => {
  const res = await fetch(getEnrichGithubPullRequestsUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(enrichGithubPullRequestsProxyRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: enrichGithubPullRequestsResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as enrichGithubPullRequestsResponse;
};

/**
 * @summary Merges a GitHub pull request as the authenticated user, with their own
GitHub grant. GitHub applies the user's permissions and the repository's
branch protections; a refusal is returned with GitHub's message.
 */
export type mergeGithubPullRequestResponse200 = {
  data: MergeGithubPullRequestResponse;
  status: 200;
};

export type mergeGithubPullRequestResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type mergeGithubPullRequestResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type mergeGithubPullRequestResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type mergeGithubPullRequestResponse409 = {
  data: ErrorResponse;
  status: 409;
};

export type mergeGithubPullRequestResponse422 = {
  data: ErrorResponse;
  status: 422;
};

export type mergeGithubPullRequestResponse428 = {
  data: ErrorResponse;
  status: 428;
};

export type mergeGithubPullRequestResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type mergeGithubPullRequestResponse502 = {
  data: UpstreamErrorResponse;
  status: 502;
};

export type mergeGithubPullRequestResponse503 = {
  data: UpstreamErrorResponse;
  status: 503;
};

export type mergeGithubPullRequestResponseSuccess =
  mergeGithubPullRequestResponse200 & {
    headers: Headers;
  };
export type mergeGithubPullRequestResponseError = (
  | mergeGithubPullRequestResponse401
  | mergeGithubPullRequestResponse403
  | mergeGithubPullRequestResponse404
  | mergeGithubPullRequestResponse409
  | mergeGithubPullRequestResponse422
  | mergeGithubPullRequestResponse428
  | mergeGithubPullRequestResponse500
  | mergeGithubPullRequestResponse502
  | mergeGithubPullRequestResponse503
) & {
  headers: Headers;
};

export type mergeGithubPullRequestResponse =
  | mergeGithubPullRequestResponseSuccess
  | mergeGithubPullRequestResponseError;

export const getMergeGithubPullRequestUrl = () => {
  return `/github_pull_requests/merge`;
};

export const mergeGithubPullRequest = async (
  mergeGithubPullRequestRequest: MergeGithubPullRequestRequest,
  options?: RequestInit
): Promise<mergeGithubPullRequestResponse> => {
  const res = await fetch(getMergeGithubPullRequestUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(mergeGithubPullRequestRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: mergeGithubPullRequestResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as mergeGithubPullRequestResponse;
};

/**
 * @summary Reads whether each GitHub pull request merges cleanly into its base, as
the authenticated user sees it. Pull requests the user cannot see are
left out.
 */
export type getGithubPullRequestMergeabilityResponse200 = {
  data: GithubPullRequestMergeabilityResponse;
  status: 200;
};

export type getGithubPullRequestMergeabilityResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type getGithubPullRequestMergeabilityResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type getGithubPullRequestMergeabilityResponse422 = {
  data: ErrorResponse;
  status: 422;
};

export type getGithubPullRequestMergeabilityResponse428 = {
  data: ErrorResponse;
  status: 428;
};

export type getGithubPullRequestMergeabilityResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getGithubPullRequestMergeabilityResponse502 = {
  data: UpstreamErrorResponse;
  status: 502;
};

export type getGithubPullRequestMergeabilityResponse503 = {
  data: UpstreamErrorResponse;
  status: 503;
};

export type getGithubPullRequestMergeabilityResponseSuccess =
  getGithubPullRequestMergeabilityResponse200 & {
    headers: Headers;
  };
export type getGithubPullRequestMergeabilityResponseError = (
  | getGithubPullRequestMergeabilityResponse401
  | getGithubPullRequestMergeabilityResponse404
  | getGithubPullRequestMergeabilityResponse422
  | getGithubPullRequestMergeabilityResponse428
  | getGithubPullRequestMergeabilityResponse500
  | getGithubPullRequestMergeabilityResponse502
  | getGithubPullRequestMergeabilityResponse503
) & {
  headers: Headers;
};

export type getGithubPullRequestMergeabilityResponse =
  | getGithubPullRequestMergeabilityResponseSuccess
  | getGithubPullRequestMergeabilityResponseError;

export const getGetGithubPullRequestMergeabilityUrl = () => {
  return `/github_pull_requests/mergeability`;
};

export const getGithubPullRequestMergeability = async (
  githubPullRequestMergeabilityRequest: GithubPullRequestMergeabilityRequest,
  options?: RequestInit
): Promise<getGithubPullRequestMergeabilityResponse> => {
  const res = await fetch(getGetGithubPullRequestMergeabilityUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(githubPullRequestMergeabilityRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getGithubPullRequestMergeabilityResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getGithubPullRequestMergeabilityResponse;
};

/**
 * @summary Closes a GitHub pull request, or reopens it, as the authenticated user
with their own GitHub grant.
 */
export type setGithubPullRequestStateResponse200 = {
  data: SetGithubPullRequestStateResponse;
  status: 200;
};

export type setGithubPullRequestStateResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type setGithubPullRequestStateResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type setGithubPullRequestStateResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type setGithubPullRequestStateResponse422 = {
  data: ErrorResponse;
  status: 422;
};

export type setGithubPullRequestStateResponse428 = {
  data: ErrorResponse;
  status: 428;
};

export type setGithubPullRequestStateResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type setGithubPullRequestStateResponse502 = {
  data: UpstreamErrorResponse;
  status: 502;
};

export type setGithubPullRequestStateResponse503 = {
  data: UpstreamErrorResponse;
  status: 503;
};

export type setGithubPullRequestStateResponseSuccess =
  setGithubPullRequestStateResponse200 & {
    headers: Headers;
  };
export type setGithubPullRequestStateResponseError = (
  | setGithubPullRequestStateResponse401
  | setGithubPullRequestStateResponse403
  | setGithubPullRequestStateResponse404
  | setGithubPullRequestStateResponse422
  | setGithubPullRequestStateResponse428
  | setGithubPullRequestStateResponse500
  | setGithubPullRequestStateResponse502
  | setGithubPullRequestStateResponse503
) & {
  headers: Headers;
};

export type setGithubPullRequestStateResponse =
  | setGithubPullRequestStateResponseSuccess
  | setGithubPullRequestStateResponseError;

export const getSetGithubPullRequestStateUrl = () => {
  return `/github_pull_requests/state`;
};

export const setGithubPullRequestState = async (
  setGithubPullRequestStateRequest: SetGithubPullRequestStateRequest,
  options?: RequestInit
): Promise<setGithubPullRequestStateResponse> => {
  const res = await fetch(getSetGithubPullRequestStateUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(setGithubPullRequestStateRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: setGithubPullRequestStateResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as setGithubPullRequestStateResponse;
};

/**
 * @summary Lists invite links, newest first. Macro staff only.
 */
export type listGtmInviteLinksResponse200 = {
  data: GtmInviteLinkList;
  status: 200;
};

export type listGtmInviteLinksResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type listGtmInviteLinksResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type listGtmInviteLinksResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type listGtmInviteLinksResponseSuccess =
  listGtmInviteLinksResponse200 & {
    headers: Headers;
  };
export type listGtmInviteLinksResponseError = (
  | listGtmInviteLinksResponse401
  | listGtmInviteLinksResponse403
  | listGtmInviteLinksResponse500
) & {
  headers: Headers;
};

export type listGtmInviteLinksResponse =
  | listGtmInviteLinksResponseSuccess
  | listGtmInviteLinksResponseError;

export const getListGtmInviteLinksUrl = (params?: ListGtmInviteLinksParams) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? 'null' : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/gtm-invite/links?${stringifiedParams}`
    : `/gtm-invite/links`;
};

export const listGtmInviteLinks = async (
  params?: ListGtmInviteLinksParams,
  options?: RequestInit
): Promise<listGtmInviteLinksResponse> => {
  const res = await fetch(getListGtmInviteLinksUrl(params), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: listGtmInviteLinksResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as listGtmInviteLinksResponse;
};

/**
 * @summary Creates an invite link. Macro staff only.
 */
export type createGtmInviteLinkResponse200 = {
  data: GtmInviteLink;
  status: 200;
};

export type createGtmInviteLinkResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type createGtmInviteLinkResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type createGtmInviteLinkResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type createGtmInviteLinkResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type createGtmInviteLinkResponseSuccess =
  createGtmInviteLinkResponse200 & {
    headers: Headers;
  };
export type createGtmInviteLinkResponseError = (
  | createGtmInviteLinkResponse400
  | createGtmInviteLinkResponse401
  | createGtmInviteLinkResponse403
  | createGtmInviteLinkResponse500
) & {
  headers: Headers;
};

export type createGtmInviteLinkResponse =
  | createGtmInviteLinkResponseSuccess
  | createGtmInviteLinkResponseError;

export const getCreateGtmInviteLinkUrl = () => {
  return `/gtm-invite/links`;
};

export const createGtmInviteLink = async (
  createGtmInviteLinkRequest: CreateGtmInviteLinkRequest,
  options?: RequestInit
): Promise<createGtmInviteLinkResponse> => {
  const res = await fetch(getCreateGtmInviteLinkUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(createGtmInviteLinkRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: createGtmInviteLinkResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as createGtmInviteLinkResponse;
};

/**
 * @summary Revokes an invite link nobody has signed up through. Macro staff only.
 */
export type revokeGtmInviteLinkResponse200 = {
  data: GtmInviteLink;
  status: 200;
};

export type revokeGtmInviteLinkResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type revokeGtmInviteLinkResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type revokeGtmInviteLinkResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type revokeGtmInviteLinkResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type revokeGtmInviteLinkResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type revokeGtmInviteLinkResponseSuccess =
  revokeGtmInviteLinkResponse200 & {
    headers: Headers;
  };
export type revokeGtmInviteLinkResponseError = (
  | revokeGtmInviteLinkResponse400
  | revokeGtmInviteLinkResponse401
  | revokeGtmInviteLinkResponse403
  | revokeGtmInviteLinkResponse404
  | revokeGtmInviteLinkResponse500
) & {
  headers: Headers;
};

export type revokeGtmInviteLinkResponse =
  | revokeGtmInviteLinkResponseSuccess
  | revokeGtmInviteLinkResponseError;

export const getRevokeGtmInviteLinkUrl = (id: string) => {
  return `/gtm-invite/links/${id}`;
};

export const revokeGtmInviteLink = async (
  id: string,
  options?: RequestInit
): Promise<revokeGtmInviteLinkResponse> => {
  const res = await fetch(getRevokeGtmInviteLinkUrl(id), {
    ...options,
    method: 'DELETE',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: revokeGtmInviteLinkResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as revokeGtmInviteLinkResponse;
};

/**
 * @summary The promotion the signed-in user's account holds from an invite link, if
they redeemed one and have not started a paid subscription yet.
 */
export type getGtmInviteOfferResponse200 = {
  data: GtmInviteOfferStatus;
  status: 200;
};

export type getGtmInviteOfferResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type getGtmInviteOfferResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getGtmInviteOfferResponseSuccess = getGtmInviteOfferResponse200 & {
  headers: Headers;
};
export type getGtmInviteOfferResponseError = (
  | getGtmInviteOfferResponse401
  | getGtmInviteOfferResponse500
) & {
  headers: Headers;
};

export type getGtmInviteOfferResponse =
  | getGtmInviteOfferResponseSuccess
  | getGtmInviteOfferResponseError;

export const getGetGtmInviteOfferUrl = () => {
  return `/gtm-invite/offer`;
};

export const getGtmInviteOffer = async (
  options?: RequestInit
): Promise<getGtmInviteOfferResponse> => {
  const res = await fetch(getGetGtmInviteOfferUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getGtmInviteOfferResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getGtmInviteOfferResponse;
};

/**
 * Unauthenticated: the recipient has no account yet. Only the first name and
whether the link is still usable are exposed.
 * @summary Resolves an invite link for the public welcome page and counts the open.
 */
export type resolveGtmInviteLinkResponse200 = {
  data: PublicGtmInviteLink;
  status: 200;
};

export type resolveGtmInviteLinkResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type resolveGtmInviteLinkResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type resolveGtmInviteLinkResponse429 = {
  data: void;
  status: 429;
};

export type resolveGtmInviteLinkResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type resolveGtmInviteLinkResponseSuccess =
  resolveGtmInviteLinkResponse200 & {
    headers: Headers;
  };
export type resolveGtmInviteLinkResponseError = (
  | resolveGtmInviteLinkResponse400
  | resolveGtmInviteLinkResponse404
  | resolveGtmInviteLinkResponse429
  | resolveGtmInviteLinkResponse500
) & {
  headers: Headers;
};

export type resolveGtmInviteLinkResponse =
  | resolveGtmInviteLinkResponseSuccess
  | resolveGtmInviteLinkResponseError;

export const getResolveGtmInviteLinkUrl = (token: string) => {
  return `/gtm-invite/public/${token}`;
};

export const resolveGtmInviteLink = async (
  token: string,
  options?: RequestInit
): Promise<resolveGtmInviteLinkResponse> => {
  const res = await fetch(getResolveGtmInviteLinkUrl(token), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: resolveGtmInviteLinkResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as resolveGtmInviteLinkResponse;
};

/**
 * @summary Attributes the signed-in user's account to the invite link they opened and
grants them its offer. Idempotent for the same account.
 */
export type redeemGtmInviteLinkResponse200 = {
  data: GtmInviteOffer;
  status: 200;
};

export type redeemGtmInviteLinkResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type redeemGtmInviteLinkResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type redeemGtmInviteLinkResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type redeemGtmInviteLinkResponse409 = {
  data: ErrorResponse;
  status: 409;
};

export type redeemGtmInviteLinkResponse410 = {
  data: ErrorResponse;
  status: 410;
};

export type redeemGtmInviteLinkResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type redeemGtmInviteLinkResponseSuccess =
  redeemGtmInviteLinkResponse200 & {
    headers: Headers;
  };
export type redeemGtmInviteLinkResponseError = (
  | redeemGtmInviteLinkResponse400
  | redeemGtmInviteLinkResponse401
  | redeemGtmInviteLinkResponse404
  | redeemGtmInviteLinkResponse409
  | redeemGtmInviteLinkResponse410
  | redeemGtmInviteLinkResponse500
) & {
  headers: Headers;
};

export type redeemGtmInviteLinkResponse =
  | redeemGtmInviteLinkResponseSuccess
  | redeemGtmInviteLinkResponseError;

export const getRedeemGtmInviteLinkUrl = () => {
  return `/gtm-invite/redeem`;
};

export const redeemGtmInviteLink = async (
  redeemGtmInviteLinkRequest: RedeemGtmInviteLinkRequest,
  options?: RequestInit
): Promise<redeemGtmInviteLinkResponse> => {
  const res = await fetch(getRedeemGtmInviteLinkUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(redeemGtmInviteLinkRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: redeemGtmInviteLinkResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as redeemGtmInviteLinkResponse;
};

/**
 * @summary Health check
 */
export type healthHandlerResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type healthHandlerResponseSuccess = healthHandlerResponse200 & {
  headers: Headers;
};

export type healthHandlerResponse = healthHandlerResponseSuccess;

export const getHealthHandlerUrl = () => {
  return `/health`;
};

export const healthHandler = async (
  options?: RequestInit
): Promise<healthHandlerResponse> => {
  const res = await fetch(getHealthHandlerUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: healthHandlerResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as healthHandlerResponse;
};

/**
 * @summary Generates a macro-api-token using the user's macro-access-token
You can either have your access token in the cookies or in the request
headers
Authorization: Bearer <access_token>
This returns a new macro-api-token
 */
export type macroApiTokenResponse200 = {
  data: MacroApiTokenResponse;
  status: 200;
};

export type macroApiTokenResponse401 = {
  data: string;
  status: 401;
};

export type macroApiTokenResponse500 = {
  data: string;
  status: 500;
};

export type macroApiTokenResponseSuccess = macroApiTokenResponse200 & {
  headers: Headers;
};
export type macroApiTokenResponseError = (
  | macroApiTokenResponse401
  | macroApiTokenResponse500
) & {
  headers: Headers;
};

export type macroApiTokenResponse =
  | macroApiTokenResponseSuccess
  | macroApiTokenResponseError;

export const getMacroApiTokenUrl = (params: MacroApiTokenParams) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? 'null' : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/jwt/macro_api_token?${stringifiedParams}`
    : `/jwt/macro_api_token`;
};

export const macroApiToken = async (
  params: MacroApiTokenParams,
  options?: RequestInit
): Promise<macroApiTokenResponse> => {
  const res = await fetch(getMacroApiTokenUrl(params), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: macroApiTokenResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as macroApiTokenResponse;
};

/**
 * @summary Refreshes a JWT token
You can either have your access token and refresh token in the cookies or in the request
headers
Authorization: Bearer <access_token>
x-macro-refresh-token: <refresh_token>
This returns the cookies with the new access and refresh token
 */
export type refreshResponse200 = {
  data: UserTokensResponse;
  status: 200;
};

export type refreshResponse400 = {
  data: string;
  status: 400;
};

export type refreshResponse401 = {
  data: string;
  status: 401;
};

export type refreshResponse429 = {
  data: string;
  status: 429;
};

export type refreshResponse500 = {
  data: string;
  status: 500;
};

export type refreshResponseSuccess = refreshResponse200 & {
  headers: Headers;
};
export type refreshResponseError = (
  | refreshResponse400
  | refreshResponse401
  | refreshResponse429
  | refreshResponse500
) & {
  headers: Headers;
};

export type refreshResponse = refreshResponseSuccess | refreshResponseError;

export const getRefreshUrl = () => {
  return `/jwt/refresh`;
};

export const refresh = async (
  options?: RequestInit
): Promise<refreshResponse> => {
  const res = await fetch(getRefreshUrl(), {
    ...options,
    method: 'POST',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: refreshResponse['data'] = body ? JSON.parse(body) : {};
  return { data, status: res.status, headers: res.headers } as refreshResponse;
};

/**
 * @summary Initiates a link for a user
 */
export type createInProgressLinkResponse200 = {
  data: CreateInProgressLinkResponse;
  status: 200;
};

export type createInProgressLinkResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type createInProgressLinkResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type createInProgressLinkResponse429 = {
  data: ErrorResponse;
  status: 429;
};

export type createInProgressLinkResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type createInProgressLinkResponseSuccess =
  createInProgressLinkResponse200 & {
    headers: Headers;
  };
export type createInProgressLinkResponseError = (
  | createInProgressLinkResponse400
  | createInProgressLinkResponse401
  | createInProgressLinkResponse429
  | createInProgressLinkResponse500
) & {
  headers: Headers;
};

export type createInProgressLinkResponse =
  | createInProgressLinkResponseSuccess
  | createInProgressLinkResponseError;

export const getCreateInProgressLinkUrl = () => {
  return `/link`;
};

export const createInProgressLink = async (
  options?: RequestInit
): Promise<createInProgressLinkResponse> => {
  const res = await fetch(getCreateInProgressLinkUrl(), {
    ...options,
    method: 'POST',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: createInProgressLinkResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as createInProgressLinkResponse;
};

export type emailConnectionProvidersResponse200 = {
  data: EmailConnectionProviders;
  status: 200;
};

export type emailConnectionProvidersResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type emailConnectionProvidersResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type emailConnectionProvidersResponseSuccess =
  emailConnectionProvidersResponse200 & {
    headers: Headers;
  };
export type emailConnectionProvidersResponseError = (
  | emailConnectionProvidersResponse400
  | emailConnectionProvidersResponse401
) & {
  headers: Headers;
};

export type emailConnectionProvidersResponse =
  | emailConnectionProvidersResponseSuccess
  | emailConnectionProvidersResponseError;

export const getEmailConnectionProvidersUrl = (
  params?: EmailConnectionProvidersParams
) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? 'null' : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/link/email/providers?${stringifiedParams}`
    : `/link/email/providers`;
};

export const emailConnectionProviders = async (
  params?: EmailConnectionProvidersParams,
  options?: RequestInit
): Promise<emailConnectionProvidersResponse> => {
  const res = await fetch(getEmailConnectionProvidersUrl(params), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: emailConnectionProvidersResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as emailConnectionProvidersResponse;
};

/**
 * @summary Initiates a link for a user
 */
export type initGithubLinkResponse200 = {
  data: InitGithubLinkResponse;
  status: 200;
};

export type initGithubLinkResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type initGithubLinkResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type initGithubLinkResponse429 = {
  data: ErrorResponse;
  status: 429;
};

export type initGithubLinkResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type initGithubLinkResponse502 = {
  data: UpstreamErrorResponse;
  status: 502;
};

export type initGithubLinkResponse503 = {
  data: UpstreamErrorResponse;
  status: 503;
};

export type initGithubLinkResponseSuccess = initGithubLinkResponse200 & {
  headers: Headers;
};
export type initGithubLinkResponseError = (
  | initGithubLinkResponse400
  | initGithubLinkResponse401
  | initGithubLinkResponse429
  | initGithubLinkResponse500
  | initGithubLinkResponse502
  | initGithubLinkResponse503
) & {
  headers: Headers;
};

export type initGithubLinkResponse =
  | initGithubLinkResponseSuccess
  | initGithubLinkResponseError;

export const getInitGithubLinkUrl = (params: InitGithubLinkParams) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? 'null' : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/link/github?${stringifiedParams}`
    : `/link/github`;
};

export const initGithubLink = async (
  params: InitGithubLinkParams,
  options?: RequestInit
): Promise<initGithubLinkResponse> => {
  const res = await fetch(getInitGithubLinkUrl(params), {
    ...options,
    method: 'POST',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: initGithubLinkResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as initGithubLinkResponse;
};

/**
 * @summary Deletes a github link for a user
 */
export type deleteGithubLinkResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type deleteGithubLinkResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type deleteGithubLinkResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type deleteGithubLinkResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type deleteGithubLinkResponse502 = {
  data: UpstreamErrorResponse;
  status: 502;
};

export type deleteGithubLinkResponse503 = {
  data: UpstreamErrorResponse;
  status: 503;
};

export type deleteGithubLinkResponseSuccess = deleteGithubLinkResponse200 & {
  headers: Headers;
};
export type deleteGithubLinkResponseError = (
  | deleteGithubLinkResponse400
  | deleteGithubLinkResponse401
  | deleteGithubLinkResponse500
  | deleteGithubLinkResponse502
  | deleteGithubLinkResponse503
) & {
  headers: Headers;
};

export type deleteGithubLinkResponse =
  | deleteGithubLinkResponseSuccess
  | deleteGithubLinkResponseError;

export const getDeleteGithubLinkUrl = () => {
  return `/link/github`;
};

export const deleteGithubLink = async (
  options?: RequestInit
): Promise<deleteGithubLinkResponse> => {
  const res = await fetch(getDeleteGithubLinkUrl(), {
    ...options,
    method: 'DELETE',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: deleteGithubLinkResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as deleteGithubLinkResponse;
};

/**
 * @summary Checks whether the authenticated user's GitHub link token is valid.
 */
export type checkGithubLinkStatusResponse200 = {
  data: GithubLinkStatusResponse;
  status: 200;
};

export type checkGithubLinkStatusResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type checkGithubLinkStatusResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type checkGithubLinkStatusResponse428 = {
  data: ErrorResponse;
  status: 428;
};

export type checkGithubLinkStatusResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type checkGithubLinkStatusResponse502 = {
  data: UpstreamErrorResponse;
  status: 502;
};

export type checkGithubLinkStatusResponse503 = {
  data: UpstreamErrorResponse;
  status: 503;
};

export type checkGithubLinkStatusResponseSuccess =
  checkGithubLinkStatusResponse200 & {
    headers: Headers;
  };
export type checkGithubLinkStatusResponseError = (
  | checkGithubLinkStatusResponse401
  | checkGithubLinkStatusResponse404
  | checkGithubLinkStatusResponse428
  | checkGithubLinkStatusResponse500
  | checkGithubLinkStatusResponse502
  | checkGithubLinkStatusResponse503
) & {
  headers: Headers;
};

export type checkGithubLinkStatusResponse =
  | checkGithubLinkStatusResponseSuccess
  | checkGithubLinkStatusResponseError;

export const getCheckGithubLinkStatusUrl = () => {
  return `/link/github/status`;
};

export const checkGithubLinkStatus = async (
  options?: RequestInit
): Promise<checkGithubLinkStatusResponse> => {
  const res = await fetch(getCheckGithubLinkStatusUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: checkGithubLinkStatusResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as checkGithubLinkStatusResponse;
};

/**
 * @summary Initiates a Gmail link for a user
 */
export type initGmailLinkResponse200 = {
  data: InitGmailLinkResponse;
  status: 200;
};

export type initGmailLinkResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type initGmailLinkResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type initGmailLinkResponse402 = {
  data: ErrorResponse;
  status: 402;
};

export type initGmailLinkResponse429 = {
  data: ErrorResponse;
  status: 429;
};

export type initGmailLinkResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type initGmailLinkResponseSuccess = initGmailLinkResponse200 & {
  headers: Headers;
};
export type initGmailLinkResponseError = (
  | initGmailLinkResponse400
  | initGmailLinkResponse401
  | initGmailLinkResponse402
  | initGmailLinkResponse429
  | initGmailLinkResponse500
) & {
  headers: Headers;
};

export type initGmailLinkResponse =
  | initGmailLinkResponseSuccess
  | initGmailLinkResponseError;

export const getInitGmailLinkUrl = (params: InitGmailLinkParams) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? 'null' : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/link/gmail?${stringifiedParams}`
    : `/link/gmail`;
};

export const initGmailLink = async (
  params: InitGmailLinkParams,
  options?: RequestInit
): Promise<initGmailLinkResponse> => {
  const res = await fetch(getInitGmailLinkUrl(params), {
    ...options,
    method: 'POST',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: initGmailLinkResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as initGmailLinkResponse;
};

/**
 * @summary Checks whether the authenticated user's gmail link is valid.
 */
export type checkGmailLinkStatusResponse200 = {
  data: GmailLinkStatusResponse;
  status: 200;
};

export type checkGmailLinkStatusResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type checkGmailLinkStatusResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type checkGmailLinkStatusResponse428 = {
  data: ErrorResponse;
  status: 428;
};

export type checkGmailLinkStatusResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type checkGmailLinkStatusResponseSuccess =
  checkGmailLinkStatusResponse200 & {
    headers: Headers;
  };
export type checkGmailLinkStatusResponseError = (
  | checkGmailLinkStatusResponse401
  | checkGmailLinkStatusResponse404
  | checkGmailLinkStatusResponse428
  | checkGmailLinkStatusResponse500
) & {
  headers: Headers;
};

export type checkGmailLinkStatusResponse =
  | checkGmailLinkStatusResponseSuccess
  | checkGmailLinkStatusResponseError;

export const getCheckGmailLinkStatusUrl = () => {
  return `/link/gmail/status`;
};

export const checkGmailLinkStatus = async (
  options?: RequestInit
): Promise<checkGmailLinkStatusResponse> => {
  const res = await fetch(getCheckGmailLinkStatusUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: checkGmailLinkStatusResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as checkGmailLinkStatusResponse;
};

/**
 * @summary Initiates a Microsoft Outlook account link for an authenticated user.
 */
export type initOutlookLinkResponse200 = {
  data: InitOutlookLinkResponse;
  status: 200;
};

export type initOutlookLinkResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type initOutlookLinkResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type initOutlookLinkResponse402 = {
  data: ErrorResponse;
  status: 402;
};

export type initOutlookLinkResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type initOutlookLinkResponse429 = {
  data: ErrorResponse;
  status: 429;
};

export type initOutlookLinkResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type initOutlookLinkResponseSuccess = initOutlookLinkResponse200 & {
  headers: Headers;
};
export type initOutlookLinkResponseError = (
  | initOutlookLinkResponse400
  | initOutlookLinkResponse401
  | initOutlookLinkResponse402
  | initOutlookLinkResponse404
  | initOutlookLinkResponse429
  | initOutlookLinkResponse500
) & {
  headers: Headers;
};

export type initOutlookLinkResponse =
  | initOutlookLinkResponseSuccess
  | initOutlookLinkResponseError;

export const getInitOutlookLinkUrl = (params?: InitOutlookLinkParams) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? 'null' : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/link/outlook?${stringifiedParams}`
    : `/link/outlook`;
};

export const initOutlookLink = async (
  params?: InitOutlookLinkParams,
  options?: RequestInit
): Promise<initOutlookLinkResponse> => {
  const res = await fetch(getInitOutlookLinkUrl(params), {
    ...options,
    method: 'POST',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: initOutlookLinkResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as initOutlookLinkResponse;
};

/**
 * @summary Completes the apple login flow
 */
export type appleLoginResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type appleLoginResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type appleLoginResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type appleLoginResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type appleLoginResponseSuccess = appleLoginResponse200 & {
  headers: Headers;
};
export type appleLoginResponseError = (
  | appleLoginResponse400
  | appleLoginResponse401
  | appleLoginResponse500
) & {
  headers: Headers;
};

export type appleLoginResponse =
  | appleLoginResponseSuccess
  | appleLoginResponseError;

export const getAppleLoginUrl = () => {
  return `/login/apple`;
};

export const appleLogin = async (
  appleLoginRequest: AppleLoginRequest,
  options?: RequestInit
): Promise<appleLoginResponse> => {
  const res = await fetch(getAppleLoginUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(appleLoginRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: appleLoginResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as appleLoginResponse;
};

/**
 * @summary Performs a password login
 */
export type passwordLoginResponse200 = {
  data: UserTokensResponse;
  status: 200;
};

export type passwordLoginResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type passwordLoginResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type passwordLoginResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type passwordLoginResponseSuccess = passwordLoginResponse200 & {
  headers: Headers;
};
export type passwordLoginResponseError = (
  | passwordLoginResponse400
  | passwordLoginResponse401
  | passwordLoginResponse500
) & {
  headers: Headers;
};

export type passwordLoginResponse =
  | passwordLoginResponseSuccess
  | passwordLoginResponseError;

export const getPasswordLoginUrl = () => {
  return `/login/password`;
};

export const passwordLogin = async (
  passwordRequest: PasswordRequest,
  options?: RequestInit
): Promise<passwordLoginResponse> => {
  const res = await fetch(getPasswordLoginUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(passwordRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: passwordLoginResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as passwordLoginResponse;
};

/**
 * @summary Initiates a passwordless login
 */
export type passwordlessLoginResponse200 = {
  data: PasswordlessStartedResponse;
  status: 200;
};

export type passwordlessLoginResponse202 = {
  data: SsoRequiredResponse;
  status: 202;
};

export type passwordlessLoginResponse400 = {
  data: string;
  status: 400;
};

export type passwordlessLoginResponse403 = {
  data: string;
  status: 403;
};

export type passwordlessLoginResponse500 = {
  data: string;
  status: 500;
};

export type passwordlessLoginResponseSuccess = (
  | passwordlessLoginResponse200
  | passwordlessLoginResponse202
) & {
  headers: Headers;
};
export type passwordlessLoginResponseError = (
  | passwordlessLoginResponse400
  | passwordlessLoginResponse403
  | passwordlessLoginResponse500
) & {
  headers: Headers;
};

export type passwordlessLoginResponse =
  | passwordlessLoginResponseSuccess
  | passwordlessLoginResponseError;

export const getPasswordlessLoginUrl = () => {
  return `/login/passwordless`;
};

export const passwordlessLogin = async (
  passwordlessRequest: PasswordlessRequest,
  options?: RequestInit
): Promise<passwordlessLoginResponse> => {
  const res = await fetch(getPasswordlessLoginUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(passwordlessRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: passwordlessLoginResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as passwordlessLoginResponse;
};

/**
 * @summary Initiates an SSO login
 */
export type ssoLoginResponse200 = {
  data: void;
  status: 200;
};

export type ssoLoginResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type ssoLoginResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type ssoLoginResponseSuccess = ssoLoginResponse200 & {
  headers: Headers;
};
export type ssoLoginResponseError = (
  | ssoLoginResponse400
  | ssoLoginResponse500
) & {
  headers: Headers;
};

export type ssoLoginResponse = ssoLoginResponseSuccess | ssoLoginResponseError;

export const getSsoLoginUrl = (params: SsoLoginParams) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? 'null' : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/login/sso?${stringifiedParams}`
    : `/login/sso`;
};

export const ssoLogin = async (
  params: SsoLoginParams,
  options?: RequestInit
): Promise<ssoLoginResponse> => {
  const res = await fetch(getSsoLoginUrl(params), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: ssoLoginResponse['data'] = body ? JSON.parse(body) : {};
  return { data, status: res.status, headers: res.headers } as ssoLoginResponse;
};

/**
 * @summary Initiates a passwordless login
 */
export type logoutResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type logoutResponseSuccess = logoutResponse200 & {
  headers: Headers;
};

export type logoutResponse = logoutResponseSuccess;

export const getLogoutUrl = () => {
  return `/logout`;
};

export const logout = async (
  options?: RequestInit
): Promise<logoutResponse> => {
  const res = await fetch(getLogoutUrl(), {
    ...options,
    method: 'POST',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: logoutResponse['data'] = body ? JSON.parse(body) : {};
  return { data, status: res.status, headers: res.headers } as logoutResponse;
};

/**
 * @summary Creates a merge request used to verify the user's email address in order to merge their
accounts.
This is different than generate_email_link which is used to verify a new email address to add a
new profile to a user's account.
 */
export type createMergeRequestResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type createMergeRequestResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type createMergeRequestResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type createMergeRequestResponse429 = {
  data: string;
  status: 429;
};

export type createMergeRequestResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type createMergeRequestResponseSuccess =
  createMergeRequestResponse200 & {
    headers: Headers;
  };
export type createMergeRequestResponseError = (
  | createMergeRequestResponse400
  | createMergeRequestResponse404
  | createMergeRequestResponse429
  | createMergeRequestResponse500
) & {
  headers: Headers;
};

export type createMergeRequestResponse =
  | createMergeRequestResponseSuccess
  | createMergeRequestResponseError;

export const getCreateMergeRequestUrl = () => {
  return `/merge`;
};

export const createMergeRequest = async (
  createAccountMergeRequest: CreateAccountMergeRequest,
  options?: RequestInit
): Promise<createMergeRequestResponse> => {
  const res = await fetch(getCreateMergeRequestUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(createAccountMergeRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: createMergeRequestResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as createMergeRequestResponse;
};

/**
 * @summary Verifies the merge request
 */
export type verifyMergeRequestResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type verifyMergeRequestResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type verifyMergeRequestResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type verifyMergeRequestResponseSuccess =
  verifyMergeRequestResponse200 & {
    headers: Headers;
  };
export type verifyMergeRequestResponseError = (
  | verifyMergeRequestResponse404
  | verifyMergeRequestResponse500
) & {
  headers: Headers;
};

export type verifyMergeRequestResponse =
  | verifyMergeRequestResponseSuccess
  | verifyMergeRequestResponseError;

export const getVerifyMergeRequestUrl = (code: string) => {
  return `/merge/verify/${code}`;
};

export const verifyMergeRequest = async (
  code: string,
  options?: RequestInit
): Promise<verifyMergeRequestResponse> => {
  const res = await fetch(getVerifyMergeRequestUrl(code), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: verifyMergeRequestResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as verifyMergeRequestResponse;
};

/**
 * @summary Emails a mobile lead a link to continue onboarding on desktop and enrolls
them in the Loops welcome sequence. No-ops if the address was already
captured, and rejects blocked addresses.
 */
export type sendMobileWelcomeEmailResponse200 = {
  data: SendMobileWelcomeEmailResponse;
  status: 200;
};

export type sendMobileWelcomeEmailResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type sendMobileWelcomeEmailResponse429 = {
  data: ErrorResponse;
  status: 429;
};

export type sendMobileWelcomeEmailResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type sendMobileWelcomeEmailResponseSuccess =
  sendMobileWelcomeEmailResponse200 & {
    headers: Headers;
  };
export type sendMobileWelcomeEmailResponseError = (
  | sendMobileWelcomeEmailResponse400
  | sendMobileWelcomeEmailResponse429
  | sendMobileWelcomeEmailResponse500
) & {
  headers: Headers;
};

export type sendMobileWelcomeEmailResponse =
  | sendMobileWelcomeEmailResponseSuccess
  | sendMobileWelcomeEmailResponseError;

export const getSendMobileWelcomeEmailUrl = () => {
  return `/mobile-welcome-email`;
};

export const sendMobileWelcomeEmail = async (
  sendMobileWelcomeEmailRequest: SendMobileWelcomeEmailRequest,
  options?: RequestInit
): Promise<sendMobileWelcomeEmailResponse> => {
  const res = await fetch(getSendMobileWelcomeEmailUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(sendMobileWelcomeEmailRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: sendMobileWelcomeEmailResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as sendMobileWelcomeEmailResponse;
};

/**
 * @summary Handles oauth redirect
 */
export type passwordlessCallbackResponse200 = {
  data: UserTokensResponse;
  status: 200;
};

export type passwordlessCallbackResponse400 = {
  data: string;
  status: 400;
};

export type passwordlessCallbackResponse401 = {
  data: string;
  status: 401;
};

export type passwordlessCallbackResponse500 = {
  data: string;
  status: 500;
};

export type passwordlessCallbackResponseSuccess =
  passwordlessCallbackResponse200 & {
    headers: Headers;
  };
export type passwordlessCallbackResponseError = (
  | passwordlessCallbackResponse400
  | passwordlessCallbackResponse401
  | passwordlessCallbackResponse500
) & {
  headers: Headers;
};

export type passwordlessCallbackResponse =
  | passwordlessCallbackResponseSuccess
  | passwordlessCallbackResponseError;

export const getPasswordlessCallbackUrl = (
  code: string,
  params: PasswordlessCallbackParams
) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? 'null' : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/oauth/passwordless/${code}?${stringifiedParams}`
    : `/oauth/passwordless/${code}`;
};

export const passwordlessCallback = async (
  code: string,
  params: PasswordlessCallbackParams,
  options?: RequestInit
): Promise<passwordlessCallbackResponse> => {
  const res = await fetch(getPasswordlessCallbackUrl(code, params), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: passwordlessCallbackResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as passwordlessCallbackResponse;
};

/**
 * @summary Handles oauth redirect
 */
export type oauthRedirectResponse200 = {
  data: void;
  status: 200;
};

export type oauthRedirectResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type oauthRedirectResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type oauthRedirectResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type oauthRedirectResponseSuccess = oauthRedirectResponse200 & {
  headers: Headers;
};
export type oauthRedirectResponseError = (
  | oauthRedirectResponse400
  | oauthRedirectResponse401
  | oauthRedirectResponse500
) & {
  headers: Headers;
};

export type oauthRedirectResponse =
  | oauthRedirectResponseSuccess
  | oauthRedirectResponseError;

export const getOauthRedirectUrl = () => {
  return `/oauth/redirect`;
};

export const oauthRedirect = async (
  options?: RequestInit
): Promise<oauthRedirectResponse> => {
  const res = await fetch(getOauthRedirectUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: oauthRedirectResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as oauthRedirectResponse;
};

/**
 * @summary Custom OAuth2 callback
 */
export type oauth2CallbackResponse200 = {
  data: void;
  status: 200;
};

export type oauth2CallbackResponse303 = {
  data: void;
  status: 303;
};

export type oauth2CallbackResponse304 = {
  data: ErrorResponse;
  status: 304;
};

export type oauth2CallbackResponse307 = {
  data: void;
  status: 307;
};

export type oauth2CallbackResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type oauth2CallbackResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type oauth2CallbackResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type oauth2CallbackResponseSuccess = oauth2CallbackResponse200 & {
  headers: Headers;
};
export type oauth2CallbackResponseError = (
  | oauth2CallbackResponse303
  | oauth2CallbackResponse304
  | oauth2CallbackResponse307
  | oauth2CallbackResponse400
  | oauth2CallbackResponse401
  | oauth2CallbackResponse500
) & {
  headers: Headers;
};

export type oauth2CallbackResponse =
  | oauth2CallbackResponseSuccess
  | oauth2CallbackResponseError;

export const getOauth2CallbackUrl = (provider: string) => {
  return `/oauth2/${provider}/callback`;
};

export const oauth2Callback = async (
  provider: string,
  options?: RequestInit
): Promise<oauth2CallbackResponse> => {
  const res = await fetch(getOauth2CallbackUrl(provider), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: oauth2CallbackResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as oauth2CallbackResponse;
};

/**
 * @summary Gets all permissions
 */
export type getPermissionsResponse200 = {
  data: Permission[];
  status: 200;
};

export type getPermissionsResponse401 = {
  data: string;
  status: 401;
};

export type getPermissionsResponse500 = {
  data: string;
  status: 500;
};

export type getPermissionsResponseSuccess = getPermissionsResponse200 & {
  headers: Headers;
};
export type getPermissionsResponseError = (
  | getPermissionsResponse401
  | getPermissionsResponse500
) & {
  headers: Headers;
};

export type getPermissionsResponse =
  | getPermissionsResponseSuccess
  | getPermissionsResponseError;

export const getGetPermissionsUrl = () => {
  return `/permissions`;
};

export const getPermissions = async (
  options?: RequestInit
): Promise<getPermissionsResponse> => {
  const res = await fetch(getGetPermissionsUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getPermissionsResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getPermissionsResponse;
};

/**
 * @summary Gets a list of the users permissions
 */
export type getUserPermissionsResponse200 = {
  data: string[];
  status: 200;
};

export type getUserPermissionsResponse401 = {
  data: string;
  status: 401;
};

export type getUserPermissionsResponse500 = {
  data: string;
  status: 500;
};

export type getUserPermissionsResponseSuccess =
  getUserPermissionsResponse200 & {
    headers: Headers;
  };
export type getUserPermissionsResponseError = (
  | getUserPermissionsResponse401
  | getUserPermissionsResponse500
) & {
  headers: Headers;
};

export type getUserPermissionsResponse =
  | getUserPermissionsResponseSuccess
  | getUserPermissionsResponseError;

export const getGetUserPermissionsUrl = () => {
  return `/permissions/me`;
};

export const getUserPermissions = async (
  options?: RequestInit
): Promise<getUserPermissionsResponse> => {
  const res = await fetch(getGetUserPermissionsUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getUserPermissionsResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getUserPermissionsResponse;
};

/**
 * Returns the authenticated user's referral code.
 * @summary Handler for `GET /referral-code`.
 */
export type getReferralCodeResponse200 = {
  data: string;
  status: 200;
};

export type getReferralCodeResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type getReferralCodeResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getReferralCodeResponseSuccess = getReferralCodeResponse200 & {
  headers: Headers;
};
export type getReferralCodeResponseError = (
  | getReferralCodeResponse401
  | getReferralCodeResponse500
) & {
  headers: Headers;
};

export type getReferralCodeResponse =
  | getReferralCodeResponseSuccess
  | getReferralCodeResponseError;

export const getGetReferralCodeUrl = () => {
  return `/referral/code`;
};

export const getReferralCode = async (
  options?: RequestInit
): Promise<getReferralCodeResponse> => {
  const res = await fetch(getGetReferralCodeUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getReferralCodeResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getReferralCodeResponse;
};

/**
 * Sends a referral code via email to a user
 * @summary Handler for `POST /referral/send`.
 */
export type sendReferralCodeResponse204 = {
  data: void;
  status: 204;
};

export type sendReferralCodeResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type sendReferralCodeResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type sendReferralCodeResponseSuccess = sendReferralCodeResponse204 & {
  headers: Headers;
};
export type sendReferralCodeResponseError = (
  | sendReferralCodeResponse401
  | sendReferralCodeResponse500
) & {
  headers: Headers;
};

export type sendReferralCodeResponse =
  | sendReferralCodeResponseSuccess
  | sendReferralCodeResponseError;

export const getSendReferralCodeUrl = () => {
  return `/referral/send`;
};

export const sendReferralCode = async (
  sendInviteBody: SendInviteBody,
  options?: RequestInit
): Promise<sendReferralCodeResponse> => {
  const res = await fetch(getSendReferralCodeUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(sendInviteBody),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: sendReferralCodeResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as sendReferralCodeResponse;
};

/**
 * @summary Refreshes a JWT token
 */
export type sessionCreationResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type sessionCreationResponse400 = {
  data: string;
  status: 400;
};

export type sessionCreationResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type sessionCreationResponseSuccess = sessionCreationResponse200 & {
  headers: Headers;
};
export type sessionCreationResponseError = (
  | sessionCreationResponse400
  | sessionCreationResponse500
) & {
  headers: Headers;
};

export type sessionCreationResponse =
  | sessionCreationResponseSuccess
  | sessionCreationResponseError;

export const getSessionCreationUrl = () => {
  return `/session`;
};

export const sessionCreation = async (
  options?: RequestInit
): Promise<sessionCreationResponse> => {
  const res = await fetch(getSessionCreationUrl(), {
    ...options,
    method: 'POST',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: sessionCreationResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as sessionCreationResponse;
};

/**
 * @summary Performs a login via session code
 */
export type sessionLoginResponse200 = {
  data: UserTokensResponse;
  status: 200;
};

export type sessionLoginResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type sessionLoginResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type sessionLoginResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type sessionLoginResponseSuccess = sessionLoginResponse200 & {
  headers: Headers;
};
export type sessionLoginResponseError = (
  | sessionLoginResponse400
  | sessionLoginResponse401
  | sessionLoginResponse500
) & {
  headers: Headers;
};

export type sessionLoginResponse =
  | sessionLoginResponseSuccess
  | sessionLoginResponseError;

export const getSessionLoginUrl = (sessionCode: string) => {
  return `/session/login/${sessionCode}`;
};

export const sessionLogin = async (
  sessionCode: string,
  options?: RequestInit
): Promise<sessionLoginResponse> => {
  const res = await fetch(getSessionLoginUrl(sessionCode), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: sessionLoginResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as sessionLoginResponse;
};

/**
 * @summary The status every user sees. Public: the banner shows wherever the app
runs, signed in or not.
 */
export type getSystemStatusResponse200 = {
  data: CurrentSystemStatus;
  status: 200;
};

export type getSystemStatusResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getSystemStatusResponseSuccess = getSystemStatusResponse200 & {
  headers: Headers;
};
export type getSystemStatusResponseError = getSystemStatusResponse500 & {
  headers: Headers;
};

export type getSystemStatusResponse =
  | getSystemStatusResponseSuccess
  | getSystemStatusResponseError;

export const getGetSystemStatusUrl = () => {
  return `/system-status`;
};

export const getSystemStatus = async (
  options?: RequestInit
): Promise<getSystemStatusResponse> => {
  const res = await fetch(getGetSystemStatusUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getSystemStatusResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getSystemStatusResponse;
};

/**
 * Authenticate with a Macro session, or from a script with a personal API
key (Settings → API keys) in the `x-macro-user-api-key` header. The body
is the new status:

- `{"status": "operational"}` clears the banner. It takes no message.
- `{"status": "degraded", "message": "Search is slow to update."}`
- `{"status": "major_outage", "message": "Macro is unavailable. We're on it."}`

Messages are trimmed and must be 1–500 characters. Every call is kept in
the history, even when it repeats the current status.
 * @summary Sets the status every user sees and pushes it to every open app. Macro
staff only.
 */
export type setSystemStatusResponse200 = {
  data: StatusUpdate;
  status: 200;
};

export type setSystemStatusResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type setSystemStatusResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type setSystemStatusResponse422 = {
  data: void;
  status: 422;
};

export type setSystemStatusResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type setSystemStatusResponseSuccess = setSystemStatusResponse200 & {
  headers: Headers;
};
export type setSystemStatusResponseError = (
  | setSystemStatusResponse401
  | setSystemStatusResponse403
  | setSystemStatusResponse422
  | setSystemStatusResponse500
) & {
  headers: Headers;
};

export type setSystemStatusResponse =
  | setSystemStatusResponseSuccess
  | setSystemStatusResponseError;

export const getSetSystemStatusUrl = () => {
  return `/system-status`;
};

export const setSystemStatus = async (
  systemStatus: SystemStatus,
  options?: RequestInit
): Promise<setSystemStatusResponse> => {
  const res = await fetch(getSetSystemStatusUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(systemStatus),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: setSystemStatusResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as setSystemStatusResponse;
};

/**
 * @summary Recent status updates, newest first, with who set each. Macro staff only.
 */
export type listSystemStatusHistoryResponse200 = {
  data: SystemStatusHistory;
  status: 200;
};

export type listSystemStatusHistoryResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type listSystemStatusHistoryResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type listSystemStatusHistoryResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type listSystemStatusHistoryResponseSuccess =
  listSystemStatusHistoryResponse200 & {
    headers: Headers;
  };
export type listSystemStatusHistoryResponseError = (
  | listSystemStatusHistoryResponse401
  | listSystemStatusHistoryResponse403
  | listSystemStatusHistoryResponse500
) & {
  headers: Headers;
};

export type listSystemStatusHistoryResponse =
  | listSystemStatusHistoryResponseSuccess
  | listSystemStatusHistoryResponseError;

export const getListSystemStatusHistoryUrl = () => {
  return `/system-status/history`;
};

export const listSystemStatusHistory = async (
  options?: RequestInit
): Promise<listSystemStatusHistoryResponse> => {
  const res = await fetch(getListSystemStatusHistoryUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: listSystemStatusHistoryResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as listSystemStatusHistoryResponse;
};

/**
 * @summary Gets a team by ID.
 */
export type getTeamResponse200 = {
  data: TeamWithMembers;
  status: 200;
};

export type getTeamResponse204 = {
  data: void;
  status: 204;
};

export type getTeamResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type getTeamResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type getTeamResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type getTeamResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getTeamResponseSuccess = (
  | getTeamResponse200
  | getTeamResponse204
) & {
  headers: Headers;
};
export type getTeamResponseError = (
  | getTeamResponse400
  | getTeamResponse401
  | getTeamResponse404
  | getTeamResponse500
) & {
  headers: Headers;
};

export type getTeamResponse = getTeamResponseSuccess | getTeamResponseError;

export const getGetTeamUrl = () => {
  return `/team`;
};

export const getTeam = async (
  options?: RequestInit
): Promise<getTeamResponse> => {
  const res = await fetch(getGetTeamUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getTeamResponse['data'] = body ? JSON.parse(body) : {};
  return { data, status: res.status, headers: res.headers } as getTeamResponse;
};

/**
 * @summary Creates a new team.
 */
export type createTeamResponse200 = {
  data: Team;
  status: 200;
};

export type createTeamResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type createTeamResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type createTeamResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type createTeamResponseSuccess = createTeamResponse200 & {
  headers: Headers;
};
export type createTeamResponseError = (
  | createTeamResponse400
  | createTeamResponse403
  | createTeamResponse500
) & {
  headers: Headers;
};

export type createTeamResponse =
  | createTeamResponseSuccess
  | createTeamResponseError;

export const getCreateTeamUrl = () => {
  return `/team`;
};

export const createTeam = async (
  createTeamRequest: CreateTeamRequest,
  options?: RequestInit
): Promise<createTeamResponse> => {
  const res = await fetch(getCreateTeamUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(createTeamRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: createTeamResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as createTeamResponse;
};

/**
 * @summary Deletes a team.
This will update all team members roles and cancel your subscription for the team.
This action is **irreversible** and you will not be able to recover the team afterwards.
 */
export type deleteTeamResponse200 = {
  data: void;
  status: 200;
};

export type deleteTeamResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type deleteTeamResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type deleteTeamResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type deleteTeamResponseSuccess = deleteTeamResponse200 & {
  headers: Headers;
};
export type deleteTeamResponseError = (
  | deleteTeamResponse400
  | deleteTeamResponse401
  | deleteTeamResponse500
) & {
  headers: Headers;
};

export type deleteTeamResponse =
  | deleteTeamResponseSuccess
  | deleteTeamResponseError;

export const getDeleteTeamUrl = () => {
  return `/team`;
};

export const deleteTeam = async (
  options?: RequestInit
): Promise<deleteTeamResponse> => {
  const res = await fetch(getDeleteTeamUrl(), {
    ...options,
    method: 'DELETE',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: deleteTeamResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as deleteTeamResponse;
};

/**
 * @summary Updates a team.
 */
export type patchTeamResponse200 = {
  data: void;
  status: 200;
};

export type patchTeamResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type patchTeamResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type patchTeamResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type patchTeamResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type patchTeamResponseSuccess = patchTeamResponse200 & {
  headers: Headers;
};
export type patchTeamResponseError = (
  | patchTeamResponse400
  | patchTeamResponse401
  | patchTeamResponse404
  | patchTeamResponse500
) & {
  headers: Headers;
};

export type patchTeamResponse =
  | patchTeamResponseSuccess
  | patchTeamResponseError;

export const getPatchTeamUrl = () => {
  return `/team`;
};

export const patchTeam = async (
  patchTeamRequest: PatchTeamRequest,
  options?: RequestInit
): Promise<patchTeamResponse> => {
  const res = await fetch(getPatchTeamUrl(), {
    ...options,
    method: 'PATCH',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(patchTeamRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: patchTeamResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as patchTeamResponse;
};

/**
 * @summary Toggles automatic domain joining for the team. When the team has no
auto-join domain, sets it to the team owner's email domain — rejected
with a 400 when that domain is a generic email provider domain (e.g.
gmail.com). When one is already set, removes it. New users whose email
domain matches a team's auto-join domain are added to that team on
signup. Requires the caller to be an Admin or Owner of the team.
 */
export type toggleTeamAutoJoinDomainResponse200 = {
  data: ToggleAutoJoinDomainResponse;
  status: 200;
};

export type toggleTeamAutoJoinDomainResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type toggleTeamAutoJoinDomainResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type toggleTeamAutoJoinDomainResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type toggleTeamAutoJoinDomainResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type toggleTeamAutoJoinDomainResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type toggleTeamAutoJoinDomainResponseSuccess =
  toggleTeamAutoJoinDomainResponse200 & {
    headers: Headers;
  };
export type toggleTeamAutoJoinDomainResponseError = (
  | toggleTeamAutoJoinDomainResponse400
  | toggleTeamAutoJoinDomainResponse401
  | toggleTeamAutoJoinDomainResponse403
  | toggleTeamAutoJoinDomainResponse404
  | toggleTeamAutoJoinDomainResponse500
) & {
  headers: Headers;
};

export type toggleTeamAutoJoinDomainResponse =
  | toggleTeamAutoJoinDomainResponseSuccess
  | toggleTeamAutoJoinDomainResponseError;

export const getToggleTeamAutoJoinDomainUrl = () => {
  return `/team/auto-join-domain/toggle`;
};

export const toggleTeamAutoJoinDomain = async (
  options?: RequestInit
): Promise<toggleTeamAutoJoinDomainResponse> => {
  const res = await fetch(getToggleTeamAutoJoinDomainUrl(), {
    ...options,
    method: 'POST',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: toggleTeamAutoJoinDomainResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as toggleTeamAutoJoinDomainResponse;
};

/**
 * @summary Enables or disables CRM for the team. On enable with `backfill`
(the default), kicks off a best-effort backfill that enqueues a
`PopulateCrmForUser` message per team member (no-op if CRM is
already enabled); without `backfill` the CRM starts empty and fills
from new activity only. On disable,
flips the flag and purges the team's CRM data (cascading through
`crm_companies` → `crm_domains` / `crm_contacts` /
`crm_contact_sources`). Requires the caller to be an Admin or
Owner of the team.
 */
export type patchTeamCrmSettingsResponse200 = {
  data: PatchTeamCrmSettingsResponse;
  status: 200;
};

export type patchTeamCrmSettingsResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type patchTeamCrmSettingsResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type patchTeamCrmSettingsResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type patchTeamCrmSettingsResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type patchTeamCrmSettingsResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type patchTeamCrmSettingsResponseSuccess =
  patchTeamCrmSettingsResponse200 & {
    headers: Headers;
  };
export type patchTeamCrmSettingsResponseError = (
  | patchTeamCrmSettingsResponse400
  | patchTeamCrmSettingsResponse401
  | patchTeamCrmSettingsResponse403
  | patchTeamCrmSettingsResponse404
  | patchTeamCrmSettingsResponse500
) & {
  headers: Headers;
};

export type patchTeamCrmSettingsResponse =
  | patchTeamCrmSettingsResponseSuccess
  | patchTeamCrmSettingsResponseError;

export const getPatchTeamCrmSettingsUrl = () => {
  return `/team/crm`;
};

export const patchTeamCrmSettings = async (
  patchTeamCrmSettingsRequest: PatchTeamCrmSettingsRequest,
  options?: RequestInit
): Promise<patchTeamCrmSettingsResponse> => {
  const res = await fetch(getPatchTeamCrmSettingsUrl(), {
    ...options,
    method: 'PATCH',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(patchTeamCrmSettingsRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: patchTeamCrmSettingsResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as patchTeamCrmSettingsResponse;
};

/**
 * @summary Emails the caller's contacts on the team's auto-join domain that the team
exists, so they can sign up and join. Contacts already on Macro, on the
team, invited, or emailed before are skipped, and a team emails at most 25
people in total. Call it after sending the team's invites. Requires the
caller to be an Admin or Owner of the team.
 */
export type sendTeamDomainNoticeResponse200 = {
  data: SendDomainNoticeResponse;
  status: 200;
};

export type sendTeamDomainNoticeResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type sendTeamDomainNoticeResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type sendTeamDomainNoticeResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type sendTeamDomainNoticeResponseSuccess =
  sendTeamDomainNoticeResponse200 & {
    headers: Headers;
  };
export type sendTeamDomainNoticeResponseError = (
  | sendTeamDomainNoticeResponse401
  | sendTeamDomainNoticeResponse403
  | sendTeamDomainNoticeResponse500
) & {
  headers: Headers;
};

export type sendTeamDomainNoticeResponse =
  | sendTeamDomainNoticeResponseSuccess
  | sendTeamDomainNoticeResponseError;

export const getSendTeamDomainNoticeUrl = () => {
  return `/team/domain-notice`;
};

export const sendTeamDomainNotice = async (
  options?: RequestInit
): Promise<sendTeamDomainNoticeResponse> => {
  const res = await fetch(getSendTeamDomainNoticeUrl(), {
    ...options,
    method: 'POST',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: sendTeamDomainNoticeResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as sendTeamDomainNoticeResponse;
};

/**
 * @summary Invites a user to a team.
 */
export type inviteToTeamResponse201 = {
  data: void;
  status: 201;
};

export type inviteToTeamResponse304 = {
  data: void;
  status: 304;
};

export type inviteToTeamResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type inviteToTeamResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type inviteToTeamResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type inviteToTeamResponse409 = {
  data: ErrorResponse;
  status: 409;
};

export type inviteToTeamResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type inviteToTeamResponseSuccess = inviteToTeamResponse201 & {
  headers: Headers;
};
export type inviteToTeamResponseError = (
  | inviteToTeamResponse304
  | inviteToTeamResponse400
  | inviteToTeamResponse401
  | inviteToTeamResponse404
  | inviteToTeamResponse409
  | inviteToTeamResponse500
) & {
  headers: Headers;
};

export type inviteToTeamResponse =
  | inviteToTeamResponseSuccess
  | inviteToTeamResponseError;

export const getInviteToTeamUrl = () => {
  return `/team/invite`;
};

export const inviteToTeam = async (
  inviteToTeamRequest: InviteToTeamRequest,
  options?: RequestInit
): Promise<inviteToTeamResponse> => {
  const res = await fetch(getInviteToTeamUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(inviteToTeamRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: inviteToTeamResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as inviteToTeamResponse;
};

/**
 * @summary Gets the team's invite link. Anyone who may invite people to the team may
see it.
 */
export type getTeamInviteLinkResponse200 = {
  data: TeamInviteLinkResponse;
  status: 200;
};

export type getTeamInviteLinkResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type getTeamInviteLinkResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type getTeamInviteLinkResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getTeamInviteLinkResponseSuccess = getTeamInviteLinkResponse200 & {
  headers: Headers;
};
export type getTeamInviteLinkResponseError = (
  | getTeamInviteLinkResponse401
  | getTeamInviteLinkResponse403
  | getTeamInviteLinkResponse500
) & {
  headers: Headers;
};

export type getTeamInviteLinkResponse =
  | getTeamInviteLinkResponseSuccess
  | getTeamInviteLinkResponseError;

export const getGetTeamInviteLinkUrl = () => {
  return `/team/invite-link`;
};

export const getTeamInviteLink = async (
  options?: RequestInit
): Promise<getTeamInviteLinkResponse> => {
  const res = await fetch(getGetTeamInviteLinkUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getTeamInviteLinkResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getTeamInviteLinkResponse;
};

/**
 * @summary Creates the team's invite link, replacing any existing one. Anyone who may
invite people may create the first link; replacing one requires a team
admin or owner.
 */
export type createTeamInviteLinkResponse201 = {
  data: CreatedTeamInviteLinkResponse;
  status: 201;
};

export type createTeamInviteLinkResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type createTeamInviteLinkResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type createTeamInviteLinkResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type createTeamInviteLinkResponseSuccess =
  createTeamInviteLinkResponse201 & {
    headers: Headers;
  };
export type createTeamInviteLinkResponseError = (
  | createTeamInviteLinkResponse401
  | createTeamInviteLinkResponse403
  | createTeamInviteLinkResponse500
) & {
  headers: Headers;
};

export type createTeamInviteLinkResponse =
  | createTeamInviteLinkResponseSuccess
  | createTeamInviteLinkResponseError;

export const getCreateTeamInviteLinkUrl = () => {
  return `/team/invite-link`;
};

export const createTeamInviteLink = async (
  options?: RequestInit
): Promise<createTeamInviteLinkResponse> => {
  const res = await fetch(getCreateTeamInviteLinkUrl(), {
    ...options,
    method: 'POST',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: createTeamInviteLinkResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as createTeamInviteLinkResponse;
};

/**
 * @summary Turns off the team's invite link. Requires a team admin or owner.
 */
export type deleteTeamInviteLinkResponse204 = {
  data: void;
  status: 204;
};

export type deleteTeamInviteLinkResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type deleteTeamInviteLinkResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type deleteTeamInviteLinkResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type deleteTeamInviteLinkResponseSuccess =
  deleteTeamInviteLinkResponse204 & {
    headers: Headers;
  };
export type deleteTeamInviteLinkResponseError = (
  | deleteTeamInviteLinkResponse401
  | deleteTeamInviteLinkResponse403
  | deleteTeamInviteLinkResponse500
) & {
  headers: Headers;
};

export type deleteTeamInviteLinkResponse =
  | deleteTeamInviteLinkResponseSuccess
  | deleteTeamInviteLinkResponseError;

export const getDeleteTeamInviteLinkUrl = () => {
  return `/team/invite-link`;
};

export const deleteTeamInviteLink = async (
  options?: RequestInit
): Promise<deleteTeamInviteLinkResponse> => {
  const res = await fetch(getDeleteTeamInviteLinkUrl(), {
    ...options,
    method: 'DELETE',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: deleteTeamInviteLinkResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as deleteTeamInviteLinkResponse;
};

/**
 * @summary Joins the team an invite link belongs to.
 */
export type joinTeamByInviteLinkResponse200 = {
  data: JoinTeamByInviteLinkResponse;
  status: 200;
};

export type joinTeamByInviteLinkResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type joinTeamByInviteLinkResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type joinTeamByInviteLinkResponse409 = {
  data: ErrorResponse;
  status: 409;
};

export type joinTeamByInviteLinkResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type joinTeamByInviteLinkResponseSuccess =
  joinTeamByInviteLinkResponse200 & {
    headers: Headers;
  };
export type joinTeamByInviteLinkResponseError = (
  | joinTeamByInviteLinkResponse401
  | joinTeamByInviteLinkResponse404
  | joinTeamByInviteLinkResponse409
  | joinTeamByInviteLinkResponse500
) & {
  headers: Headers;
};

export type joinTeamByInviteLinkResponse =
  | joinTeamByInviteLinkResponseSuccess
  | joinTeamByInviteLinkResponseError;

export const getJoinTeamByInviteLinkUrl = () => {
  return `/team/invite-link/join`;
};

export const joinTeamByInviteLink = async (
  teamInviteLinkTokenRequest: TeamInviteLinkTokenRequest,
  options?: RequestInit
): Promise<joinTeamByInviteLinkResponse> => {
  const res = await fetch(getJoinTeamByInviteLinkUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(teamInviteLinkTokenRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: joinTeamByInviteLinkResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as joinTeamByInviteLinkResponse;
};

/**
 * @summary Gets the team an invite link joins, so the user can see it before joining.
 */
export type getTeamByInviteLinkResponse200 = {
  data: TeamInviteLinkTeam;
  status: 200;
};

export type getTeamByInviteLinkResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type getTeamByInviteLinkResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type getTeamByInviteLinkResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getTeamByInviteLinkResponseSuccess =
  getTeamByInviteLinkResponse200 & {
    headers: Headers;
  };
export type getTeamByInviteLinkResponseError = (
  | getTeamByInviteLinkResponse401
  | getTeamByInviteLinkResponse404
  | getTeamByInviteLinkResponse500
) & {
  headers: Headers;
};

export type getTeamByInviteLinkResponse =
  | getTeamByInviteLinkResponseSuccess
  | getTeamByInviteLinkResponseError;

export const getGetTeamByInviteLinkUrl = () => {
  return `/team/invite-link/team`;
};

export const getTeamByInviteLink = async (
  teamInviteLinkTokenRequest: TeamInviteLinkTokenRequest,
  options?: RequestInit
): Promise<getTeamByInviteLinkResponse> => {
  const res = await fetch(getGetTeamByInviteLinkUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(teamInviteLinkTokenRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getTeamByInviteLinkResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getTeamByInviteLinkResponse;
};

/**
 * @summary Deletes a team invite from a team.
 */
export type deleteTeamInviteHandlerResponse200 = {
  data: void;
  status: 200;
};

export type deleteTeamInviteHandlerResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type deleteTeamInviteHandlerResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type deleteTeamInviteHandlerResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type deleteTeamInviteHandlerResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type deleteTeamInviteHandlerResponseSuccess =
  deleteTeamInviteHandlerResponse200 & {
    headers: Headers;
  };
export type deleteTeamInviteHandlerResponseError = (
  | deleteTeamInviteHandlerResponse400
  | deleteTeamInviteHandlerResponse401
  | deleteTeamInviteHandlerResponse404
  | deleteTeamInviteHandlerResponse500
) & {
  headers: Headers;
};

export type deleteTeamInviteHandlerResponse =
  | deleteTeamInviteHandlerResponseSuccess
  | deleteTeamInviteHandlerResponseError;

export const getDeleteTeamInviteHandlerUrl = (teamInviteId: string) => {
  return `/team/invite/${teamInviteId}`;
};

export const deleteTeamInviteHandler = async (
  teamInviteId: string,
  options?: RequestInit
): Promise<deleteTeamInviteHandlerResponse> => {
  const res = await fetch(getDeleteTeamInviteHandlerUrl(teamInviteId), {
    ...options,
    method: 'DELETE',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: deleteTeamInviteHandlerResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as deleteTeamInviteHandlerResponse;
};

/**
 * @summary Gets all invites for a team.
 */
export type getTeamInvitesResponse200 = {
  data: TeamInvitesResponse;
  status: 200;
};

export type getTeamInvitesResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type getTeamInvitesResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type getTeamInvitesResponse409 = {
  data: ErrorResponse;
  status: 409;
};

export type getTeamInvitesResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getTeamInvitesResponseSuccess = getTeamInvitesResponse200 & {
  headers: Headers;
};
export type getTeamInvitesResponseError = (
  | getTeamInvitesResponse400
  | getTeamInvitesResponse401
  | getTeamInvitesResponse409
  | getTeamInvitesResponse500
) & {
  headers: Headers;
};

export type getTeamInvitesResponse =
  | getTeamInvitesResponseSuccess
  | getTeamInvitesResponseError;

export const getGetTeamInvitesUrl = (params?: GetTeamInvitesParams) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? 'null' : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/team/invites?${stringifiedParams}`
    : `/team/invites`;
};

export const getTeamInvites = async (
  params?: GetTeamInvitesParams,
  options?: RequestInit
): Promise<getTeamInvitesResponse> => {
  const res = await fetch(getGetTeamInvitesUrl(params), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getTeamInvitesResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getTeamInvitesResponse;
};

/**
 * @summary Joins a team by accepting an invite.
 */
export type joinTeamResponse200 = {
  data: void;
  status: 200;
};

export type joinTeamResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type joinTeamResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type joinTeamResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type joinTeamResponseSuccess = joinTeamResponse200 & {
  headers: Headers;
};
export type joinTeamResponseError = (
  | joinTeamResponse400
  | joinTeamResponse401
  | joinTeamResponse500
) & {
  headers: Headers;
};

export type joinTeamResponse = joinTeamResponseSuccess | joinTeamResponseError;

export const getJoinTeamUrl = (teamInviteId: string) => {
  return `/team/join/${teamInviteId}`;
};

export const joinTeam = async (
  teamInviteId: string,
  options?: RequestInit
): Promise<joinTeamResponse> => {
  const res = await fetch(getJoinTeamUrl(teamInviteId), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: joinTeamResponse['data'] = body ? JSON.parse(body) : {};
  return { data, status: res.status, headers: res.headers } as joinTeamResponse;
};

/**
 * @summary Rejects an invitation to join a team.
 */
export type rejectInvitationResponse200 = {
  data: void;
  status: 200;
};

export type rejectInvitationResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type rejectInvitationResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type rejectInvitationResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type rejectInvitationResponseSuccess = rejectInvitationResponse200 & {
  headers: Headers;
};
export type rejectInvitationResponseError = (
  | rejectInvitationResponse400
  | rejectInvitationResponse401
  | rejectInvitationResponse500
) & {
  headers: Headers;
};

export type rejectInvitationResponse =
  | rejectInvitationResponseSuccess
  | rejectInvitationResponseError;

export const getRejectInvitationUrl = (teamInviteId: string) => {
  return `/team/join/${teamInviteId}`;
};

export const rejectInvitation = async (
  teamInviteId: string,
  options?: RequestInit
): Promise<rejectInvitationResponse> => {
  const res = await fetch(getRejectInvitationUrl(teamInviteId), {
    ...options,
    method: 'DELETE',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: rejectInvitationResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as rejectInvitationResponse;
};

/**
 * Team admins and owners only. The team's subscription is re-billed for
the seat at once (prorated); the member's tier role and individual AI
allowance follow immediately.
 * @summary Moves one team member's seat between paid plans.
 */
export type patchTeamMemberPlanResponse200 = {
  data: TeamMember;
  status: 200;
};

export type patchTeamMemberPlanResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type patchTeamMemberPlanResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type patchTeamMemberPlanResponse402 = {
  data: ErrorResponse;
  status: 402;
};

export type patchTeamMemberPlanResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type patchTeamMemberPlanResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type patchTeamMemberPlanResponseSuccess =
  patchTeamMemberPlanResponse200 & {
    headers: Headers;
  };
export type patchTeamMemberPlanResponseError = (
  | patchTeamMemberPlanResponse400
  | patchTeamMemberPlanResponse401
  | patchTeamMemberPlanResponse402
  | patchTeamMemberPlanResponse404
  | patchTeamMemberPlanResponse500
) & {
  headers: Headers;
};

export type patchTeamMemberPlanResponse =
  | patchTeamMemberPlanResponseSuccess
  | patchTeamMemberPlanResponseError;

export const getPatchTeamMemberPlanUrl = (memberUserId: string) => {
  return `/team/members/${memberUserId}/plan`;
};

export const patchTeamMemberPlan = async (
  memberUserId: string,
  patchTeamMemberPlanRequest: PatchTeamMemberPlanRequest,
  options?: RequestInit
): Promise<patchTeamMemberPlanResponse> => {
  const res = await fetch(getPatchTeamMemberPlanUrl(memberUserId), {
    ...options,
    method: 'PATCH',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(patchTeamMemberPlanRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: patchTeamMemberPlanResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as patchTeamMemberPlanResponse;
};

/**
 * @summary Toggles whether non-admin members may invite users to the team. Teams
start with this on (any member can invite); turning it off restricts
inviting to team admins and owners. Requires the caller to be an Admin
or Owner of the team.
 */
export type toggleTeamNonAdminInvitesResponse200 = {
  data: ToggleNonAdminInvitesResponse;
  status: 200;
};

export type toggleTeamNonAdminInvitesResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type toggleTeamNonAdminInvitesResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type toggleTeamNonAdminInvitesResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type toggleTeamNonAdminInvitesResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type toggleTeamNonAdminInvitesResponseSuccess =
  toggleTeamNonAdminInvitesResponse200 & {
    headers: Headers;
  };
export type toggleTeamNonAdminInvitesResponseError = (
  | toggleTeamNonAdminInvitesResponse401
  | toggleTeamNonAdminInvitesResponse403
  | toggleTeamNonAdminInvitesResponse404
  | toggleTeamNonAdminInvitesResponse500
) & {
  headers: Headers;
};

export type toggleTeamNonAdminInvitesResponse =
  | toggleTeamNonAdminInvitesResponseSuccess
  | toggleTeamNonAdminInvitesResponseError;

export const getToggleTeamNonAdminInvitesUrl = () => {
  return `/team/non-admin-invites/toggle`;
};

export const toggleTeamNonAdminInvites = async (
  options?: RequestInit
): Promise<toggleTeamNonAdminInvitesResponse> => {
  const res = await fetch(getToggleTeamNonAdminInvitesUrl(), {
    ...options,
    method: 'POST',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: toggleTeamNonAdminInvitesResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as toggleTeamNonAdminInvitesResponse;
};

/**
 * @summary Removes a user from a team.
 */
export type removeUserFromTeamResponse200 = {
  data: void;
  status: 200;
};

export type removeUserFromTeamResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type removeUserFromTeamResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type removeUserFromTeamResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type removeUserFromTeamResponseSuccess =
  removeUserFromTeamResponse200 & {
    headers: Headers;
  };
export type removeUserFromTeamResponseError = (
  | removeUserFromTeamResponse400
  | removeUserFromTeamResponse401
  | removeUserFromTeamResponse500
) & {
  headers: Headers;
};

export type removeUserFromTeamResponse =
  | removeUserFromTeamResponseSuccess
  | removeUserFromTeamResponseError;

export const getRemoveUserFromTeamUrl = (removeUserId: string) => {
  return `/team/remove/${removeUserId}`;
};

export const removeUserFromTeam = async (
  removeUserId: string,
  options?: RequestInit
): Promise<removeUserFromTeamResponse> => {
  const res = await fetch(getRemoveUserFromTeamUrl(removeUserId), {
    ...options,
    method: 'DELETE',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: removeUserFromTeamResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as removeUserFromTeamResponse;
};

/**
 * @summary Gets all teams for the authenticated user.
 */
export type getUserTeamsResponse200 = {
  data: Team[];
  status: 200;
};

export type getUserTeamsResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type getUserTeamsResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type getUserTeamsResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getUserTeamsResponseSuccess = getUserTeamsResponse200 & {
  headers: Headers;
};
export type getUserTeamsResponseError = (
  | getUserTeamsResponse400
  | getUserTeamsResponse401
  | getUserTeamsResponse500
) & {
  headers: Headers;
};

export type getUserTeamsResponse =
  | getUserTeamsResponseSuccess
  | getUserTeamsResponseError;

export const getGetUserTeamsUrl = () => {
  return `/team/user`;
};

export const getUserTeams = async (
  options?: RequestInit
): Promise<getUserTeamsResponse> => {
  const res = await fetch(getGetUserTeamsUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getUserTeamsResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getUserTeamsResponse;
};

/**
 * @summary Gets all of a user's invitations.
 */
export type getUserInvitesResponse200 = {
  data: TeamInvitesResponse;
  status: 200;
};

export type getUserInvitesResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type getUserInvitesResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type getUserInvitesResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getUserInvitesResponseSuccess = getUserInvitesResponse200 & {
  headers: Headers;
};
export type getUserInvitesResponseError = (
  | getUserInvitesResponse400
  | getUserInvitesResponse401
  | getUserInvitesResponse500
) & {
  headers: Headers;
};

export type getUserInvitesResponse =
  | getUserInvitesResponseSuccess
  | getUserInvitesResponseError;

export const getGetUserInvitesUrl = () => {
  return `/team/user/invites`;
};

export const getUserInvites = async (
  options?: RequestInit
): Promise<getUserInvitesResponse> => {
  const res = await fetch(getGetUserInvitesUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getUserInvitesResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getUserInvitesResponse;
};

/**
 * Safe to repeat until the agent confirms it saved the token: a reload replaces
the key, and a failed join stays pending for the next attempt.
 * @summary Finishes an agent's signup: joins the team that invited it and mints its
SDK token.
 */
export type agentSetupResponse200 = {
  data: AgentSetupResponse;
  status: 200;
};

export type agentSetupResponse401 = {
  data: string;
  status: 401;
};

export type agentSetupResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type agentSetupResponse409 = {
  data: ErrorResponse;
  status: 409;
};

export type agentSetupResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type agentSetupResponseSuccess = agentSetupResponse200 & {
  headers: Headers;
};
export type agentSetupResponseError = (
  | agentSetupResponse401
  | agentSetupResponse403
  | agentSetupResponse409
  | agentSetupResponse500
) & {
  headers: Headers;
};

export type agentSetupResponse =
  | agentSetupResponseSuccess
  | agentSetupResponseError;

export const getAgentSetupUrl = () => {
  return `/user/agent_setup`;
};

export const agentSetup = async (
  options?: RequestInit
): Promise<agentSetupResponse> => {
  const res = await fetch(getAgentSetupUrl(), {
    ...options,
    method: 'POST',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: agentSetupResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as agentSetupResponse;
};

/**
 * @summary Retrieves user names in bulk
 */
export type getUserNamesResponse200 = {
  data: UserNames;
  status: 200;
};

export type getUserNamesResponse401 = {
  data: string;
  status: 401;
};

export type getUserNamesResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getUserNamesResponseSuccess = getUserNamesResponse200 & {
  headers: Headers;
};
export type getUserNamesResponseError = (
  | getUserNamesResponse401
  | getUserNamesResponse500
) & {
  headers: Headers;
};

export type getUserNamesResponse =
  | getUserNamesResponseSuccess
  | getUserNamesResponseError;

export const getGetUserNamesUrl = () => {
  return `/user/get_names`;
};

export const getUserNames = async (
  postGetNamesRequestBody: PostGetNamesRequestBody,
  options?: RequestInit
): Promise<getUserNamesResponse> => {
  const res = await fetch(getGetUserNamesUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(postGetNamesRequestBody),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getUserNamesResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getUserNamesResponse;
};

/**
 * @summary Gets names for passed user profile ids, falling back to the requesting user's email contact names
 */
export type getUserNamesWithEmailResponse200 = {
  data: UserNames;
  status: 200;
};

export type getUserNamesWithEmailResponse400 = {
  data: string;
  status: 400;
};

export type getUserNamesWithEmailResponse401 = {
  data: string;
  status: 401;
};

export type getUserNamesWithEmailResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getUserNamesWithEmailResponseSuccess =
  getUserNamesWithEmailResponse200 & {
    headers: Headers;
  };
export type getUserNamesWithEmailResponseError = (
  | getUserNamesWithEmailResponse400
  | getUserNamesWithEmailResponse401
  | getUserNamesWithEmailResponse500
) & {
  headers: Headers;
};

export type getUserNamesWithEmailResponse =
  | getUserNamesWithEmailResponseSuccess
  | getUserNamesWithEmailResponseError;

export const getGetUserNamesWithEmailUrl = () => {
  return `/user/get_names_with_email`;
};

export const getUserNamesWithEmail = async (
  getNamesWithEmailRequestBody: GetNamesWithEmailRequestBody,
  options?: RequestInit
): Promise<getUserNamesWithEmailResponse> => {
  const res = await fetch(getGetUserNamesWithEmailUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(getNamesWithEmailRequestBody),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getUserNamesWithEmailResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getUserNamesWithEmailResponse;
};

/**
 * @summary Updates the user's group.
 */
export type patchUserGroupResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type patchUserGroupResponse401 = {
  data: string;
  status: 401;
};

export type patchUserGroupResponse404 = {
  data: string;
  status: 404;
};

export type patchUserGroupResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type patchUserGroupResponseSuccess = patchUserGroupResponse200 & {
  headers: Headers;
};
export type patchUserGroupResponseError = (
  | patchUserGroupResponse401
  | patchUserGroupResponse404
  | patchUserGroupResponse500
) & {
  headers: Headers;
};

export type patchUserGroupResponse =
  | patchUserGroupResponseSuccess
  | patchUserGroupResponseError;

export const getPatchUserGroupUrl = () => {
  return `/user/group`;
};

export const patchUserGroup = async (
  patchUserGroupRequest: PatchUserGroupRequest,
  options?: RequestInit
): Promise<patchUserGroupResponse> => {
  const res = await fetch(getPatchUserGroupUrl(), {
    ...options,
    method: 'PATCH',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(patchUserGroupRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: patchUserGroupResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as patchUserGroupResponse;
};

/**
 * @summary Get the caller's interface language.
 */
export type getUserLanguageResponse200 = {
  data: UserLanguage;
  status: 200;
};

export type getUserLanguageResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type getUserLanguageResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type getUserLanguageResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getUserLanguageResponseSuccess = getUserLanguageResponse200 & {
  headers: Headers;
};
export type getUserLanguageResponseError = (
  | getUserLanguageResponse401
  | getUserLanguageResponse404
  | getUserLanguageResponse500
) & {
  headers: Headers;
};

export type getUserLanguageResponse =
  | getUserLanguageResponseSuccess
  | getUserLanguageResponseError;

export const getGetUserLanguageUrl = () => {
  return `/user/language`;
};

export const getUserLanguage = async (
  options?: RequestInit
): Promise<getUserLanguageResponse> => {
  const res = await fetch(getGetUserLanguageUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getUserLanguageResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getUserLanguageResponse;
};

/**
 * @summary Set the caller's interface language, or clear it to follow their team's,
else their browser's.
 */
export type putUserLanguageResponse204 = {
  data: void;
  status: 204;
};

export type putUserLanguageResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type putUserLanguageResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type putUserLanguageResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type putUserLanguageResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type putUserLanguageResponseSuccess = putUserLanguageResponse204 & {
  headers: Headers;
};
export type putUserLanguageResponseError = (
  | putUserLanguageResponse400
  | putUserLanguageResponse401
  | putUserLanguageResponse404
  | putUserLanguageResponse500
) & {
  headers: Headers;
};

export type putUserLanguageResponse =
  | putUserLanguageResponseSuccess
  | putUserLanguageResponseError;

export const getPutUserLanguageUrl = () => {
  return `/user/language`;
};

export const putUserLanguage = async (
  userLanguage: UserLanguage,
  options?: RequestInit
): Promise<putUserLanguageResponse> => {
  const res = await fetch(getPutUserLanguageUrl(), {
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(userLanguage),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: putUserLanguageResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as putUserLanguageResponse;
};

/**
 * @summary Gets the calling user's info which matches what was given in the **deprecated**
getUserPermissions query in our graphql api.
This will eventually be removed and optimized to use smaller calls that grab
what is needed for various parts of the UI.
 */
export type getLegacyUserPermissionsResponse200 = {
  data: GetLegacyUserPermissionsResponse;
  status: 200;
};

export type getLegacyUserPermissionsResponse401 = {
  data: string;
  status: 401;
};

export type getLegacyUserPermissionsResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getLegacyUserPermissionsResponseSuccess =
  getLegacyUserPermissionsResponse200 & {
    headers: Headers;
  };
export type getLegacyUserPermissionsResponseError = (
  | getLegacyUserPermissionsResponse401
  | getLegacyUserPermissionsResponse500
) & {
  headers: Headers;
};

export type getLegacyUserPermissionsResponse =
  | getLegacyUserPermissionsResponseSuccess
  | getLegacyUserPermissionsResponseError;

export const getGetLegacyUserPermissionsUrl = () => {
  return `/user/legacy_user_permissions`;
};

export const getLegacyUserPermissions = async (
  options?: RequestInit
): Promise<getLegacyUserPermissionsResponse> => {
  const res = await fetch(getGetLegacyUserPermissionsUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getLegacyUserPermissionsResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getLegacyUserPermissionsResponse;
};

/**
 * @summary Returns whether or not a given idp link exists for a user
 */
export type getUserLinkExistsResponse200 = {
  data: UserLinkResponse;
  status: 200;
};

export type getUserLinkExistsResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type getUserLinkExistsResponse401 = {
  data: string;
  status: 401;
};

export type getUserLinkExistsResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getUserLinkExistsResponseSuccess = getUserLinkExistsResponse200 & {
  headers: Headers;
};
export type getUserLinkExistsResponseError = (
  | getUserLinkExistsResponse400
  | getUserLinkExistsResponse401
  | getUserLinkExistsResponse500
) & {
  headers: Headers;
};

export type getUserLinkExistsResponse =
  | getUserLinkExistsResponseSuccess
  | getUserLinkExistsResponseError;

export const getGetUserLinkExistsUrl = (params: GetUserLinkExistsParams) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? 'null' : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/user/link_exists?${stringifiedParams}`
    : `/user/link_exists`;
};

export const getUserLinkExists = async (
  params: GetUserLinkExistsParams,
  options?: RequestInit
): Promise<getUserLinkExistsResponse> => {
  const res = await fetch(getGetUserLinkExistsUrl(params), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getUserLinkExistsResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getUserLinkExistsResponse;
};

/**
 * @summary Gets the calling user's info
 */
export type getUserInfoResponse200 = {
  data: GetUserInfo;
  status: 200;
};

export type getUserInfoResponse401 = {
  data: string;
  status: 401;
};

export type getUserInfoResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getUserInfoResponseSuccess = getUserInfoResponse200 & {
  headers: Headers;
};
export type getUserInfoResponseError = (
  | getUserInfoResponse401
  | getUserInfoResponse500
) & {
  headers: Headers;
};

export type getUserInfoResponse =
  | getUserInfoResponseSuccess
  | getUserInfoResponseError;

export const getGetUserInfoUrl = () => {
  return `/user/me`;
};

export const getUserInfo = async (
  options?: RequestInit
): Promise<getUserInfoResponse> => {
  const res = await fetch(getGetUserInfoUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getUserInfoResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getUserInfoResponse;
};

/**
 * @summary Deletes the user who calls this endpoint
 */
export type deleteUserResponse200 = {
  data: GenericSuccessResponse;
  status: 200;
};

export type deleteUserResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type deleteUserResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type deleteUserResponseSuccess = deleteUserResponse200 & {
  headers: Headers;
};
export type deleteUserResponseError = (
  | deleteUserResponse401
  | deleteUserResponse500
) & {
  headers: Headers;
};

export type deleteUserResponse =
  | deleteUserResponseSuccess
  | deleteUserResponseError;

export const getDeleteUserUrl = () => {
  return `/user/me`;
};

export const deleteUser = async (
  options?: RequestInit
): Promise<deleteUserResponse> => {
  const res = await fetch(getDeleteUserUrl(), {
    ...options,
    method: 'DELETE',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: deleteUserResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as deleteUserResponse;
};

/**
 * @summary Retrieves the name of a particular user.
 */
export type getUserNameResponse200 = {
  data: UserName;
  status: 200;
};

export type getUserNameResponse401 = {
  data: string;
  status: 401;
};

export type getUserNameResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getUserNameResponseSuccess = getUserNameResponse200 & {
  headers: Headers;
};
export type getUserNameResponseError = (
  | getUserNameResponse401
  | getUserNameResponse500
) & {
  headers: Headers;
};

export type getUserNameResponse =
  | getUserNameResponseSuccess
  | getUserNameResponseError;

export const getGetUserNameUrl = () => {
  return `/user/name`;
};

export const getUserName = async (
  options?: RequestInit
): Promise<getUserNameResponse> => {
  const res = await fetch(getGetUserNameUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getUserNameResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getUserNameResponse;
};

/**
 * @summary Sets the name of a particular user
 */
export type putUserNameResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type putUserNameResponse401 = {
  data: string;
  status: 401;
};

export type putUserNameResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type putUserNameResponseSuccess = putUserNameResponse200 & {
  headers: Headers;
};
export type putUserNameResponseError = (
  | putUserNameResponse401
  | putUserNameResponse500
) & {
  headers: Headers;
};

export type putUserNameResponse =
  | putUserNameResponseSuccess
  | putUserNameResponseError;

export const getPutUserNameUrl = (params?: PutUserNameParams) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? 'null' : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/user/name?${stringifiedParams}`
    : `/user/name`;
};

export const putUserName = async (
  params?: PutUserNameParams,
  options?: RequestInit
): Promise<putUserNameResponse> => {
  const res = await fetch(getPutUserNameUrl(params), {
    ...options,
    method: 'PUT',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: putUserNameResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as putUserNameResponse;
};

/**
 * @summary Updates the user's onboarding.
 */
export type patchUserOnboardingResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type patchUserOnboardingResponse401 = {
  data: string;
  status: 401;
};

export type patchUserOnboardingResponse404 = {
  data: string;
  status: 404;
};

export type patchUserOnboardingResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type patchUserOnboardingResponseSuccess =
  patchUserOnboardingResponse200 & {
    headers: Headers;
  };
export type patchUserOnboardingResponseError = (
  | patchUserOnboardingResponse401
  | patchUserOnboardingResponse404
  | patchUserOnboardingResponse500
) & {
  headers: Headers;
};

export type patchUserOnboardingResponse =
  | patchUserOnboardingResponseSuccess
  | patchUserOnboardingResponseError;

export const getPatchUserOnboardingUrl = () => {
  return `/user/onboarding`;
};

export const patchUserOnboarding = async (
  patchUserOnboardingRequest: PatchUserOnboardingRequest,
  options?: RequestInit
): Promise<patchUserOnboardingResponse> => {
  const res = await fetch(getPatchUserOnboardingUrl(), {
    ...options,
    method: 'PATCH',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(patchUserOnboardingRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: patchUserOnboardingResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as patchUserOnboardingResponse;
};

/**
 * @summary Retrieves the users organization if present.
Returns NO_CONTENT if the user is a not part of an organization.
 */
export type getUserOrganizationResponse200 = {
  data: UserOrganizationResponse;
  status: 200;
};

export type getUserOrganizationResponse204 = {
  data: void;
  status: 204;
};

export type getUserOrganizationResponse401 = {
  data: string;
  status: 401;
};

export type getUserOrganizationResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getUserOrganizationResponseSuccess = (
  | getUserOrganizationResponse200
  | getUserOrganizationResponse204
) & {
  headers: Headers;
};
export type getUserOrganizationResponseError = (
  | getUserOrganizationResponse401
  | getUserOrganizationResponse500
) & {
  headers: Headers;
};

export type getUserOrganizationResponse =
  | getUserOrganizationResponseSuccess
  | getUserOrganizationResponseError;

export const getGetUserOrganizationUrl = () => {
  return `/user/organization`;
};

export const getUserOrganization = async (
  options?: RequestInit
): Promise<getUserOrganizationResponse> => {
  const res = await fetch(getGetUserOrganizationUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getUserOrganizationResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getUserOrganizationResponse;
};

/**
 * @summary Sets the profile picture URL for a particular user
 */
export type putProfilePictureResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type putProfilePictureResponse401 = {
  data: string;
  status: 401;
};

export type putProfilePictureResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type putProfilePictureResponseSuccess = putProfilePictureResponse200 & {
  headers: Headers;
};
export type putProfilePictureResponseError = (
  | putProfilePictureResponse401
  | putProfilePictureResponse500
) & {
  headers: Headers;
};

export type putProfilePictureResponse =
  | putProfilePictureResponseSuccess
  | putProfilePictureResponseError;

export const getPutProfilePictureUrl = (params: PutProfilePictureParams) => {
  const normalizedParams = new URLSearchParams();

  Object.entries(params || {}).forEach(([key, value]) => {
    if (value !== undefined) {
      normalizedParams.append(key, value === null ? 'null' : value.toString());
    }
  });

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/user/profile_picture?${stringifiedParams}`
    : `/user/profile_picture`;
};

export const putProfilePicture = async (
  params: PutProfilePictureParams,
  options?: RequestInit
): Promise<putProfilePictureResponse> => {
  const res = await fetch(getPutProfilePictureUrl(params), {
    ...options,
    method: 'PUT',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: putProfilePictureResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as putProfilePictureResponse;
};

/**
 * @summary Sets the caller's profile picture to an image they uploaded.
 */
export type putProfilePictureFileResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type putProfilePictureFileResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type putProfilePictureFileResponse401 = {
  data: string;
  status: 401;
};

export type putProfilePictureFileResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type putProfilePictureFileResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type putProfilePictureFileResponseSuccess =
  putProfilePictureFileResponse200 & {
    headers: Headers;
  };
export type putProfilePictureFileResponseError = (
  | putProfilePictureFileResponse400
  | putProfilePictureFileResponse401
  | putProfilePictureFileResponse404
  | putProfilePictureFileResponse500
) & {
  headers: Headers;
};

export type putProfilePictureFileResponse =
  | putProfilePictureFileResponseSuccess
  | putProfilePictureFileResponseError;

export const getPutProfilePictureFileUrl = () => {
  return `/user/profile_picture/file`;
};

export const putProfilePictureFile = async (
  putProfilePictureFileRequest: PutProfilePictureFileRequest,
  options?: RequestInit
): Promise<putProfilePictureFileResponse> => {
  const res = await fetch(getPutProfilePictureFileUrl(), {
    ...options,
    method: 'PUT',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(putProfilePictureFileRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: putProfilePictureFileResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as putProfilePictureFileResponse;
};

/**
 * @summary Reserves storage for a new profile picture. Static file storage has no
MacroDB, so it cannot check API keys; this route lets key holders upload.
 */
export type createProfilePictureUploadResponse200 = {
  data: ProfilePictureUpload;
  status: 200;
};

export type createProfilePictureUploadResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type createProfilePictureUploadResponse401 = {
  data: string;
  status: 401;
};

export type createProfilePictureUploadResponse413 = {
  data: ErrorResponse;
  status: 413;
};

export type createProfilePictureUploadResponse429 = {
  data: ErrorResponse;
  status: 429;
};

export type createProfilePictureUploadResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type createProfilePictureUploadResponseSuccess =
  createProfilePictureUploadResponse200 & {
    headers: Headers;
  };
export type createProfilePictureUploadResponseError = (
  | createProfilePictureUploadResponse400
  | createProfilePictureUploadResponse401
  | createProfilePictureUploadResponse413
  | createProfilePictureUploadResponse429
  | createProfilePictureUploadResponse500
) & {
  headers: Headers;
};

export type createProfilePictureUploadResponse =
  | createProfilePictureUploadResponseSuccess
  | createProfilePictureUploadResponseError;

export const getCreateProfilePictureUploadUrl = () => {
  return `/user/profile_picture/file`;
};

export const createProfilePictureUpload = async (
  createProfilePictureUploadRequest: CreateProfilePictureUploadRequest,
  options?: RequestInit
): Promise<createProfilePictureUploadResponse> => {
  const res = await fetch(getCreateProfilePictureUploadUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(createProfilePictureUploadRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: createProfilePictureUploadResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as createProfilePictureUploadResponse;
};

/**
 * @summary Retrieves profile picture URLs for a list of users
 */
export type postProfilePicturesResponse200 = {
  data: ProfilePictures;
  status: 200;
};

export type postProfilePicturesResponse401 = {
  data: string;
  status: 401;
};

export type postProfilePicturesResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type postProfilePicturesResponseSuccess =
  postProfilePicturesResponse200 & {
    headers: Headers;
  };
export type postProfilePicturesResponseError = (
  | postProfilePicturesResponse401
  | postProfilePicturesResponse500
) & {
  headers: Headers;
};

export type postProfilePicturesResponse =
  | postProfilePicturesResponseSuccess
  | postProfilePicturesResponseError;

export const getPostProfilePicturesUrl = () => {
  return `/user/profile_pictures`;
};

export const postProfilePictures = async (
  getProfilePicturesRequestBody: GetProfilePicturesRequestBody,
  options?: RequestInit
): Promise<postProfilePicturesResponse> => {
  const res = await fetch(getPostProfilePicturesUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(getProfilePicturesRequestBody),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: postProfilePicturesResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as postProfilePicturesResponse;
};

/**
 * @summary Retrieves the users quota.
Returns NO_CONTENT if the user is a premium user with no quota.
 */
export type getUserQuotaResponse200 = {
  data: UserQuota;
  status: 200;
};

export type getUserQuotaResponse204 = {
  data: void;
  status: 204;
};

export type getUserQuotaResponse401 = {
  data: string;
  status: 401;
};

export type getUserQuotaResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getUserQuotaResponseSuccess = (
  | getUserQuotaResponse200
  | getUserQuotaResponse204
) & {
  headers: Headers;
};
export type getUserQuotaResponseError = (
  | getUserQuotaResponse401
  | getUserQuotaResponse500
) & {
  headers: Headers;
};

export type getUserQuotaResponse =
  | getUserQuotaResponseSuccess
  | getUserQuotaResponseError;

export const getGetUserQuotaUrl = () => {
  return `/user/quota`;
};

export const getUserQuota = async (
  options?: RequestInit
): Promise<getUserQuotaResponse> => {
  const res = await fetch(getGetUserQuotaUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getUserQuotaResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getUserQuotaResponse;
};

/**
 * @summary Creates a Stripe checkout session for the user to subscribe.
 */
export type createCheckoutSessionV2Response200 = {
  data: CheckoutSessionV2Response;
  status: 200;
};

export type createCheckoutSessionV2Response400 = {
  data: ErrorResponse;
  status: 400;
};

export type createCheckoutSessionV2Response404 = {
  data: ErrorResponse;
  status: 404;
};

export type createCheckoutSessionV2Response409 = {
  data: ErrorResponse;
  status: 409;
};

export type createCheckoutSessionV2Response500 = {
  data: ErrorResponse;
  status: 500;
};

export type createCheckoutSessionV2ResponseSuccess =
  createCheckoutSessionV2Response200 & {
    headers: Headers;
  };
export type createCheckoutSessionV2ResponseError = (
  | createCheckoutSessionV2Response400
  | createCheckoutSessionV2Response404
  | createCheckoutSessionV2Response409
  | createCheckoutSessionV2Response500
) & {
  headers: Headers;
};

export type createCheckoutSessionV2Response =
  | createCheckoutSessionV2ResponseSuccess
  | createCheckoutSessionV2ResponseError;

export const getCreateCheckoutSessionV2Url = () => {
  return `/user/stripe/checkoutv2`;
};

export const createCheckoutSessionV2 = async (
  createCheckoutSessionV2Request: CreateCheckoutSessionV2Request,
  options?: RequestInit
): Promise<createCheckoutSessionV2Response> => {
  const res = await fetch(getCreateCheckoutSessionV2Url(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(createCheckoutSessionV2Request),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: createCheckoutSessionV2Response['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as createCheckoutSessionV2Response;
};

/**
 * @summary Read subscription state for the authenticated user's seat.
 */
export type getSubscriptionStatusResponse200 = {
  data: SubscriptionStatus;
  status: 200;
};

export type getSubscriptionStatusResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type getSubscriptionStatusResponse409 = {
  data: ErrorResponse;
  status: 409;
};

export type getSubscriptionStatusResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getSubscriptionStatusResponseSuccess =
  getSubscriptionStatusResponse200 & {
    headers: Headers;
  };
export type getSubscriptionStatusResponseError = (
  | getSubscriptionStatusResponse401
  | getSubscriptionStatusResponse409
  | getSubscriptionStatusResponse500
) & {
  headers: Headers;
};

export type getSubscriptionStatusResponse =
  | getSubscriptionStatusResponseSuccess
  | getSubscriptionStatusResponseError;

export const getGetSubscriptionStatusUrl = () => {
  return `/user/stripe/plan`;
};

export const getSubscriptionStatus = async (
  options?: RequestInit
): Promise<getSubscriptionStatusResponse> => {
  const res = await fetch(getGetSubscriptionStatusUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getSubscriptionStatusResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getSubscriptionStatusResponse;
};

/**
 * @summary Changes the caller's paid plan. Upgrades are prorated immediately;
downgrades retain the active plan until renewal. Selecting the active plan
cancels a pending downgrade without charging or resetting usage.
 */
export type changePlanResponse200 = {
  data: ChangePlanResponse;
  status: 200;
};

export type changePlanResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type changePlanResponse402 = {
  data: ErrorResponse;
  status: 402;
};

export type changePlanResponse403 = {
  data: ErrorResponse;
  status: 403;
};

export type changePlanResponse404 = {
  data: ErrorResponse;
  status: 404;
};

export type changePlanResponse409 = {
  data: ErrorResponse;
  status: 409;
};

export type changePlanResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type changePlanResponseSuccess = changePlanResponse200 & {
  headers: Headers;
};
export type changePlanResponseError = (
  | changePlanResponse400
  | changePlanResponse402
  | changePlanResponse403
  | changePlanResponse404
  | changePlanResponse409
  | changePlanResponse500
) & {
  headers: Headers;
};

export type changePlanResponse =
  | changePlanResponseSuccess
  | changePlanResponseError;

export const getChangePlanUrl = () => {
  return `/user/stripe/plan`;
};

export const changePlan = async (
  changePlanRequest: ChangePlanRequest,
  options?: RequestInit
): Promise<changePlanResponse> => {
  const res = await fetch(getChangePlanUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(changePlanRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: changePlanResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as changePlanResponse;
};

/**
 * @summary Creates a Stripe billing portal session.
 */
export type createPortalSessionResponse200 = {
  data: StripeSessionResponse;
  status: 200;
};

export type createPortalSessionResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type createPortalSessionResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type createPortalSessionResponseSuccess =
  createPortalSessionResponse200 & {
    headers: Headers;
  };
export type createPortalSessionResponseError = (
  | createPortalSessionResponse400
  | createPortalSessionResponse500
) & {
  headers: Headers;
};

export type createPortalSessionResponse =
  | createPortalSessionResponseSuccess
  | createPortalSessionResponseError;

export const getCreatePortalSessionUrl = () => {
  return `/user/stripe/portal`;
};

export const createPortalSession = async (
  createPortalSessionRequest: CreatePortalSessionRequest,
  options?: RequestInit
): Promise<createPortalSessionResponse> => {
  const res = await fetch(getCreatePortalSessionUrl(), {
    ...options,
    method: 'POST',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(createPortalSessionRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: createPortalSessionResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as createPortalSessionResponse;
};

/**
 * @summary Read the caller's eligibility; checkout revalidates before granting a trial.
 */
export type getTrialEligibilityResponse200 = {
  data: TrialEligibility;
  status: 200;
};

export type getTrialEligibilityResponse400 = {
  data: ErrorResponse;
  status: 400;
};

export type getTrialEligibilityResponse401 = {
  data: ErrorResponse;
  status: 401;
};

export type getTrialEligibilityResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type getTrialEligibilityResponseSuccess =
  getTrialEligibilityResponse200 & {
    headers: Headers;
  };
export type getTrialEligibilityResponseError = (
  | getTrialEligibilityResponse400
  | getTrialEligibilityResponse401
  | getTrialEligibilityResponse500
) & {
  headers: Headers;
};

export type getTrialEligibilityResponse =
  | getTrialEligibilityResponseSuccess
  | getTrialEligibilityResponseError;

export const getGetTrialEligibilityUrl = () => {
  return `/user/stripe/trial_eligibility`;
};

export const getTrialEligibility = async (
  options?: RequestInit
): Promise<getTrialEligibilityResponse> => {
  const res = await fetch(getGetTrialEligibilityUrl(), {
    ...options,
    method: 'GET',
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: getTrialEligibilityResponse['data'] = body
    ? JSON.parse(body)
    : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as getTrialEligibilityResponse;
};

/**
 * @summary Updates the user's tutorialComplete flag.
 */
export type patchUserTutorialResponse200 = {
  data: EmptyResponse;
  status: 200;
};

export type patchUserTutorialResponse401 = {
  data: string;
  status: 401;
};

export type patchUserTutorialResponse404 = {
  data: string;
  status: 404;
};

export type patchUserTutorialResponse500 = {
  data: ErrorResponse;
  status: 500;
};

export type patchUserTutorialResponseSuccess = patchUserTutorialResponse200 & {
  headers: Headers;
};
export type patchUserTutorialResponseError = (
  | patchUserTutorialResponse401
  | patchUserTutorialResponse404
  | patchUserTutorialResponse500
) & {
  headers: Headers;
};

export type patchUserTutorialResponse =
  | patchUserTutorialResponseSuccess
  | patchUserTutorialResponseError;

export const getPatchUserTutorialUrl = () => {
  return `/user/tutorial`;
};

export const patchUserTutorial = async (
  patchUserTutorialRequest: PatchUserTutorialRequest,
  options?: RequestInit
): Promise<patchUserTutorialResponse> => {
  const res = await fetch(getPatchUserTutorialUrl(), {
    ...options,
    method: 'PATCH',
    headers: { 'Content-Type': 'application/json', ...options?.headers },
    body: JSON.stringify(patchUserTutorialRequest),
  });

  const body = [204, 205, 304].includes(res.status) ? null : await res.text();

  const data: patchUserTutorialResponse['data'] = body ? JSON.parse(body) : {};
  return {
    data,
    status: res.status,
    headers: res.headers,
  } as patchUserTutorialResponse;
};