/**
 * 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 {
  DNSCheckResponse,
  MailDomainAdmin,
  MailDomainAdminWrite,
  MailDomainAdminWriteRequest,
  MailboxAdmin,
  MailboxAdminCreate,
  MailboxAdminCreatePayloadRequest,
  MaildomainsListParams,
  MaildomainsMailboxesListParams,
  MaildomainsMessageTemplatesListParams,
  MaildomainsMessageTemplatesRetrieveParams,
  MessageTemplate,
  MessageTemplateRequest,
  PaginatedMailDomainAdminList,
  PaginatedMailboxAdminList,
  PatchedMailboxAdminPartialUpdatePayloadRequest,
  PatchedMessageTemplateRequest,
  ReadMessageTemplate,
  ResetPasswordError,
  ResetPasswordInternalServerError,
  ResetPasswordNotFound,
  ResetPasswordResponse,
} from ".././models";

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

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

/**
 * ViewSet for listing MailDomains the user administers.
Provides a top-level entry for mail domain administration.
Endpoint: /maildomains/<maildomain_pk>/
 */
export type maildomainsListResponse200 = {
  data: PaginatedMailDomainAdminList;
  status: 200;
};

export type maildomainsListResponseSuccess = maildomainsListResponse200 & {
  headers: Headers;
};
export type maildomainsListResponse = maildomainsListResponseSuccess;

