/**
 * 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,
  ChannelCreateResponse,
  ChannelRequest,
  PatchedChannelRequest,
  RegeneratedSecretResponse,
  UserChannelCreateRequestRequest,
} from ".././models";

import { fetchAPI } from "../../fetch-api";
import type { ErrorType } 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 = ErrorType<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 = ErrorType<unknown>;

export function useMailboxesChannelsList<
  TData = Awaited<ReturnType<typeof mailboxesChannelsList>>,
  TError = ErrorType<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 = ErrorType<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 = ErrorType<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 = ErrorType<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: ChannelCreateResponse;
  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 = ErrorType<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 = ErrorType<void>;

export const useMailboxesChannelsCreate = <
  TError = ErrorType<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 = ErrorType<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 = ErrorType<unknown>;

export function useMailboxesChannelsRetrieve<
  TData = Awaited<ReturnType<typeof mailboxesChannelsRetrieve>>,
  TError = ErrorType<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 = ErrorType<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 = ErrorType<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 = ErrorType<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 = ErrorType<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 = ErrorType<void>;

export const useMailboxesChannelsUpdate = <
  TError = ErrorType<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 = ErrorType<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 = ErrorType<unknown>;

export const useMailboxesChannelsPartialUpdate = <
  TError = ErrorType<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 = ErrorType<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 = ErrorType<void>;

export const useMailboxesChannelsDestroy = <
  TError = ErrorType<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);
};
/**
 * Manage integration channels for a mailbox
 */
export type mailboxesChannelsRegenerateSecretCreateResponse200 = {
  data: RegeneratedSecretResponse;
  status: 200;
};

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

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

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

export type mailboxesChannelsRegenerateSecretCreateResponseSuccess =
  mailboxesChannelsRegenerateSecretCreateResponse200 & {
    headers: Headers;
  };
export type mailboxesChannelsRegenerateSecretCreateResponseError = (
  | mailboxesChannelsRegenerateSecretCreateResponse400
  | mailboxesChannelsRegenerateSecretCreateResponse403
  | mailboxesChannelsRegenerateSecretCreateResponse404
) & {
  headers: Headers;
};

export type mailboxesChannelsRegenerateSecretCreateResponse =
  | mailboxesChannelsRegenerateSecretCreateResponseSuccess
  | mailboxesChannelsRegenerateSecretCreateResponseError;

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

export const mailboxesChannelsRegenerateSecretCreate = async (
  mailboxId: string,
  id: string,
  options?: RequestInit,
): Promise<mailboxesChannelsRegenerateSecretCreateResponse> => {
  return fetchAPI<mailboxesChannelsRegenerateSecretCreateResponse>(
    getMailboxesChannelsRegenerateSecretCreateUrl(mailboxId, id),
    {
      ...options,
      method: "POST",
    },
  );
};

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

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

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

export type MailboxesChannelsRegenerateSecretCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof mailboxesChannelsRegenerateSecretCreate>>
>;

export type MailboxesChannelsRegenerateSecretCreateMutationError =
  ErrorType<void>;

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

  return useMutation(mutationOptions, queryClient);
};
/**
 * Manage personal (scope_level=user) integration channels
 */
export type usersMeChannelsListResponse200 = {
  data: Channel[];
  status: 200;
};

export type usersMeChannelsListResponseSuccess =
  usersMeChannelsListResponse200 & {
    headers: Headers;
  };
export type usersMeChannelsListResponse = usersMeChannelsListResponseSuccess;

export const getUsersMeChannelsListUrl = () => {
  return `/api/v1.0/users/me/channels/`;
};

export const usersMeChannelsList = async (
  options?: RequestInit,
): Promise<usersMeChannelsListResponse> => {
  return fetchAPI<usersMeChannelsListResponse>(getUsersMeChannelsListUrl(), {
    ...options,
    method: "GET",
  });
};

export const getUsersMeChannelsListQueryKey = () => {
  return [`/api/v1.0/users/me/channels/`] as const;
};

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

  const queryKey = queryOptions?.queryKey ?? getUsersMeChannelsListQueryKey();

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

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

export type UsersMeChannelsListQueryResult = NonNullable<
  Awaited<ReturnType<typeof usersMeChannelsList>>
