/**
 * Generated by orval 🍺
 * Do not edit manually.
 * messages API
 * This is the messages API schema.
 * OpenAPI spec version: 1.0.0 (v1.0)
 */
import { useMutation, useQuery } from "@tanstack/react-query";
import type {
  DataTag,
  DefinedInitialDataOptions,
  DefinedUseQueryResult,
  MutationFunction,
  QueryClient,
  QueryFunction,
  QueryKey,
  UndefinedInitialDataOptions,
  UseMutationOptions,
  UseMutationResult,
  UseQueryOptions,
  UseQueryResult,
} from "@tanstack/react-query";

import type {
  Label,
  LabelRequest,
  LabelsAddThreadsCreateBody,
  LabelsListParams,
  LabelsRemoveThreadsCreateBody,
  PatchedLabelRequest,
  TreeLabel,
} from ".././models";

import { fetchAPI } from "../../fetch-api";
import type { ErrorType } from "../../fetch-api";

type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];

/**
 * 
        List all labels accessible to the user in a hierarchical structure.

        The response returns labels in a tree structure where:
        - Labels are ordered alphabetically by name
        - Each label includes its children (sub-labels)
        - The hierarchy is determined by the label's name (e.g., "Inbox/Important" is a child of "Inbox")

        You can filter labels by mailbox using the mailbox_id query parameter.
        
 */
export type labelsListResponse200 = {
  data: TreeLabel[];
  status: 200;
};

export type labelsListResponseSuccess = labelsListResponse200 & {
  headers: Headers;
};
export type labelsListResponse = labelsListResponseSuccess;

export const getLabelsListUrl = (params?: LabelsListParams) => {
  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
    ? `/api/v1.0/labels/?${stringifiedParams}`
    : `/api/v1.0/labels/`;
};

export const labelsList = async (
  params?: LabelsListParams,
  options?: RequestInit,
): Promise<labelsListResponse> => {
  return fetchAPI<labelsListResponse>(getLabelsListUrl(params), {
    ...options,
    method: "GET",
  });
};

export const getLabelsListQueryKey = (params?: LabelsListParams) => {
  return [`/api/v1.0/labels/`, ...(params ? [params] : [])] as const;
};

export const getLabelsListQueryOptions = <
  TData = Awaited<ReturnType<typeof labelsList>>,
  TError = ErrorType<unknown>,
>(
  params?: LabelsListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<Awaited<ReturnType<typeof labelsList>>, TError, TData>
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey = queryOptions?.queryKey ?? getLabelsListQueryKey(params);

  const queryFn: QueryFunction<Awaited<ReturnType<typeof labelsList>>> = ({
    signal,
  }) => labelsList(params, { signal, ...requestOptions });

  return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
    Awaited<ReturnType<typeof labelsList>>,
    TError,
    TData
  > & { queryKey: DataTag<QueryKey, TData, TError> };
};

export type LabelsListQueryResult = NonNullable<
  Awaited<ReturnType<typeof labelsList>>
>;
export type LabelsListQueryError = ErrorType<unknown>;

export function useLabelsList<
  TData = Awaited<ReturnType<typeof labelsList>>,
  TError = ErrorType<unknown>,