export const getMaildomainsListUrl = (params?: MaildomainsListParams) => {
  const normalizedParams = new URLSearchParams();

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

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/api/v1.0/maildomains/?${stringifiedParams}`
    : `/api/v1.0/maildomains/`;
};

export const maildomainsList = async (
  params?: MaildomainsListParams,
  options?: RequestInit,
): Promise<maildomainsListResponse> => {
  return fetchAPI<maildomainsListResponse>(getMaildomainsListUrl(params), {
    ...options,
    method: "GET",
  });
};

export const getMaildomainsListQueryKey = (params?: MaildomainsListParams) => {
  return [`/api/v1.0/maildomains/`, ...(params ? [params] : [])] as const;
};

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

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

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

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

export type MaildomainsListQueryResult = NonNullable<
  Awaited<ReturnType<typeof maildomainsList>>
>;
export type MaildomainsListQueryError = unknown;

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

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

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * ViewSet for listing MailDomains the user administers.
Provides a top-level entry for mail domain administration.
Endpoint: /maildomains/<maildomain_pk>/
 */
export type maildomainsCreateResponse201 = {
  data: MailDomainAdminWrite;
  status: 201;
};

export type maildomainsCreateResponseSuccess = maildomainsCreateResponse201 & {
  headers: Headers;
};
export type maildomainsCreateResponse = maildomainsCreateResponseSuccess;

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

export const maildomainsCreate = async (
  mailDomainAdminWriteRequest: MailDomainAdminWriteRequest,
  options?: RequestInit,
): Promise<maildomainsCreateResponse> => {
  return fetchAPI<maildomainsCreateResponse>(getMaildomainsCreateUrl(), {
    ...options,
    method: "POST",
    headers: { "Content-Type": "application/json", ...options?.headers },
    body: JSON.stringify(mailDomainAdminWriteRequest),
  });
};

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

    return maildomainsCreate(data, requestOptions);
  };

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

export type MaildomainsCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof maildomainsCreate>>
>;
export type MaildomainsCreateMutationBody = MailDomainAdminWriteRequest;
export type MaildomainsCreateMutationError = unknown;

export const useMaildomainsCreate = <TError = unknown, TContext = unknown>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof maildomainsCreate>>,
      TError,
      { data: MailDomainAdminWriteRequest },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof maildomainsCreate>>,
  TError,
  { data: MailDomainAdminWriteRequest },
  TContext
> => {
  const mutationOptions = getMaildomainsCreateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * ViewSet for listing MailDomains the user administers.
Provides a top-level entry for mail domain administration.
Endpoint: /maildomains/<maildomain_pk>/
 */
export type maildomainsRetrieveResponse200 = {
  data: MailDomainAdmin;
  status: 200;
};

export type maildomainsRetrieveResponseSuccess =
  maildomainsRetrieveResponse200 & {
    headers: Headers;
  };
export type maildomainsRetrieveResponse = maildomainsRetrieveResponseSuccess;

export const getMaildomainsRetrieveUrl = (maildomainPk: string) => {
  return `/api/v1.0/maildomains/${maildomainPk}/`;
};

export const maildomainsRetrieve = async (
  maildomainPk: string,
  options?: RequestInit,
): Promise<maildomainsRetrieveResponse> => {
  return fetchAPI<maildomainsRetrieveResponse>(
    getMaildomainsRetrieveUrl(maildomainPk),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getMaildomainsRetrieveQueryKey = (maildomainPk?: string) => {
  return [`/api/v1.0/maildomains/${maildomainPk}/`] as const;
};

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

  const queryKey =
    queryOptions?.queryKey ?? getMaildomainsRetrieveQueryKey(maildomainPk);

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

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

export type MaildomainsRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof maildomainsRetrieve>>
>;
export type MaildomainsRetrieveQueryError = unknown;

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

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

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * Check DNS records for a specific mail domain.
 */
export type maildomainsCheckDnsCreateResponse200 = {
  data: DNSCheckResponse;
  status: 200;
};

export type maildomainsCheckDnsCreateResponseSuccess =
  maildomainsCheckDnsCreateResponse200 & {
    headers: Headers;
  };
export type maildomainsCheckDnsCreateResponse =
  maildomainsCheckDnsCreateResponseSuccess;

export const getMaildomainsCheckDnsCreateUrl = (maildomainPk: string) => {
  return `/api/v1.0/maildomains/${maildomainPk}/check-dns/`;
};

export const maildomainsCheckDnsCreate = async (
  maildomainPk: string,
  options?: RequestInit,
): Promise<maildomainsCheckDnsCreateResponse> => {
  return fetchAPI<maildomainsCheckDnsCreateResponse>(
    getMaildomainsCheckDnsCreateUrl(maildomainPk),
    {
      ...options,
      method: "POST",
    },
  );
};

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

    return maildomainsCheckDnsCreate(maildomainPk, requestOptions);
  };

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

export type MaildomainsCheckDnsCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof maildomainsCheckDnsCreate>>
>;

export type MaildomainsCheckDnsCreateMutationError = unknown;

export const useMaildomainsCheckDnsCreate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof maildomainsCheckDnsCreate>>,
      TError,
      { maildomainPk: string },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof maildomainsCheckDnsCreate>>,
  TError,
  { maildomainPk: string },
  TContext
> => {
  const mutationOptions = getMaildomainsCheckDnsCreateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * ViewSet for managing Mailboxes within a specific MailDomain.
Nested under /maildomains/{maildomain_pk}/mailboxes/
Permissions are checked by IsMailDomainAdmin for the maildomain_pk.

This viewset serves a different purpose than the one in mailbox.py (/api/v1.0/mailboxes/).
That other one is for listing the mailboxes a user has access to in regular app use.
This one is for managing mailboxes within a specific maildomain in the admin interface.
 */
export type maildomainsMailboxesListResponse200 = {
  data: PaginatedMailboxAdminList;
  status: 200;
};

export type maildomainsMailboxesListResponseSuccess =
  maildomainsMailboxesListResponse200 & {
    headers: Headers;
  };
export type maildomainsMailboxesListResponse =
  maildomainsMailboxesListResponseSuccess;

export const getMaildomainsMailboxesListUrl = (
  maildomainPk: string,
  params?: MaildomainsMailboxesListParams,
) => {
  const normalizedParams = new URLSearchParams();

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

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/api/v1.0/maildomains/${maildomainPk}/mailboxes/?${stringifiedParams}`
    : `/api/v1.0/maildomains/${maildomainPk}/mailboxes/`;
};