>;
export type UsersMeChannelsListQueryError = ErrorType<unknown>;

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

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

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * Manage personal (scope_level=user) integration channels
 */
export type usersMeChannelsCreateResponse200 = {
  data: Channel;
  status: 200;
};

export type usersMeChannelsCreateResponse201 = {
  data: ChannelCreateResponse;
  status: 201;
};

export type usersMeChannelsCreateResponseSuccess = (
  | usersMeChannelsCreateResponse200
  | usersMeChannelsCreateResponse201
) & {
  headers: Headers;
};
export type usersMeChannelsCreateResponse =
  usersMeChannelsCreateResponseSuccess;

export const getUsersMeChannelsCreateUrl = () => {
  return `/api/v1.0/users/me/channels/`;
};

export const usersMeChannelsCreate = async (
  userChannelCreateRequestRequest: UserChannelCreateRequestRequest,
  options?: RequestInit,
): Promise<usersMeChannelsCreateResponse> => {
  return fetchAPI<usersMeChannelsCreateResponse>(
    getUsersMeChannelsCreateUrl(),
    {
      ...options,
      method: "POST",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(userChannelCreateRequestRequest),
    },
  );
};

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

    return usersMeChannelsCreate(data, requestOptions);
  };

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

export type UsersMeChannelsCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof usersMeChannelsCreate>>
>;
export type UsersMeChannelsCreateMutationBody = UserChannelCreateRequestRequest;
export type UsersMeChannelsCreateMutationError = ErrorType<unknown>;

export const useUsersMeChannelsCreate = <
  TError = ErrorType<unknown>,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof usersMeChannelsCreate>>,
      TError,
      { data: UserChannelCreateRequestRequest },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof usersMeChannelsCreate>>,
  TError,
  { data: UserChannelCreateRequestRequest },
  TContext
> => {
  const mutationOptions = getUsersMeChannelsCreateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * Manage personal (scope_level=user) integration channels
 */
export type usersMeChannelsRetrieveResponse200 = {
  data: Channel;
  status: 200;
};

export type usersMeChannelsRetrieveResponseSuccess =
  usersMeChannelsRetrieveResponse200 & {
    headers: Headers;
  };
export type usersMeChannelsRetrieveResponse =
  usersMeChannelsRetrieveResponseSuccess;

export const getUsersMeChannelsRetrieveUrl = (id: string) => {
  return `/api/v1.0/users/me/channels/${id}/`;
};

export const usersMeChannelsRetrieve = async (
  id: string,
  options?: RequestInit,
): Promise<usersMeChannelsRetrieveResponse> => {
  return fetchAPI<usersMeChannelsRetrieveResponse>(
    getUsersMeChannelsRetrieveUrl(id),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getUsersMeChannelsRetrieveQueryKey = (id?: string) => {
  return [`/api/v1.0/users/me/channels/${id}/`] as const;
};

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

  const queryKey =
    queryOptions?.queryKey ?? getUsersMeChannelsRetrieveQueryKey(id);

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

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

export type UsersMeChannelsRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof usersMeChannelsRetrieve>>
>;
export type UsersMeChannelsRetrieveQueryError = ErrorType<unknown>;

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

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

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * Manage personal (scope_level=user) integration channels
 */
export type usersMeChannelsUpdateResponse200 = {
  data: Channel;
  status: 200;
};

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

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

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

export type usersMeChannelsUpdateResponseSuccess =
  usersMeChannelsUpdateResponse200 & {
    headers: Headers;
  };
export type usersMeChannelsUpdateResponseError = (
  | usersMeChannelsUpdateResponse400
  | usersMeChannelsUpdateResponse403
  | usersMeChannelsUpdateResponse404
) & {
  headers: Headers;
};

export type usersMeChannelsUpdateResponse =
  | usersMeChannelsUpdateResponseSuccess
  | usersMeChannelsUpdateResponseError;

export const getUsersMeChannelsUpdateUrl = (id: string) => {
  return `/api/v1.0/users/me/channels/${id}/`;
};

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

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

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

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

export type UsersMeChannelsUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof usersMeChannelsUpdate>>
>;
export type UsersMeChannelsUpdateMutationBody = ChannelRequest;
export type UsersMeChannelsUpdateMutationError = ErrorType<void>;

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

  return useMutation(mutationOptions, queryClient);
};
/**
 * Manage personal (scope_level=user) integration channels
 */
export type usersMeChannelsPartialUpdateResponse200 = {
  data: Channel;
  status: 200;
};

export type usersMeChannelsPartialUpdateResponseSuccess =
  usersMeChannelsPartialUpdateResponse200 & {
    headers: Headers;
  };
export type usersMeChannelsPartialUpdateResponse =
  usersMeChannelsPartialUpdateResponseSuccess;

export const getUsersMeChannelsPartialUpdateUrl = (id: string) => {
  return `/api/v1.0/users/me/channels/${id}/`;
};

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

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

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

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

export type UsersMeChannelsPartialUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof usersMeChannelsPartialUpdate>>
>;
export type UsersMeChannelsPartialUpdateMutationBody = PatchedChannelRequest;
export type UsersMeChannelsPartialUpdateMutationError = ErrorType<unknown>;

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

  return useMutation(mutationOptions, queryClient);
};
/**
 * Manage personal (scope_level=user) integration channels
 */
export type usersMeChannelsDestroyResponse204 = {
  data: void;
  status: 204;
};

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

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

export type usersMeChannelsDestroyResponseSuccess =
  usersMeChannelsDestroyResponse204 & {
    headers: Headers;
  };
export type usersMeChannelsDestroyResponseError = (
  | usersMeChannelsDestroyResponse403
  | usersMeChannelsDestroyResponse404
) & {
  headers: Headers;
};

export type usersMeChannelsDestroyResponse =
  | usersMeChannelsDestroyResponseSuccess
  | usersMeChannelsDestroyResponseError;

export const getUsersMeChannelsDestroyUrl = (id: string) => {
  return `/api/v1.0/users/me/channels/${id}/`;
};

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

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

    return usersMeChannelsDestroy(id, requestOptions);
  };

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

