/**
 * 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 {
  PatchedThreadEventRequest,
  ThreadEvent,
  ThreadEventRequest,
} from ".././models";

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

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

/**
 * ViewSet for ThreadEvent model.
 */
export type threadsEventsListResponse200 = {
  data: ThreadEvent[];
  status: 200;
};

export type threadsEventsListResponseSuccess = threadsEventsListResponse200 & {
  headers: Headers;
};
export type threadsEventsListResponse = threadsEventsListResponseSuccess;

export const getThreadsEventsListUrl = (threadId: string) => {
  return `/api/v1.0/threads/${threadId}/events/`;
};

export const threadsEventsList = async (
  threadId: string,
  options?: RequestInit,
): Promise<threadsEventsListResponse> => {
  return fetchAPI<threadsEventsListResponse>(
    getThreadsEventsListUrl(threadId),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getThreadsEventsListQueryKey = (threadId?: string) => {
  return [`/api/v1.0/threads/${threadId}/events/`] as const;
};

export const getThreadsEventsListQueryOptions = <
  TData = Awaited<ReturnType<typeof threadsEventsList>>,
  TError = ErrorType<unknown>,
>(
  threadId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof threadsEventsList>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ?? getThreadsEventsListQueryKey(threadId);

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

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

export type ThreadsEventsListQueryResult = NonNullable<
  Awaited<ReturnType<typeof threadsEventsList>>
>;
export type ThreadsEventsListQueryError = ErrorType<unknown>;

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

export function useThreadsEventsList<
  TData = Awaited<ReturnType<typeof threadsEventsList>>,
  TError = ErrorType<unknown>,
>(
  threadId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof threadsEventsList>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getThreadsEventsListQueryOptions(threadId, options);

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * Create a ThreadEvent.

For ASSIGN/UNASSIGN, delegates to the service layer which owns the
idempotence rules, edit-rights validation and the undo window.
For IM, persists the event via the serializer and then re-syncs
MENTION rows.

Returns 204 when the service decides nothing was new (every
assignee already assigned, full UNASSIGN absorbed by undo, …).
 */
export type threadsEventsCreateResponse201 = {
  data: ThreadEvent;
  status: 201;
};

export type threadsEventsCreateResponseSuccess =
  threadsEventsCreateResponse201 & {
    headers: Headers;
  };
export type threadsEventsCreateResponse = threadsEventsCreateResponseSuccess;

export const getThreadsEventsCreateUrl = (threadId: string) => {
  return `/api/v1.0/threads/${threadId}/events/`;
};

export const threadsEventsCreate = async (
  threadId: string,
  threadEventRequest: ThreadEventRequest,
  options?: RequestInit,
): Promise<threadsEventsCreateResponse> => {
  return fetchAPI<threadsEventsCreateResponse>(
    getThreadsEventsCreateUrl(threadId),
    {
      ...options,
      method: "POST",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(threadEventRequest),
    },
  );
};

export const getThreadsEventsCreateMutationOptions = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof threadsEventsCreate>>,
    TError,
    { threadId: string; data: ThreadEventRequest },
    TContext
  >;
  request?: SecondParameter<typeof fetchAPI>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof threadsEventsCreate>>,
  TError,
  { threadId: string; data: ThreadEventRequest },
  TContext
> => {
  const mutationKey = ["threadsEventsCreate"];
  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 threadsEventsCreate>>,
    { threadId: string; data: ThreadEventRequest }
  > = (props) => {
    const { threadId, data } = props ?? {};

    return threadsEventsCreate(threadId, data, requestOptions);
  };

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

export type ThreadsEventsCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof threadsEventsCreate>>
>;
export type ThreadsEventsCreateMutationBody = ThreadEventRequest;
export type ThreadsEventsCreateMutationError = ErrorType<unknown>;

export const useThreadsEventsCreate = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof threadsEventsCreate>>,
      TError,
      { threadId: string; data: ThreadEventRequest },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof threadsEventsCreate>>,
  TError,
  { threadId: string; data: ThreadEventRequest },
  TContext
> => {
  const mutationOptions = getThreadsEventsCreateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * ViewSet for ThreadEvent model.
 */
export type threadsEventsRetrieveResponse200 = {
  data: ThreadEvent;
  status: 200;
};

export type threadsEventsRetrieveResponseSuccess =
  threadsEventsRetrieveResponse200 & {
    headers: Headers;
  };
export type threadsEventsRetrieveResponse =
  threadsEventsRetrieveResponseSuccess;

export const getThreadsEventsRetrieveUrl = (threadId: string, id: string) => {
  return `/api/v1.0/threads/${threadId}/events/${id}/`;
};

export const threadsEventsRetrieve = async (
  threadId: string,
  id: string,
  options?: RequestInit,
): Promise<threadsEventsRetrieveResponse> => {
  return fetchAPI<threadsEventsRetrieveResponse>(
    getThreadsEventsRetrieveUrl(threadId, id),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getThreadsEventsRetrieveQueryKey = (
  threadId?: string,
  id?: string,
) => {
  return [`/api/v1.0/threads/${threadId}/events/${id}/`] as const;
};

export const getThreadsEventsRetrieveQueryOptions = <
  TData = Awaited<ReturnType<typeof threadsEventsRetrieve>>,
  TError = ErrorType<unknown>,
>(
  threadId: string,
  id: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof threadsEventsRetrieve>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ?? getThreadsEventsRetrieveQueryKey(threadId, id);

  const queryFn: QueryFunction<
    Awaited<ReturnType<typeof threadsEventsRetrieve>>
  > = ({ signal }) =>
    threadsEventsRetrieve(threadId, id, { signal, ...requestOptions });

  return {
    queryKey,
    queryFn,
    enabled: !!(threadId && id),
    ...queryOptions,
  } as UseQueryOptions<
    Awaited<ReturnType<typeof threadsEventsRetrieve>>,
    TError,
    TData
  > & { queryKey: DataTag<QueryKey, TData, TError> };
};

export type ThreadsEventsRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof threadsEventsRetrieve>>
>;
export type ThreadsEventsRetrieveQueryError = ErrorType<unknown>;

export function useThreadsEventsRetrieve<
  TData = Awaited<ReturnType<typeof threadsEventsRetrieve>>,
  TError = ErrorType<unknown>,
>(
  threadId: string,
  id: string,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof threadsEventsRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof threadsEventsRetrieve>>,
          TError,
          Awaited<ReturnType<typeof threadsEventsRetrieve>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useThreadsEventsRetrieve<
  TData = Awaited<ReturnType<typeof threadsEventsRetrieve>>,
  TError = ErrorType<unknown>,
>(
  threadId: string,
  id: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof threadsEventsRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof threadsEventsRetrieve>>,
          TError,
          Awaited<ReturnType<typeof threadsEventsRetrieve>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useThreadsEventsRetrieve<
  TData = Awaited<ReturnType<typeof threadsEventsRetrieve>>,
  TError = ErrorType<unknown>,
>(
  threadId: string,
  id: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof threadsEventsRetrieve>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};

export function useThreadsEventsRetrieve<
  TData = Awaited<ReturnType<typeof threadsEventsRetrieve>>,
  TError = ErrorType<unknown>,
>(
  threadId: string,
  id: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof threadsEventsRetrieve>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getThreadsEventsRetrieveQueryOptions(
    threadId,
    id,
    options,
  );

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * ViewSet for ThreadEvent model.
 */
export type threadsEventsUpdateResponse200 = {
  data: ThreadEvent;
  status: 200;
};

export type threadsEventsUpdateResponseSuccess =
  threadsEventsUpdateResponse200 & {
    headers: Headers;
  };
export type threadsEventsUpdateResponse = threadsEventsUpdateResponseSuccess;

export const getThreadsEventsUpdateUrl = (threadId: string, id: string) => {
  return `/api/v1.0/threads/${threadId}/events/${id}/`;
};

export const threadsEventsUpdate = async (
  threadId: string,
  id: string,
  threadEventRequest: ThreadEventRequest,
  options?: RequestInit,
): Promise<threadsEventsUpdateResponse> => {
  return fetchAPI<threadsEventsUpdateResponse>(
    getThreadsEventsUpdateUrl(threadId, id),
    {
      ...options,
      method: "PUT",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(threadEventRequest),
    },
  );
};

export const getThreadsEventsUpdateMutationOptions = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof threadsEventsUpdate>>,
    TError,
    { threadId: string; id: string; data: ThreadEventRequest },
    TContext
  >;
  request?: SecondParameter<typeof fetchAPI>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof threadsEventsUpdate>>,
  TError,
  { threadId: string; id: string; data: ThreadEventRequest },
  TContext
> => {
  const mutationKey = ["threadsEventsUpdate"];
  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 threadsEventsUpdate>>,
    { threadId: string; id: string; data: ThreadEventRequest }
  > = (props) => {
    const { threadId, id, data } = props ?? {};

    return threadsEventsUpdate(threadId, id, data, requestOptions);
  };

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

export type ThreadsEventsUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof threadsEventsUpdate>>
>;
export type ThreadsEventsUpdateMutationBody = ThreadEventRequest;
export type ThreadsEventsUpdateMutationError = ErrorType<unknown>;

export const useThreadsEventsUpdate = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof threadsEventsUpdate>>,
      TError,
      { threadId: string; id: string; data: ThreadEventRequest },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof threadsEventsUpdate>>,
  TError,
  { threadId: string; id: string; data: ThreadEventRequest },
  TContext
> => {
  const mutationOptions = getThreadsEventsUpdateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * ViewSet for ThreadEvent model.
 */
export type threadsEventsPartialUpdateResponse200 = {
  data: ThreadEvent;
  status: 200;
};

export type threadsEventsPartialUpdateResponseSuccess =
  threadsEventsPartialUpdateResponse200 & {
    headers: Headers;
  };
export type threadsEventsPartialUpdateResponse =
  threadsEventsPartialUpdateResponseSuccess;

export const getThreadsEventsPartialUpdateUrl = (
  threadId: string,
  id: string,
) => {
  return `/api/v1.0/threads/${threadId}/events/${id}/`;
};

export const threadsEventsPartialUpdate = async (
  threadId: string,
  id: string,
  patchedThreadEventRequest: PatchedThreadEventRequest,
  options?: RequestInit,
): Promise<threadsEventsPartialUpdateResponse> => {
  return fetchAPI<threadsEventsPartialUpdateResponse>(
    getThreadsEventsPartialUpdateUrl(threadId, id),
    {
      ...options,
      method: "PATCH",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(patchedThreadEventRequest),
    },
  );
};

export const getThreadsEventsPartialUpdateMutationOptions = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof threadsEventsPartialUpdate>>,
    TError,
    { threadId: string; id: string; data: PatchedThreadEventRequest },
    TContext
  >;
  request?: SecondParameter<typeof fetchAPI>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof threadsEventsPartialUpdate>>,
  TError,
  { threadId: string; id: string; data: PatchedThreadEventRequest },
  TContext
> => {
  const mutationKey = ["threadsEventsPartialUpdate"];
  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 threadsEventsPartialUpdate>>,
    { threadId: string; id: string; data: PatchedThreadEventRequest }
  > = (props) => {
    const { threadId, id, data } = props ?? {};

    return threadsEventsPartialUpdate(threadId, id, data, requestOptions);
  };

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

export type ThreadsEventsPartialUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof threadsEventsPartialUpdate>>
>;
export type ThreadsEventsPartialUpdateMutationBody = PatchedThreadEventRequest;
export type ThreadsEventsPartialUpdateMutationError = ErrorType<unknown>;

export const useThreadsEventsPartialUpdate = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof threadsEventsPartialUpdate>>,
      TError,
      { threadId: string; id: string; data: PatchedThreadEventRequest },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof threadsEventsPartialUpdate>>,
  TError,
  { threadId: string; id: string; data: PatchedThreadEventRequest },
  TContext
> => {
  const mutationOptions = getThreadsEventsPartialUpdateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * ViewSet for ThreadEvent model.
 */
export type threadsEventsDestroyResponse204 = {
  data: void;
  status: 204;
};

export type threadsEventsDestroyResponseSuccess =
  threadsEventsDestroyResponse204 & {
    headers: Headers;
  };
export type threadsEventsDestroyResponse = threadsEventsDestroyResponseSuccess;

export const getThreadsEventsDestroyUrl = (threadId: string, id: string) => {
  return `/api/v1.0/threads/${threadId}/events/${id}/`;
};

export const threadsEventsDestroy = async (
  threadId: string,
  id: string,
  options?: RequestInit,
): Promise<threadsEventsDestroyResponse> => {
  return fetchAPI<threadsEventsDestroyResponse>(
    getThreadsEventsDestroyUrl(threadId, id),
    {
      ...options,
      method: "DELETE",
    },
  );
};

export const getThreadsEventsDestroyMutationOptions = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof threadsEventsDestroy>>,
    TError,
    { threadId: string; id: string },
    TContext
  >;
  request?: SecondParameter<typeof fetchAPI>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof threadsEventsDestroy>>,
  TError,
  { threadId: string; id: string },
  TContext
> => {
  const mutationKey = ["threadsEventsDestroy"];
  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 threadsEventsDestroy>>,
    { threadId: string; id: string }
  > = (props) => {
    const { threadId, id } = props ?? {};

    return threadsEventsDestroy(threadId, id, requestOptions);
  };

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

export type ThreadsEventsDestroyMutationResult = NonNullable<
  Awaited<ReturnType<typeof threadsEventsDestroy>>
>;

export type ThreadsEventsDestroyMutationError = ErrorType<unknown>;

export const useThreadsEventsDestroy = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof threadsEventsDestroy>>,
      TError,
      { threadId: string; id: string },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof threadsEventsDestroy>>,
  TError,
  { threadId: string; id: string },
  TContext
> => {
  const mutationOptions = getThreadsEventsDestroyMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * Mark the current user's unread MENTION on this ThreadEvent as read.

Returns 204 even when no UserEvent matches (idempotent); the thread
event itself is resolved via the standard ``get_object`` lookup so a
missing event yields 404.
 */
export type threadsEventsReadMentionPartialUpdateResponse204 = {
  data: void;
  status: 204;
};

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

export type threadsEventsReadMentionPartialUpdateResponseSuccess =
  threadsEventsReadMentionPartialUpdateResponse204 & {
    headers: Headers;
  };
export type threadsEventsReadMentionPartialUpdateResponseError =
  threadsEventsReadMentionPartialUpdateResponse404 & {
    headers: Headers;
  };

export type threadsEventsReadMentionPartialUpdateResponse =
  | threadsEventsReadMentionPartialUpdateResponseSuccess
  | threadsEventsReadMentionPartialUpdateResponseError;

export const getThreadsEventsReadMentionPartialUpdateUrl = (
  threadId: string,
  id: string,
) => {
  return `/api/v1.0/threads/${threadId}/events/${id}/read-mention/`;
};

export const threadsEventsReadMentionPartialUpdate = async (
  threadId: string,
  id: string,
  options?: RequestInit,
): Promise<threadsEventsReadMentionPartialUpdateResponse> => {
  return fetchAPI<threadsEventsReadMentionPartialUpdateResponse>(
    getThreadsEventsReadMentionPartialUpdateUrl(threadId, id),
    {
      ...options,
      method: "PATCH",
    },
  );
};

export const getThreadsEventsReadMentionPartialUpdateMutationOptions = <
  TError = ErrorType<void>,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof threadsEventsReadMentionPartialUpdate>>,
    TError,
    { threadId: string; id: string },
    TContext
  >;
  request?: SecondParameter<typeof fetchAPI>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof threadsEventsReadMentionPartialUpdate>>,
  TError,
  { threadId: string; id: string },
  TContext
> => {
  const mutationKey = ["threadsEventsReadMentionPartialUpdate"];
  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 threadsEventsReadMentionPartialUpdate>>,
    { threadId: string; id: string }
  > = (props) => {
    const { threadId, id } = props ?? {};

    return threadsEventsReadMentionPartialUpdate(threadId, id, requestOptions);
  };

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

export type ThreadsEventsReadMentionPartialUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof threadsEventsReadMentionPartialUpdate>>
>;

export type ThreadsEventsReadMentionPartialUpdateMutationError =
  ErrorType<void>;

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

  return useMutation(mutationOptions, queryClient);
};