export const maildomainsMailboxesList = async (
  maildomainPk: string,
  params?: MaildomainsMailboxesListParams,
  options?: RequestInit,
): Promise<maildomainsMailboxesListResponse> => {
  return fetchAPI<maildomainsMailboxesListResponse>(
    getMaildomainsMailboxesListUrl(maildomainPk, params),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getMaildomainsMailboxesListQueryKey = (
  maildomainPk?: string,
  params?: MaildomainsMailboxesListParams,
) => {
  return [
    `/api/v1.0/maildomains/${maildomainPk}/mailboxes/`,
    ...(params ? [params] : []),
  ] as const;
};

export const getMaildomainsMailboxesListQueryOptions = <
  TData = Awaited<ReturnType<typeof maildomainsMailboxesList>>,
  TError = unknown,
>(
  maildomainPk: string,
  params?: MaildomainsMailboxesListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof maildomainsMailboxesList>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getMaildomainsMailboxesListQueryKey(maildomainPk, params);

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

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

export type MaildomainsMailboxesListQueryResult = NonNullable<
  Awaited<ReturnType<typeof maildomainsMailboxesList>>
>;
export type MaildomainsMailboxesListQueryError = unknown;

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

export function useMaildomainsMailboxesList<
  TData = Awaited<ReturnType<typeof maildomainsMailboxesList>>,
  TError = unknown,
>(
  maildomainPk: string,
  params?: MaildomainsMailboxesListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof maildomainsMailboxesList>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getMaildomainsMailboxesListQueryOptions(
    maildomainPk,
    params,
    options,
  );

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * Create new mailbox in a specific maildomain.
 */
export type maildomainsMailboxesCreateResponse201 = {
  data: MailboxAdminCreate;
  status: 201;
};

export type maildomainsMailboxesCreateResponseSuccess =
  maildomainsMailboxesCreateResponse201 & {
    headers: Headers;
  };
export type maildomainsMailboxesCreateResponse =
  maildomainsMailboxesCreateResponseSuccess;

export const getMaildomainsMailboxesCreateUrl = (maildomainPk: string) => {
  return `/api/v1.0/maildomains/${maildomainPk}/mailboxes/`;
};

export const maildomainsMailboxesCreate = async (
  maildomainPk: string,
  mailboxAdminCreatePayloadRequest: MailboxAdminCreatePayloadRequest,
  options?: RequestInit,
): Promise<maildomainsMailboxesCreateResponse> => {
  return fetchAPI<maildomainsMailboxesCreateResponse>(
    getMaildomainsMailboxesCreateUrl(maildomainPk),
    {
      ...options,
      method: "POST",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(mailboxAdminCreatePayloadRequest),
    },
  );
};

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

    return maildomainsMailboxesCreate(maildomainPk, data, requestOptions);
  };

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

export type MaildomainsMailboxesCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof maildomainsMailboxesCreate>>
>;
export type MaildomainsMailboxesCreateMutationBody =
  MailboxAdminCreatePayloadRequest;
export type MaildomainsMailboxesCreateMutationError = unknown;

export const useMaildomainsMailboxesCreate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof maildomainsMailboxesCreate>>,
      TError,
      { maildomainPk: string; data: MailboxAdminCreatePayloadRequest },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof maildomainsMailboxesCreate>>,
  TError,
  { maildomainPk: string; data: MailboxAdminCreatePayloadRequest },
  TContext
> => {
  const mutationOptions = getMaildomainsMailboxesCreateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * ViewSet for managing Mailboxes within a specific MailDomain.
Nested under /maildomains/{maildomain_pk}/mailboxes/
Permissions are checked by IsMailDomainAdmin for the maildomain_pk.

This viewset serves a different purpose than the one in mailbox.py (/api/v1.0/mailboxes/).
That other one is for listing the mailboxes a user has access to in regular app use.
This one is for managing mailboxes within a specific maildomain in the admin interface.
 */
export type maildomainsMailboxesRetrieveResponse200 = {
  data: MailboxAdmin;
  status: 200;
};

export type maildomainsMailboxesRetrieveResponseSuccess =
  maildomainsMailboxesRetrieveResponse200 & {
    headers: Headers;
  };
export type maildomainsMailboxesRetrieveResponse =
  maildomainsMailboxesRetrieveResponseSuccess;

export const getMaildomainsMailboxesRetrieveUrl = (
  maildomainPk: string,
  id: string,
) => {
  return `/api/v1.0/maildomains/${maildomainPk}/mailboxes/${id}/`;
};

export const maildomainsMailboxesRetrieve = async (
  maildomainPk: string,
  id: string,
  options?: RequestInit,
): Promise<maildomainsMailboxesRetrieveResponse> => {
  return fetchAPI<maildomainsMailboxesRetrieveResponse>(
    getMaildomainsMailboxesRetrieveUrl(maildomainPk, id),
    {
      ...options,
      method: "GET",
    },
  );
};

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

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

  const queryKey =
    queryOptions?.queryKey ??
    getMaildomainsMailboxesRetrieveQueryKey(maildomainPk, id);

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

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

export type MaildomainsMailboxesRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof maildomainsMailboxesRetrieve>>
>;
export type MaildomainsMailboxesRetrieveQueryError = unknown;

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

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

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * Partially update a mailbox in a specific maildomain.
 */
export type maildomainsMailboxesPartialUpdateResponse200 = {
  data: MailboxAdmin;
  status: 200;
};

export type maildomainsMailboxesPartialUpdateResponseSuccess =
  maildomainsMailboxesPartialUpdateResponse200 & {
    headers: Headers;
  };
export type maildomainsMailboxesPartialUpdateResponse =
  maildomainsMailboxesPartialUpdateResponseSuccess;

export const getMaildomainsMailboxesPartialUpdateUrl = (
  maildomainPk: string,
  id: string,
) => {
  return `/api/v1.0/maildomains/${maildomainPk}/mailboxes/${id}/`;
};

export const maildomainsMailboxesPartialUpdate = async (
  maildomainPk: string,
  id: string,
  patchedMailboxAdminPartialUpdatePayloadRequest: PatchedMailboxAdminPartialUpdatePayloadRequest,
  options?: RequestInit,
): Promise<maildomainsMailboxesPartialUpdateResponse> => {
  return fetchAPI<maildomainsMailboxesPartialUpdateResponse>(
    getMaildomainsMailboxesPartialUpdateUrl(maildomainPk, id),
    {
      ...options,
      method: "PATCH",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(patchedMailboxAdminPartialUpdatePayloadRequest),
    },
  );
};

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

    return maildomainsMailboxesPartialUpdate(
      maildomainPk,
      id,
      data,
      requestOptions,
    );
  };

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

export type MaildomainsMailboxesPartialUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof maildomainsMailboxesPartialUpdate>>
>;
export type MaildomainsMailboxesPartialUpdateMutationBody =
  PatchedMailboxAdminPartialUpdatePayloadRequest;
export type MaildomainsMailboxesPartialUpdateMutationError = unknown;

export const useMaildomainsMailboxesPartialUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof maildomainsMailboxesPartialUpdate>>,
      TError,
      {
        maildomainPk: string;
        id: string;
        data: PatchedMailboxAdminPartialUpdatePayloadRequest;
      },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof maildomainsMailboxesPartialUpdate>>,
  TError,
  {
    maildomainPk: string;
    id: string;
    data: PatchedMailboxAdminPartialUpdatePayloadRequest;
  },
  TContext
> => {
  const mutationOptions =
    getMaildomainsMailboxesPartialUpdateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * ViewSet for managing Mailboxes within a specific MailDomain.
Nested under /maildomains/{maildomain_pk}/mailboxes/
Permissions are checked by IsMailDomainAdmin for the maildomain_pk.

This viewset serves a different purpose than the one in mailbox.py (/api/v1.0/mailboxes/).
That other one is for listing the mailboxes a user has access to in regular app use.
This one is for managing mailboxes within a specific maildomain in the admin interface.
 */
export type maildomainsMailboxesDestroyResponse204 = {
  data: void;
  status: 204;
};

export type maildomainsMailboxesDestroyResponseSuccess =
  maildomainsMailboxesDestroyResponse204 & {
    headers: Headers;
  };
export type maildomainsMailboxesDestroyResponse =
  maildomainsMailboxesDestroyResponseSuccess;

export const getMaildomainsMailboxesDestroyUrl = (
  maildomainPk: string,
  id: string,
) => {
  return `/api/v1.0/maildomains/${maildomainPk}/mailboxes/${id}/`;
};

export const maildomainsMailboxesDestroy = async (
  maildomainPk: string,
  id: string,
  options?: RequestInit,
): Promise<maildomainsMailboxesDestroyResponse> => {
  return fetchAPI<maildomainsMailboxesDestroyResponse>(
    getMaildomainsMailboxesDestroyUrl(maildomainPk, id),
    {
      ...options,
      method: "DELETE",
    },
  );
};

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

    return maildomainsMailboxesDestroy(maildomainPk, id, requestOptions);
  };

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

export type MaildomainsMailboxesDestroyMutationResult = NonNullable<
  Awaited<ReturnType<typeof maildomainsMailboxesDestroy>>
>;

export type MaildomainsMailboxesDestroyMutationError = unknown;

export const useMaildomainsMailboxesDestroy = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof maildomainsMailboxesDestroy>>,
      TError,
      { maildomainPk: string; id: string },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof maildomainsMailboxesDestroy>>,
  TError,
  { maildomainPk: string; id: string },
  TContext
> => {
  const mutationOptions =
    getMaildomainsMailboxesDestroyMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * Reset the Keycloak password for a specific mailbox.
 */
export type maildomainsMailboxesResetPasswordResponse200 = {
  data: ResetPasswordResponse;
  status: 200;
};

export type maildomainsMailboxesResetPasswordResponse400 = {
  data: ResetPasswordError;
  status: 400;
};

export type maildomainsMailboxesResetPasswordResponse404 = {
  data: ResetPasswordNotFound;
  status: 404;
};

export type maildomainsMailboxesResetPasswordResponse500 = {
  data: ResetPasswordInternalServerError;
  status: 500;
};

export type maildomainsMailboxesResetPasswordResponseSuccess =
  maildomainsMailboxesResetPasswordResponse200 & {
    headers: Headers;
  };
export type maildomainsMailboxesResetPasswordResponseError = (
  | maildomainsMailboxesResetPasswordResponse400
  | maildomainsMailboxesResetPasswordResponse404
  | maildomainsMailboxesResetPasswordResponse500
) & {
  headers: Headers;
};

export type maildomainsMailboxesResetPasswordResponse =
  | maildomainsMailboxesResetPasswordResponseSuccess
  | maildomainsMailboxesResetPasswordResponseError;

export const getMaildomainsMailboxesResetPasswordUrl = (
  maildomainPk: string,
  id: string,
) => {
  return `/api/v1.0/maildomains/${maildomainPk}/mailboxes/${id}/reset-password/`;
};

export const maildomainsMailboxesResetPassword = async (
  maildomainPk: string,
  id: string,
  options?: RequestInit,
): Promise<maildomainsMailboxesResetPasswordResponse> => {
  return fetchAPI<maildomainsMailboxesResetPasswordResponse>(
    getMaildomainsMailboxesResetPasswordUrl(maildomainPk, id),
    {
      ...options,
      method: "PATCH",
    },
  );
};

export const getMaildomainsMailboxesResetPasswordMutationOptions = <
  TError =
    | ResetPasswordError
    | ResetPasswordNotFound
    | ResetPasswordInternalServerError,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof maildomainsMailboxesResetPassword>>,
    TError,
    { maildomainPk: string; id: string },
    TContext
  >;
  request?: SecondParameter<typeof fetchAPI>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof maildomainsMailboxesResetPassword>>,
  TError,
  { maildomainPk: string; id: string },
  TContext
> => {
  const mutationKey = ["maildomainsMailboxesResetPassword"];
  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 maildomainsMailboxesResetPassword>>,
    { maildomainPk: string; id: string }
  > = (props) => {
    const { maildomainPk, id } = props ?? {};

    return maildomainsMailboxesResetPassword(maildomainPk, id, requestOptions);
  };

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

export type MaildomainsMailboxesResetPasswordMutationResult = NonNullable<
  Awaited<ReturnType<typeof maildomainsMailboxesResetPassword>>
>;

export type MaildomainsMailboxesResetPasswordMutationError =
  | ResetPasswordError
  | ResetPasswordNotFound
  | ResetPasswordInternalServerError;

export const useMaildomainsMailboxesResetPassword = <
  TError =
    | ResetPasswordError
    | ResetPasswordNotFound
    | ResetPasswordInternalServerError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof maildomainsMailboxesResetPassword>>,
      TError,
      { maildomainPk: string; id: string },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof maildomainsMailboxesResetPassword>>,
  TError,
  { maildomainPk: string; id: string },
  TContext
> => {
  const mutationOptions =
    getMaildomainsMailboxesResetPasswordMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * List message templates for a maildomain.
 */
export type maildomainsMessageTemplatesListResponse200 = {
  data: ReadMessageTemplate[];
  status: 200;
};

export type maildomainsMessageTemplatesListResponseSuccess =
  maildomainsMessageTemplatesListResponse200 & {
    headers: Headers;
  };
export type maildomainsMessageTemplatesListResponse =
  maildomainsMessageTemplatesListResponseSuccess;

export const getMaildomainsMessageTemplatesListUrl = (
  maildomainPk: string,
  params?: MaildomainsMessageTemplatesListParams,
) => {
  const normalizedParams = new URLSearchParams();

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

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/api/v1.0/maildomains/${maildomainPk}/message-templates/?${stringifiedParams}`
    : `/api/v1.0/maildomains/${maildomainPk}/message-templates/`;
};

export const maildomainsMessageTemplatesList = async (
  maildomainPk: string,
  params?: MaildomainsMessageTemplatesListParams,
  options?: RequestInit,
): Promise<maildomainsMessageTemplatesListResponse> => {
  return fetchAPI<maildomainsMessageTemplatesListResponse>(
    getMaildomainsMessageTemplatesListUrl(maildomainPk, params),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getMaildomainsMessageTemplatesListQueryKey = (
  maildomainPk?: string,
  params?: MaildomainsMessageTemplatesListParams,
) => {
  return [
    `/api/v1.0/maildomains/${maildomainPk}/message-templates/`,
    ...(params ? [params] : []),
  ] as const;
};

export const getMaildomainsMessageTemplatesListQueryOptions = <
  TData = Awaited<ReturnType<typeof maildomainsMessageTemplatesList>>,
  TError = unknown,
>(
  maildomainPk: string,
  params?: MaildomainsMessageTemplatesListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof maildomainsMessageTemplatesList>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getMaildomainsMessageTemplatesListQueryKey(maildomainPk, params);

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

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

export type MaildomainsMessageTemplatesListQueryResult = NonNullable<
  Awaited<ReturnType<typeof maildomainsMessageTemplatesList>>
>;
export type MaildomainsMessageTemplatesListQueryError = unknown;

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

export function useMaildomainsMessageTemplatesList<
  TData = Awaited<ReturnType<typeof maildomainsMessageTemplatesList>>,
  TError = unknown,
>(
  maildomainPk: string,
  params?: MaildomainsMessageTemplatesListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof maildomainsMessageTemplatesList>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getMaildomainsMessageTemplatesListQueryOptions(
    maildomainPk,
    params,
    options,
  );

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * Create a template and return a read-serialized response.
 */
export type maildomainsMessageTemplatesCreateResponse201 = {
  data: MessageTemplate;
  status: 201;
};

export type maildomainsMessageTemplatesCreateResponseSuccess =
  maildomainsMessageTemplatesCreateResponse201 & {
    headers: Headers;
  };
export type maildomainsMessageTemplatesCreateResponse =
  maildomainsMessageTemplatesCreateResponseSuccess;

export const getMaildomainsMessageTemplatesCreateUrl = (
  maildomainPk: string,
) => {
  return `/api/v1.0/maildomains/${maildomainPk}/message-templates/`;
};

export const maildomainsMessageTemplatesCreate = async (
  maildomainPk: string,
  messageTemplateRequest: MessageTemplateRequest,
  options?: RequestInit,
): Promise<maildomainsMessageTemplatesCreateResponse> => {
  return fetchAPI<maildomainsMessageTemplatesCreateResponse>(
    getMaildomainsMessageTemplatesCreateUrl(maildomainPk),
    {
      ...options,
      method: "POST",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(messageTemplateRequest),
    },
  );
};

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

    return maildomainsMessageTemplatesCreate(
      maildomainPk,
      data,
      requestOptions,
    );
  };

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

export type MaildomainsMessageTemplatesCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof maildomainsMessageTemplatesCreate>>
>;
export type MaildomainsMessageTemplatesCreateMutationBody =
  MessageTemplateRequest;
export type MaildomainsMessageTemplatesCreateMutationError = unknown;

export const useMaildomainsMessageTemplatesCreate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof maildomainsMessageTemplatesCreate>>,
      TError,
      { maildomainPk: string; data: MessageTemplateRequest },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof maildomainsMessageTemplatesCreate>>,
  TError,
  { maildomainPk: string; data: MessageTemplateRequest },
  TContext
> => {
  const mutationOptions =
    getMaildomainsMessageTemplatesCreateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * Retrieve a message template.
 */
export type maildomainsMessageTemplatesRetrieveResponse200 = {
  data: ReadMessageTemplate;
  status: 200;
};

export type maildomainsMessageTemplatesRetrieveResponseSuccess =
  maildomainsMessageTemplatesRetrieveResponse200 & {
    headers: Headers;
  };
export type maildomainsMessageTemplatesRetrieveResponse =
  maildomainsMessageTemplatesRetrieveResponseSuccess;

export const getMaildomainsMessageTemplatesRetrieveUrl = (
  maildomainPk: string,
  id: string,
  params?: MaildomainsMessageTemplatesRetrieveParams,
) => {
  const normalizedParams = new URLSearchParams();

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

  const stringifiedParams = normalizedParams.toString();

  return stringifiedParams.length > 0
    ? `/api/v1.0/maildomains/${maildomainPk}/message-templates/${id}/?${stringifiedParams}`
    : `/api/v1.0/maildomains/${maildomainPk}/message-templates/${id}/`;
};

export const maildomainsMessageTemplatesRetrieve = async (
  maildomainPk: string,
  id: string,
  params?: MaildomainsMessageTemplatesRetrieveParams,
  options?: RequestInit,
): Promise<maildomainsMessageTemplatesRetrieveResponse> => {
  return fetchAPI<maildomainsMessageTemplatesRetrieveResponse>(
    getMaildomainsMessageTemplatesRetrieveUrl(maildomainPk, id, params),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getMaildomainsMessageTemplatesRetrieveQueryKey = (
  maildomainPk?: string,
  id?: string,
  params?: MaildomainsMessageTemplatesRetrieveParams,
) => {
  return [
    `/api/v1.0/maildomains/${maildomainPk}/message-templates/${id}/`,
    ...(params ? [params] : []),
  ] as const;
};

export const getMaildomainsMessageTemplatesRetrieveQueryOptions = <
  TData = Awaited<ReturnType<typeof maildomainsMessageTemplatesRetrieve>>,
  TError = unknown,
>(
  maildomainPk: string,
  id: string,
  params?: MaildomainsMessageTemplatesRetrieveParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof maildomainsMessageTemplatesRetrieve>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getMaildomainsMessageTemplatesRetrieveQueryKey(maildomainPk, id, params);

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

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

export type MaildomainsMessageTemplatesRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof maildomainsMessageTemplatesRetrieve>>
>;
export type MaildomainsMessageTemplatesRetrieveQueryError = unknown;

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

export function useMaildomainsMessageTemplatesRetrieve<
  TData = Awaited<ReturnType<typeof maildomainsMessageTemplatesRetrieve>>,
  TError = unknown,
>(
  maildomainPk: string,
  id: string,
  params?: MaildomainsMessageTemplatesRetrieveParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof maildomainsMessageTemplatesRetrieve>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getMaildomainsMessageTemplatesRetrieveQueryOptions(
    maildomainPk,
    id,
    params,
    options,
  );

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * Update a template and return a read-serialized response.
 */
export type maildomainsMessageTemplatesUpdateResponse200 = {
  data: MessageTemplate;
  status: 200;
};

export type maildomainsMessageTemplatesUpdateResponseSuccess =
  maildomainsMessageTemplatesUpdateResponse200 & {
    headers: Headers;
  };
export type maildomainsMessageTemplatesUpdateResponse =
  maildomainsMessageTemplatesUpdateResponseSuccess;

export const getMaildomainsMessageTemplatesUpdateUrl = (
  maildomainPk: string,
  id: string,
) => {
  return `/api/v1.0/maildomains/${maildomainPk}/message-templates/${id}/`;
};

export const maildomainsMessageTemplatesUpdate = async (
  maildomainPk: string,
  id: string,
  messageTemplateRequest: MessageTemplateRequest,
  options?: RequestInit,
): Promise<maildomainsMessageTemplatesUpdateResponse> => {
  return fetchAPI<maildomainsMessageTemplatesUpdateResponse>(
    getMaildomainsMessageTemplatesUpdateUrl(maildomainPk, id),
    {
      ...options,
      method: "PUT",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(messageTemplateRequest),
    },
  );
};

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

    return maildomainsMessageTemplatesUpdate(
      maildomainPk,
      id,
      data,
      requestOptions,
    );
  };

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

export type MaildomainsMessageTemplatesUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof maildomainsMessageTemplatesUpdate>>
>;
export type MaildomainsMessageTemplatesUpdateMutationBody =
  MessageTemplateRequest;
export type MaildomainsMessageTemplatesUpdateMutationError = unknown;

export const useMaildomainsMessageTemplatesUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof maildomainsMessageTemplatesUpdate>>,
      TError,
      { maildomainPk: string; id: string; data: MessageTemplateRequest },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof maildomainsMessageTemplatesUpdate>>,
  TError,
  { maildomainPk: string; id: string; data: MessageTemplateRequest },
  TContext
> => {
  const mutationOptions =
    getMaildomainsMessageTemplatesUpdateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * ViewSet for managing message templates for a maildomain.
 */
export type maildomainsMessageTemplatesPartialUpdateResponse200 = {
  data: MessageTemplate;
  status: 200;
};

export type maildomainsMessageTemplatesPartialUpdateResponseSuccess =
  maildomainsMessageTemplatesPartialUpdateResponse200 & {
    headers: Headers;
  };
export type maildomainsMessageTemplatesPartialUpdateResponse =
  maildomainsMessageTemplatesPartialUpdateResponseSuccess;

export const getMaildomainsMessageTemplatesPartialUpdateUrl = (
  maildomainPk: string,
  id: string,
) => {
  return `/api/v1.0/maildomains/${maildomainPk}/message-templates/${id}/`;
};

export const maildomainsMessageTemplatesPartialUpdate = async (
  maildomainPk: string,
  id: string,
  patchedMessageTemplateRequest: PatchedMessageTemplateRequest,
  options?: RequestInit,
): Promise<maildomainsMessageTemplatesPartialUpdateResponse> => {
  return fetchAPI<maildomainsMessageTemplatesPartialUpdateResponse>(
    getMaildomainsMessageTemplatesPartialUpdateUrl(maildomainPk, id),
    {
      ...options,
      method: "PATCH",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(patchedMessageTemplateRequest),
    },
  );
};

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

    return maildomainsMessageTemplatesPartialUpdate(
      maildomainPk,
      id,
      data,
      requestOptions,
    );
  };

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

export type MaildomainsMessageTemplatesPartialUpdateMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof maildomainsMessageTemplatesPartialUpdate>>
  >;
export type MaildomainsMessageTemplatesPartialUpdateMutationBody =
  PatchedMessageTemplateRequest;
export type MaildomainsMessageTemplatesPartialUpdateMutationError = unknown;

export const useMaildomainsMessageTemplatesPartialUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof maildomainsMessageTemplatesPartialUpdate>>,
      TError,
      { maildomainPk: string; id: string; data: PatchedMessageTemplateRequest },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof maildomainsMessageTemplatesPartialUpdate>>,
  TError,
  { maildomainPk: string; id: string; data: PatchedMessageTemplateRequest },
  TContext
> => {
  const mutationOptions =
    getMaildomainsMessageTemplatesPartialUpdateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * ViewSet for managing message templates for a maildomain.
 */
export type maildomainsMessageTemplatesDestroyResponse204 = {
  data: void;
  status: 204;
};

export type maildomainsMessageTemplatesDestroyResponseSuccess =
  maildomainsMessageTemplatesDestroyResponse204 & {
    headers: Headers;
  };
export type maildomainsMessageTemplatesDestroyResponse =
  maildomainsMessageTemplatesDestroyResponseSuccess;

export const getMaildomainsMessageTemplatesDestroyUrl = (
  maildomainPk: string,
  id: string,
) => {
  return `/api/v1.0/maildomains/${maildomainPk}/message-templates/${id}/`;
};

export const maildomainsMessageTemplatesDestroy = async (
  maildomainPk: string,
  id: string,
  options?: RequestInit,
): Promise<maildomainsMessageTemplatesDestroyResponse> => {
  return fetchAPI<maildomainsMessageTemplatesDestroyResponse>(
    getMaildomainsMessageTemplatesDestroyUrl(maildomainPk, id),
    {
      ...options,
      method: "DELETE",
    },
  );
};

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

    return maildomainsMessageTemplatesDestroy(maildomainPk, id, requestOptions);
  };

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

export type MaildomainsMessageTemplatesDestroyMutationResult = NonNullable<
  Awaited<ReturnType<typeof maildomainsMessageTemplatesDestroy>>
>;

export type MaildomainsMessageTemplatesDestroyMutationError = unknown;

export const useMaildomainsMessageTemplatesDestroy = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof maildomainsMessageTemplatesDestroy>>,
      TError,
      { maildomainPk: string; id: string },
      TContext
    >;
    request?: SecondParameter<typeof fetchAPI>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof maildomainsMessageTemplatesDestroy>>,
  TError,
  { maildomainPk: string; id: string },
  TContext
> => {
  const mutationOptions =
    getMaildomainsMessageTemplatesDestroyMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