>(
  params: undefined | LabelsListParams,
  options: {
    query: Partial<
      UseQueryOptions<Awaited<ReturnType<typeof labelsList>>, TError, TData>
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof labelsList>>,
          TError,
          Awaited<ReturnType<typeof labelsList>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useLabelsList<
  TData = Awaited<ReturnType<typeof labelsList>>,
  TError = ErrorType<unknown>,
>(
  params?: LabelsListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<Awaited<ReturnType<typeof labelsList>>, TError, TData>
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof labelsList>>,
          TError,
          Awaited<ReturnType<typeof labelsList>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useLabelsList<
  TData = Awaited<ReturnType<typeof labelsList>>,
  TError = ErrorType<unknown>,
>(
  params?: LabelsListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<Awaited<ReturnType<typeof labelsList>>, TError, TData>
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};

export function useLabelsList<
  TData = Awaited<ReturnType<typeof labelsList>>,
  TError = ErrorType<unknown>,
>(
  params?: LabelsListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<Awaited<ReturnType<typeof labelsList>>, TError, TData>
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getLabelsListQueryOptions(params, options);

  const query = useQuery(queryOptions, queryClient) as UseQueryResult<
    TData,
    TError
  > & { queryKey: DataTag<QueryKey, TData, TError> };

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * View and manage labels
 */
export type labelsCreateResponse201 = {
  data: Label;
  status: 201;
};

export type labelsCreateResponse400 = {
  data: unknown;
  status: 400;
};

export type labelsCreateResponse403 = {
  data: unknown;
  status: 403;
};

export type labelsCreateResponseSuccess = labelsCreateResponse201 & {
  headers: Headers;
};
export type labelsCreateResponseError = (
  | labelsCreateResponse400
  | labelsCreateResponse403
) & {
  headers: Headers;
};

export type labelsCreateResponse =
  | labelsCreateResponseSuccess
  | labelsCreateResponseError;

export const getLabelsCreateUrl = () => {
  return `/api/v1.0/labels/`;
};

export const labelsCreate = async (
  labelRequest: LabelRequest,
  options?: RequestInit,
): Promise<labelsCreateResponse> => {
  return fetchAPI<labelsCreateResponse>(getLabelsCreateUrl(), {
    ...options,
    method: "POST",
    headers: { "Content-Type": "application/json", ...options?.headers },
    body: JSON.stringify(labelRequest),
  });
};

export const getLabelsCreateMutationOptions = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof labelsCreate>>,
    TError,
    { data: LabelRequest },
    TContext
  >;
  request?: SecondParameter<typeof fetchAPI>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof labelsCreate>>,
  TError,
  { data: LabelRequest },
  TContext
> => {
  const mutationKey = ["labelsCreate"];
  const { mutation: mutationOptions, request: requestOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey }, request: undefined };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof labelsCreate>>,
    { data: LabelRequest }
  > = (props) => {
    const { data } = props ?? {};

    return labelsCreate(data, requestOptions);
  };

  return { mutationFn, ...mutationOptions };
};

export type LabelsCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof labelsCreate>>
>;
export type LabelsCreateMutationBody = LabelRequest;
export type LabelsCreateMutationError = ErrorType<unknown>;

export const useLabelsCreate = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof labelsCreate>>,
      TError,
      { data: LabelRequest },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof labelsCreate>>,
  TError,
  { data: LabelRequest },
  TContext
> => {
  const mutationOptions = getLabelsCreateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * View and manage labels
 */
export type labelsUpdateResponse200 = {
  data: Label;
  status: 200;
};

export type labelsUpdateResponse400 = {
  data: unknown;
  status: 400;
};

export type labelsUpdateResponse403 = {
  data: unknown;
  status: 403;
};

export type labelsUpdateResponseSuccess = labelsUpdateResponse200 & {
  headers: Headers;
};
export type labelsUpdateResponseError = (
  | labelsUpdateResponse400
  | labelsUpdateResponse403
) & {
  headers: Headers;
};

export type labelsUpdateResponse =
  | labelsUpdateResponseSuccess
  | labelsUpdateResponseError;

export const getLabelsUpdateUrl = (id: string) => {
  return `/api/v1.0/labels/${id}/`;
};

export const labelsUpdate = async (
  id: string,
  labelRequest: LabelRequest,
  options?: RequestInit,
): Promise<labelsUpdateResponse> => {
  return fetchAPI<labelsUpdateResponse>(getLabelsUpdateUrl(id), {
    ...options,
    method: "PUT",
    headers: { "Content-Type": "application/json", ...options?.headers },
    body: JSON.stringify(labelRequest),
  });
};

export const getLabelsUpdateMutationOptions = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof labelsUpdate>>,
    TError,
    { id: string; data: LabelRequest },
    TContext
  >;
  request?: SecondParameter<typeof fetchAPI>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof labelsUpdate>>,
  TError,
  { id: string; data: LabelRequest },
  TContext
> => {
  const mutationKey = ["labelsUpdate"];
  const { mutation: mutationOptions, request: requestOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey }, request: undefined };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof labelsUpdate>>,
    { id: string; data: LabelRequest }
  > = (props) => {
    const { id, data } = props ?? {};

    return labelsUpdate(id, data, requestOptions);
  };

  return { mutationFn, ...mutationOptions };
};

export type LabelsUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof labelsUpdate>>
>;
export type LabelsUpdateMutationBody = LabelRequest;
export type LabelsUpdateMutationError = ErrorType<unknown>;

export const useLabelsUpdate = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof labelsUpdate>>,
      TError,
      { id: string; data: LabelRequest },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof labelsUpdate>>,
  TError,
  { id: string; data: LabelRequest },
  TContext
> => {
  const mutationOptions = getLabelsUpdateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * View and manage labels
 */
export type labelsPartialUpdateResponse200 = {
  data: Label;
  status: 200;
};

export type labelsPartialUpdateResponseSuccess =
  labelsPartialUpdateResponse200 & {
    headers: Headers;
  };
export type labelsPartialUpdateResponse = labelsPartialUpdateResponseSuccess;

export const getLabelsPartialUpdateUrl = (id: string) => {
  return `/api/v1.0/labels/${id}/`;
};

export const labelsPartialUpdate = async (
  id: string,
  patchedLabelRequest: PatchedLabelRequest,
  options?: RequestInit,
): Promise<labelsPartialUpdateResponse> => {
  return fetchAPI<labelsPartialUpdateResponse>(getLabelsPartialUpdateUrl(id), {
    ...options,
    method: "PATCH",
    headers: { "Content-Type": "application/json", ...options?.headers },
    body: JSON.stringify(patchedLabelRequest),
  });
};

export const getLabelsPartialUpdateMutationOptions = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof labelsPartialUpdate>>,
    TError,
    { id: string; data: PatchedLabelRequest },
    TContext
  >;
  request?: SecondParameter<typeof fetchAPI>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof labelsPartialUpdate>>,
  TError,
  { id: string; data: PatchedLabelRequest },
  TContext
> => {
  const mutationKey = ["labelsPartialUpdate"];
  const { mutation: mutationOptions, request: requestOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey }, request: undefined };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof labelsPartialUpdate>>,
    { id: string; data: PatchedLabelRequest }
  > = (props) => {
    const { id, data } = props ?? {};

    return labelsPartialUpdate(id, data, requestOptions);
  };

  return { mutationFn, ...mutationOptions };
};

export type LabelsPartialUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof labelsPartialUpdate>>
>;
export type LabelsPartialUpdateMutationBody = PatchedLabelRequest;
export type LabelsPartialUpdateMutationError = ErrorType<unknown>;

export const useLabelsPartialUpdate = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof labelsPartialUpdate>>,
      TError,
      { id: string; data: PatchedLabelRequest },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof labelsPartialUpdate>>,
  TError,
  { id: string; data: PatchedLabelRequest },
  TContext
> => {
  const mutationOptions = getLabelsPartialUpdateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * View and manage labels
 */
export type labelsDestroyResponse204 = {
  data: void;
  status: 204;
};

export type labelsDestroyResponse403 = {
  data: unknown;
  status: 403;
};

export type labelsDestroyResponse404 = {
  data: void;
  status: 404;
};

export type labelsDestroyResponseSuccess = labelsDestroyResponse204 & {
  headers: Headers;
};
export type labelsDestroyResponseError = (
  | labelsDestroyResponse403
  | labelsDestroyResponse404
) & {
  headers: Headers;
};

export type labelsDestroyResponse =
  | labelsDestroyResponseSuccess
  | labelsDestroyResponseError;

export const getLabelsDestroyUrl = (id: string) => {
  return `/api/v1.0/labels/${id}/`;
};

export const labelsDestroy = async (
  id: string,
  options?: RequestInit,
): Promise<labelsDestroyResponse> => {
  return fetchAPI<labelsDestroyResponse>(getLabelsDestroyUrl(id), {
    ...options,
    method: "DELETE",
  });
};

export const getLabelsDestroyMutationOptions = <
  TError = ErrorType<unknown | void>,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof labelsDestroy>>,
    TError,
    { id: string },
    TContext
  >;
  request?: SecondParameter<typeof fetchAPI>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof labelsDestroy>>,
  TError,
  { id: string },
  TContext
> => {
  const mutationKey = ["labelsDestroy"];
  const { mutation: mutationOptions, request: requestOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey }, request: undefined };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof labelsDestroy>>,
    { id: string }
  > = (props) => {
    const { id } = props ?? {};

    return labelsDestroy(id, requestOptions);
  };

  return { mutationFn, ...mutationOptions };
};

export type LabelsDestroyMutationResult = NonNullable<
  Awaited<ReturnType<typeof labelsDestroy>>
>;

export type LabelsDestroyMutationError = ErrorType<unknown | void>;

export const useLabelsDestroy = <
  TError = ErrorType<unknown | void>,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof labelsDestroy>>,
      TError,
      { id: string },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof labelsDestroy>>,
  TError,
  { id: string },
  TContext
> => {
  const mutationOptions = getLabelsDestroyMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * View and manage labels
 */
export type labelsAddThreadsCreateResponse200 = {
  data: Label;
  status: 200;
};

export type labelsAddThreadsCreateResponse400 = {
  data: unknown;
  status: 400;
};

export type labelsAddThreadsCreateResponse403 = {
  data: unknown;
  status: 403;
};

export type labelsAddThreadsCreateResponseSuccess =
  labelsAddThreadsCreateResponse200 & {
    headers: Headers;
  };
export type labelsAddThreadsCreateResponseError = (
  | labelsAddThreadsCreateResponse400
  | labelsAddThreadsCreateResponse403
) & {
  headers: Headers;
};

export type labelsAddThreadsCreateResponse =
  | labelsAddThreadsCreateResponseSuccess
  | labelsAddThreadsCreateResponseError;

export const getLabelsAddThreadsCreateUrl = (id: string) => {
  return `/api/v1.0/labels/${id}/add-threads/`;
};

export const labelsAddThreadsCreate = async (
  id: string,
  labelsAddThreadsCreateBody: LabelsAddThreadsCreateBody,
  options?: RequestInit,
): Promise<labelsAddThreadsCreateResponse> => {
  return fetchAPI<labelsAddThreadsCreateResponse>(
    getLabelsAddThreadsCreateUrl(id),
    {
      ...options,
      method: "POST",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(labelsAddThreadsCreateBody),
    },
  );
};

export const getLabelsAddThreadsCreateMutationOptions = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof labelsAddThreadsCreate>>,
    TError,
    { id: string; data: LabelsAddThreadsCreateBody },
    TContext
  >;
  request?: SecondParameter<typeof fetchAPI>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof labelsAddThreadsCreate>>,
  TError,
  { id: string; data: LabelsAddThreadsCreateBody },
  TContext
> => {
  const mutationKey = ["labelsAddThreadsCreate"];
  const { mutation: mutationOptions, request: requestOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey }, request: undefined };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof labelsAddThreadsCreate>>,
    { id: string; data: LabelsAddThreadsCreateBody }
  > = (props) => {
    const { id, data } = props ?? {};

    return labelsAddThreadsCreate(id, data, requestOptions);
  };

  return { mutationFn, ...mutationOptions };
};

export type LabelsAddThreadsCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof labelsAddThreadsCreate>>
>;
export type LabelsAddThreadsCreateMutationBody = LabelsAddThreadsCreateBody;
export type LabelsAddThreadsCreateMutationError = ErrorType<unknown>;

export const useLabelsAddThreadsCreate = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof labelsAddThreadsCreate>>,
      TError,
      { id: string; data: LabelsAddThreadsCreateBody },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof labelsAddThreadsCreate>>,
  TError,
  { id: string; data: LabelsAddThreadsCreateBody },
  TContext
> => {
  const mutationOptions = getLabelsAddThreadsCreateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * View and manage labels
 */
export type labelsRemoveThreadsCreateResponse200 = {
  data: Label;
  status: 200;
};

export type labelsRemoveThreadsCreateResponse400 = {
  data: unknown;
  status: 400;
};

export type labelsRemoveThreadsCreateResponse403 = {
  data: unknown;
  status: 403;
};

export type labelsRemoveThreadsCreateResponseSuccess =
  labelsRemoveThreadsCreateResponse200 & {
    headers: Headers;
  };
export type labelsRemoveThreadsCreateResponseError = (
  | labelsRemoveThreadsCreateResponse400
  | labelsRemoveThreadsCreateResponse403
) & {
  headers: Headers;
};

export type labelsRemoveThreadsCreateResponse =
  | labelsRemoveThreadsCreateResponseSuccess
  | labelsRemoveThreadsCreateResponseError;

export const getLabelsRemoveThreadsCreateUrl = (id: string) => {
  return `/api/v1.0/labels/${id}/remove-threads/`;
};

export const labelsRemoveThreadsCreate = async (
  id: string,
  labelsRemoveThreadsCreateBody: LabelsRemoveThreadsCreateBody,
  options?: RequestInit,
): Promise<labelsRemoveThreadsCreateResponse> => {
  return fetchAPI<labelsRemoveThreadsCreateResponse>(
    getLabelsRemoveThreadsCreateUrl(id),
    {
      ...options,
      method: "POST",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(labelsRemoveThreadsCreateBody),
    },
  );
};

export const getLabelsRemoveThreadsCreateMutationOptions = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof labelsRemoveThreadsCreate>>,
    TError,
    { id: string; data: LabelsRemoveThreadsCreateBody },
    TContext
  >;
  request?: SecondParameter<typeof fetchAPI>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof labelsRemoveThreadsCreate>>,
  TError,
  { id: string; data: LabelsRemoveThreadsCreateBody },
  TContext
> => {
  const mutationKey = ["labelsRemoveThreadsCreate"];
  const { mutation: mutationOptions, request: requestOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey }, request: undefined };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof labelsRemoveThreadsCreate>>,
    { id: string; data: LabelsRemoveThreadsCreateBody }
  > = (props) => {
    const { id, data } = props ?? {};

    return labelsRemoveThreadsCreate(id, data, requestOptions);
  };

  return { mutationFn, ...mutationOptions };
};

export type LabelsRemoveThreadsCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof labelsRemoveThreadsCreate>>
>;
export type LabelsRemoveThreadsCreateMutationBody =
  LabelsRemoveThreadsCreateBody;
export type LabelsRemoveThreadsCreateMutationError = ErrorType<unknown>;

export const useLabelsRemoveThreadsCreate = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof labelsRemoveThreadsCreate>>,
      TError,
      { id: string; data: LabelsRemoveThreadsCreateBody },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof labelsRemoveThreadsCreate>>,
  TError,
  { id: string; data: LabelsRemoveThreadsCreateBody },
  TContext
> => {
  const mutationOptions = getLabelsRemoveThreadsCreateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