export type UsersMeChannelsDestroyMutationResult = NonNullable<
  Awaited<ReturnType<typeof usersMeChannelsDestroy>>
>;

export type UsersMeChannelsDestroyMutationError = ErrorType<void>;

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

  return useMutation(mutationOptions, queryClient);
};
/**
 * Manage personal (scope_level=user) integration channels
 */
export type usersMeChannelsRegenerateSecretCreateResponse200 = {
  data: RegeneratedSecretResponse;
  status: 200;
};

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

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

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

export type usersMeChannelsRegenerateSecretCreateResponseSuccess =
  usersMeChannelsRegenerateSecretCreateResponse200 & {
    headers: Headers;
  };
export type usersMeChannelsRegenerateSecretCreateResponseError = (
  | usersMeChannelsRegenerateSecretCreateResponse400
  | usersMeChannelsRegenerateSecretCreateResponse403
  | usersMeChannelsRegenerateSecretCreateResponse404
) & {
  headers: Headers;
};

export type usersMeChannelsRegenerateSecretCreateResponse =
  | usersMeChannelsRegenerateSecretCreateResponseSuccess
  | usersMeChannelsRegenerateSecretCreateResponseError;

export const getUsersMeChannelsRegenerateSecretCreateUrl = (id: string) => {
  return `/api/v1.0/users/me/channels/${id}/regenerate-secret/`;
};

export const usersMeChannelsRegenerateSecretCreate = async (
  id: string,
  options?: RequestInit,
): Promise<usersMeChannelsRegenerateSecretCreateResponse> => {
  return fetchAPI<usersMeChannelsRegenerateSecretCreateResponse>(
    getUsersMeChannelsRegenerateSecretCreateUrl(id),
    {
      ...options,
      method: "POST",
    },
  );
};

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

    return usersMeChannelsRegenerateSecretCreate(id, requestOptions);
  };

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

export type UsersMeChannelsRegenerateSecretCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof usersMeChannelsRegenerateSecretCreate>>
>;

export type UsersMeChannelsRegenerateSecretCreateMutationError =
  ErrorType<void>;

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

  return useMutation(mutationOptions, queryClient);
};
