/**
 * 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 {
  Channel,
  ChannelRequest,
  PatchedChannelRequest,
} from ".././models";

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

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

/**
 * Manage integration channels for a mailbox
 */
export type mailboxesChannelsListResponse200 = {
  data: Channel[];
  status: 200;
};

export type mailboxesChannelsListResponseSuccess =
  mailboxesChannelsListResponse200 & {
    headers: Headers;
  };
export type mailboxesChannelsListResponse =
  mailboxesChannelsListResponseSuccess;

export const getMailboxesChannelsListUrl = (mailboxId: string) => {
  return `/api/v1.0/mailboxes/${mailboxId}/channels/`;
};

export const mailboxesChannelsList = async (
  mailboxId: string,
  options?: RequestInit,
): Promise<mailboxesChannelsListResponse> => {
  return fetchAPI<mailboxesChannelsListResponse>(
    getMailboxesChannelsListUrl(mailboxId),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getMailboxesChannelsListQueryKey = (mailboxId?: string) => {
  return [`/api/v1.0/mailboxes/${mailboxId}/channels/`] as const;
};

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

  const queryKey =
    queryOptions?.queryKey ?? getMailboxesChannelsListQueryKey(mailboxId);

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

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

export type MailboxesChannelsListQueryResult = NonNullable<
  Awaited<ReturnType<typeof mailboxesChannelsList>>
>;
export type MailboxesChannelsListQueryError = unknown;

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

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

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * Manage integration channels for a mailbox
 */
export type mailboxesChannelsCreateResponse201 = {
  data: Channel;
  status: 201;
};

export type mailboxesChannelsCreateResponse400 = {
  data: void;
  status: 400;
};

export type mailboxesChannelsCreateResponse403 = {
  data: void;
  status: 403;
};

export type mailboxesChannelsCreateResponseSuccess =
  mailboxesChannelsCreateResponse201 & {
    headers: Headers;
  };
export type mailboxesChannelsCreateResponseError = (
  | mailboxesChannelsCreateResponse400
  | mailboxesChannelsCreateResponse403
) & {
  headers: Headers;
};

export type mailboxesChannelsCreateResponse =
  | mailboxesChannelsCreateResponseSuccess
  | mailboxesChannelsCreateResponseError;

export const getMailboxesChannelsCreateUrl = (mailboxId: string) => {
  return `/api/v1.0/mailboxes/${mailboxId}/channels/`;
};

export const mailboxesChannelsCreate = async (
  mailboxId: string,
  channelRequest: ChannelRequest,
  options?: RequestInit,
): Promise<mailboxesChannelsCreateResponse> => {
  return fetchAPI<mailboxesChannelsCreateResponse>(
    getMailboxesChannelsCreateUrl(mailboxId),
    {
      ...options,
      method: "POST",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(channelRequest),
    },
  );
};

export const getMailboxesChannelsCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof mailboxesChannelsCreate>>,
    TError,
    { mailboxId: string; data: ChannelRequest },
    TContext
  >;
  request?: SecondParameter<typeof fetchAPI>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof mailboxesChannelsCreate>>,
  TError,
  { mailboxId: string; data: ChannelRequest },
  TContext
> => {
  const mutationKey = ["mailboxesChannelsCreate"];
  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 mailboxesChannelsCreate>>,
    { mailboxId: string; data: ChannelRequest }
  > = (props) => {
    const { mailboxId, data } = props ?? {};

    return mailboxesChannelsCreate(mailboxId, data, requestOptions);
  };

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

export type MailboxesChannelsCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof mailboxesChannelsCreate>>
>;
export type MailboxesChannelsCreateMutationBody = ChannelRequest;
export type MailboxesChannelsCreateMutationError = void;

export const useMailboxesChannelsCreate = <TError = void, TContext = unknown>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof mailboxesChannelsCreate>>,
      TError,
      { mailboxId: string; data: ChannelRequest },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof mailboxesChannelsCreate>>,
  TError,
  { mailboxId: string; data: ChannelRequest },
  TContext
> => {
  const mutationOptions = getMailboxesChannelsCreateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * Manage integration channels for a mailbox
 */
export type mailboxesChannelsRetrieveResponse200 = {
  data: Channel;
  status: 200;
};

export type mailboxesChannelsRetrieveResponseSuccess =
  mailboxesChannelsRetrieveResponse200 & {
    headers: Headers;
  };
export type mailboxesChannelsRetrieveResponse =
  mailboxesChannelsRetrieveResponseSuccess;

export const getMailboxesChannelsRetrieveUrl = (
  mailboxId: string,
  id: string,
) => {
  return `/api/v1.0/mailboxes/${mailboxId}/channels/${id}/`;
};

export const mailboxesChannelsRetrieve = async (
  mailboxId: string,
  id: string,
  options?: RequestInit,
): Promise<mailboxesChannelsRetrieveResponse> => {
  return fetchAPI<mailboxesChannelsRetrieveResponse>(
    getMailboxesChannelsRetrieveUrl(mailboxId, id),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getMailboxesChannelsRetrieveQueryKey = (
  mailboxId?: string,
  id?: string,
) => {
  return [`/api/v1.0/mailboxes/${mailboxId}/channels/${id}/`] as const;
};

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

  const queryKey =
    queryOptions?.queryKey ??
    getMailboxesChannelsRetrieveQueryKey(mailboxId, id);

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

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

export type MailboxesChannelsRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof mailboxesChannelsRetrieve>>
>;
export type MailboxesChannelsRetrieveQueryError = unknown;

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

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

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * Manage integration channels for a mailbox
 */
export type mailboxesChannelsUpdateResponse200 = {
  data: Channel;
  status: 200;
};

export type mailboxesChannelsUpdateResponse400 = {
  data: void;
  status: 400;
};

export type mailboxesChannelsUpdateResponse403 = {
  data: void;
  status: 403;
};

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

export type mailboxesChannelsUpdateResponseSuccess =
  mailboxesChannelsUpdateResponse200 & {
    headers: Headers;
  };
export type mailboxesChannelsUpdateResponseError = (
  | mailboxesChannelsUpdateResponse400
  | mailboxesChannelsUpdateResponse403
  | mailboxesChannelsUpdateResponse404
) & {
  headers: Headers;
};

export type mailboxesChannelsUpdateResponse =
  | mailboxesChannelsUpdateResponseSuccess
  | mailboxesChannelsUpdateResponseError;

export const getMailboxesChannelsUpdateUrl = (
  mailboxId: string,
  id: string,
) => {
  return `/api/v1.0/mailboxes/${mailboxId}/channels/${id}/`;
};

export const mailboxesChannelsUpdate = async (
  mailboxId: string,
  id: string,
  channelRequest: ChannelRequest,
  options?: RequestInit,
): Promise<mailboxesChannelsUpdateResponse> => {
  return fetchAPI<mailboxesChannelsUpdateResponse>(
    getMailboxesChannelsUpdateUrl(mailboxId, id),
    {
      ...options,
      method: "PUT",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(channelRequest),
    },
  );
};

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

    return mailboxesChannelsUpdate(mailboxId, id, data, requestOptions);
  };

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

export type MailboxesChannelsUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof mailboxesChannelsUpdate>>
>;
export type MailboxesChannelsUpdateMutationBody = ChannelRequest;
export type MailboxesChannelsUpdateMutationError = void;

export const useMailboxesChannelsUpdate = <TError = void, TContext = unknown>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof mailboxesChannelsUpdate>>,
      TError,
      { mailboxId: string; id: string; data: ChannelRequest },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof mailboxesChannelsUpdate>>,
  TError,
  { mailboxId: string; id: string; data: ChannelRequest },
  TContext
> => {
  const mutationOptions = getMailboxesChannelsUpdateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * Manage integration channels for a mailbox
 */
export type mailboxesChannelsPartialUpdateResponse200 = {
  data: Channel;
  status: 200;
};

export type mailboxesChannelsPartialUpdateResponseSuccess =
  mailboxesChannelsPartialUpdateResponse200 & {
    headers: Headers;
  };
export type mailboxesChannelsPartialUpdateResponse =
  mailboxesChannelsPartialUpdateResponseSuccess;

export const getMailboxesChannelsPartialUpdateUrl = (
  mailboxId: string,
  id: string,
) => {
  return `/api/v1.0/mailboxes/${mailboxId}/channels/${id}/`;
};

export const mailboxesChannelsPartialUpdate = async (
  mailboxId: string,
  id: string,
  patchedChannelRequest: PatchedChannelRequest,
  options?: RequestInit,
): Promise<mailboxesChannelsPartialUpdateResponse> => {
  return fetchAPI<mailboxesChannelsPartialUpdateResponse>(
    getMailboxesChannelsPartialUpdateUrl(mailboxId, id),
    {
      ...options,
      method: "PATCH",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(patchedChannelRequest),
    },
  );
};

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

    return mailboxesChannelsPartialUpdate(mailboxId, id, data, requestOptions);
  };

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

export type MailboxesChannelsPartialUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof mailboxesChannelsPartialUpdate>>
>;
export type MailboxesChannelsPartialUpdateMutationBody = PatchedChannelRequest;
export type MailboxesChannelsPartialUpdateMutationError = unknown;

export const useMailboxesChannelsPartialUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof mailboxesChannelsPartialUpdate>>,
      TError,
      { mailboxId: string; id: string; data: PatchedChannelRequest },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof mailboxesChannelsPartialUpdate>>,
  TError,
  { mailboxId: string; id: string; data: PatchedChannelRequest },
  TContext
> => {
  const mutationOptions =
    getMailboxesChannelsPartialUpdateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * Manage integration channels for a mailbox
 */
export type mailboxesChannelsDestroyResponse204 = {
  data: void;
  status: 204;
};

export type mailboxesChannelsDestroyResponse403 = {
  data: void;
  status: 403;
};

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

export type mailboxesChannelsDestroyResponseSuccess =
  mailboxesChannelsDestroyResponse204 & {
    headers: Headers;
  };
export type mailboxesChannelsDestroyResponseError = (
  | mailboxesChannelsDestroyResponse403
  | mailboxesChannelsDestroyResponse404
) & {
  headers: Headers;
};

export type mailboxesChannelsDestroyResponse =
  | mailboxesChannelsDestroyResponseSuccess
  | mailboxesChannelsDestroyResponseError;

export const getMailboxesChannelsDestroyUrl = (
  mailboxId: string,
  id: string,
) => {
  return `/api/v1.0/mailboxes/${mailboxId}/channels/${id}/`;
};

export const mailboxesChannelsDestroy = async (
  mailboxId: string,
  id: string,
  options?: RequestInit,
): Promise<mailboxesChannelsDestroyResponse> => {
  return fetchAPI<mailboxesChannelsDestroyResponse>(
    getMailboxesChannelsDestroyUrl(mailboxId, id),
    {
      ...options,
      method: "DELETE",
    },
  );
};

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

    return mailboxesChannelsDestroy(mailboxId, id, requestOptions);
  };

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

export type MailboxesChannelsDestroyMutationResult = NonNullable<
  Awaited<ReturnType<typeof mailboxesChannelsDestroy>>
>;

export type MailboxesChannelsDestroyMutationError = void;

export const useMailboxesChannelsDestroy = <TError = void, TContext = unknown>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof mailboxesChannelsDestroy>>,
      TError,
      { mailboxId: string; id: string },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof mailboxesChannelsDestroy>>,
  TError,
  { mailboxId: string; id: string },
  TContext
> => {
  const mutationOptions = getMailboxesChannelsDestroyMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
