/**
 * Generated by orval v8.3.0 🍺
 * Do not edit manually.
 * Mission Control API
 * OpenAPI spec version: 0.1.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 {
  ApprovalCreate,
  ApprovalRead,
  ApprovalUpdate,
  HTTPValidationError,
  LimitOffsetPageTypeVarCustomizedApprovalRead,
  ListApprovalsApiV1BoardsBoardIdApprovalsGetParams,
  StreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetParams,
} from ".././model";

import { customFetch } from "../../mutator";

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

/**
 * List approvals for a board, optionally filtering by status.
 * @summary List Approvals
 */
export type listApprovalsApiV1BoardsBoardIdApprovalsGetResponse200 = {
  data: LimitOffsetPageTypeVarCustomizedApprovalRead;
  status: 200;
};

export type listApprovalsApiV1BoardsBoardIdApprovalsGetResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type listApprovalsApiV1BoardsBoardIdApprovalsGetResponseSuccess =
  listApprovalsApiV1BoardsBoardIdApprovalsGetResponse200 & {
    headers: Headers;
  };
export type listApprovalsApiV1BoardsBoardIdApprovalsGetResponseError =
  listApprovalsApiV1BoardsBoardIdApprovalsGetResponse422 & {
    headers: Headers;
  };

export type listApprovalsApiV1BoardsBoardIdApprovalsGetResponse =
  | listApprovalsApiV1BoardsBoardIdApprovalsGetResponseSuccess
  | listApprovalsApiV1BoardsBoardIdApprovalsGetResponseError;

export const getListApprovalsApiV1BoardsBoardIdApprovalsGetUrl = (
  boardId: string,
  params?: ListApprovalsApiV1BoardsBoardIdApprovalsGetParams,
) => {
  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/boards/${boardId}/approvals?${stringifiedParams}`
    : `/api/v1/boards/${boardId}/approvals`;
};

export const listApprovalsApiV1BoardsBoardIdApprovalsGet = async (
  boardId: string,
  params?: ListApprovalsApiV1BoardsBoardIdApprovalsGetParams,
  options?: RequestInit,
): Promise<listApprovalsApiV1BoardsBoardIdApprovalsGetResponse> => {
  return customFetch<listApprovalsApiV1BoardsBoardIdApprovalsGetResponse>(
    getListApprovalsApiV1BoardsBoardIdApprovalsGetUrl(boardId, params),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getListApprovalsApiV1BoardsBoardIdApprovalsGetQueryKey = (
  boardId: string,
  params?: ListApprovalsApiV1BoardsBoardIdApprovalsGetParams,
) => {
  return [
    `/api/v1/boards/${boardId}/approvals`,
    ...(params ? [params] : []),
  ] as const;
};

export const getListApprovalsApiV1BoardsBoardIdApprovalsGetQueryOptions = <
  TData = Awaited<
    ReturnType<typeof listApprovalsApiV1BoardsBoardIdApprovalsGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  params?: ListApprovalsApiV1BoardsBoardIdApprovalsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listApprovalsApiV1BoardsBoardIdApprovalsGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getListApprovalsApiV1BoardsBoardIdApprovalsGetQueryKey(boardId, params);

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

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

export type ListApprovalsApiV1BoardsBoardIdApprovalsGetQueryResult =
  NonNullable<
    Awaited<ReturnType<typeof listApprovalsApiV1BoardsBoardIdApprovalsGet>>
  >;
export type ListApprovalsApiV1BoardsBoardIdApprovalsGetQueryError =
  HTTPValidationError;

export function useListApprovalsApiV1BoardsBoardIdApprovalsGet<
  TData = Awaited<
    ReturnType<typeof listApprovalsApiV1BoardsBoardIdApprovalsGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  params: undefined | ListApprovalsApiV1BoardsBoardIdApprovalsGetParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listApprovalsApiV1BoardsBoardIdApprovalsGet>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof listApprovalsApiV1BoardsBoardIdApprovalsGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof listApprovalsApiV1BoardsBoardIdApprovalsGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useListApprovalsApiV1BoardsBoardIdApprovalsGet<
  TData = Awaited<
    ReturnType<typeof listApprovalsApiV1BoardsBoardIdApprovalsGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  params?: ListApprovalsApiV1BoardsBoardIdApprovalsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listApprovalsApiV1BoardsBoardIdApprovalsGet>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof listApprovalsApiV1BoardsBoardIdApprovalsGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof listApprovalsApiV1BoardsBoardIdApprovalsGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useListApprovalsApiV1BoardsBoardIdApprovalsGet<
  TData = Awaited<
    ReturnType<typeof listApprovalsApiV1BoardsBoardIdApprovalsGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  params?: ListApprovalsApiV1BoardsBoardIdApprovalsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listApprovalsApiV1BoardsBoardIdApprovalsGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary List Approvals
 */

export function useListApprovalsApiV1BoardsBoardIdApprovalsGet<
  TData = Awaited<
    ReturnType<typeof listApprovalsApiV1BoardsBoardIdApprovalsGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  params?: ListApprovalsApiV1BoardsBoardIdApprovalsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listApprovalsApiV1BoardsBoardIdApprovalsGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getListApprovalsApiV1BoardsBoardIdApprovalsGetQueryOptions(
      boardId,
      params,
      options,
    );

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

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Create an approval for a board.
 * @summary Create Approval
 */
export type createApprovalApiV1BoardsBoardIdApprovalsPostResponse200 = {
  data: ApprovalRead;
  status: 200;
};

export type createApprovalApiV1BoardsBoardIdApprovalsPostResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type createApprovalApiV1BoardsBoardIdApprovalsPostResponseSuccess =
  createApprovalApiV1BoardsBoardIdApprovalsPostResponse200 & {
    headers: Headers;
  };
export type createApprovalApiV1BoardsBoardIdApprovalsPostResponseError =
  createApprovalApiV1BoardsBoardIdApprovalsPostResponse422 & {
    headers: Headers;
  };

export type createApprovalApiV1BoardsBoardIdApprovalsPostResponse =
  | createApprovalApiV1BoardsBoardIdApprovalsPostResponseSuccess
  | createApprovalApiV1BoardsBoardIdApprovalsPostResponseError;

export const getCreateApprovalApiV1BoardsBoardIdApprovalsPostUrl = (
  boardId: string,
) => {
  return `/api/v1/boards/${boardId}/approvals`;
};

export const createApprovalApiV1BoardsBoardIdApprovalsPost = async (
  boardId: string,
  approvalCreate: ApprovalCreate,
  options?: RequestInit,
): Promise<createApprovalApiV1BoardsBoardIdApprovalsPostResponse> => {
  return customFetch<createApprovalApiV1BoardsBoardIdApprovalsPostResponse>(
    getCreateApprovalApiV1BoardsBoardIdApprovalsPostUrl(boardId),
    {
      ...options,
      method: "POST",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(approvalCreate),
    },
  );
};

export const getCreateApprovalApiV1BoardsBoardIdApprovalsPostMutationOptions = <
  TError = HTTPValidationError,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof createApprovalApiV1BoardsBoardIdApprovalsPost>>,
    TError,
    { boardId: string; data: ApprovalCreate },
    TContext
  >;
  request?: SecondParameter<typeof customFetch>;
}): UseMutationOptions<
  Awaited<ReturnType<typeof createApprovalApiV1BoardsBoardIdApprovalsPost>>,
  TError,
  { boardId: string; data: ApprovalCreate },
  TContext
> => {
  const mutationKey = ["createApprovalApiV1BoardsBoardIdApprovalsPost"];
  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 createApprovalApiV1BoardsBoardIdApprovalsPost>>,
    { boardId: string; data: ApprovalCreate }
  > = (props) => {
    const { boardId, data } = props ?? {};

    return createApprovalApiV1BoardsBoardIdApprovalsPost(
      boardId,
      data,
      requestOptions,
    );
  };

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

export type CreateApprovalApiV1BoardsBoardIdApprovalsPostMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof createApprovalApiV1BoardsBoardIdApprovalsPost>>
  >;
export type CreateApprovalApiV1BoardsBoardIdApprovalsPostMutationBody =
  ApprovalCreate;
export type CreateApprovalApiV1BoardsBoardIdApprovalsPostMutationError =
  HTTPValidationError;

/**
 * @summary Create Approval
 */
export const useCreateApprovalApiV1BoardsBoardIdApprovalsPost = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof createApprovalApiV1BoardsBoardIdApprovalsPost>>,
      TError,
      { boardId: string; data: ApprovalCreate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof createApprovalApiV1BoardsBoardIdApprovalsPost>>,
  TError,
  { boardId: string; data: ApprovalCreate },
  TContext
> => {
  return useMutation(
    getCreateApprovalApiV1BoardsBoardIdApprovalsPostMutationOptions(options),
    queryClient,
  );
};
/**
 * Stream approval updates for a board using server-sent events.
 * @summary Stream Approvals
 */
export type streamApprovalsApiV1BoardsBoardIdApprovalsStreamGetResponse200 = {
  data: unknown;
  status: 200;
};

export type streamApprovalsApiV1BoardsBoardIdApprovalsStreamGetResponse422 = {
  data: HTTPValidationError;
  status: 422;
};

export type streamApprovalsApiV1BoardsBoardIdApprovalsStreamGetResponseSuccess =
  streamApprovalsApiV1BoardsBoardIdApprovalsStreamGetResponse200 & {
    headers: Headers;
  };
export type streamApprovalsApiV1BoardsBoardIdApprovalsStreamGetResponseError =
  streamApprovalsApiV1BoardsBoardIdApprovalsStreamGetResponse422 & {
    headers: Headers;
  };

export type streamApprovalsApiV1BoardsBoardIdApprovalsStreamGetResponse =
  | streamApprovalsApiV1BoardsBoardIdApprovalsStreamGetResponseSuccess
  | streamApprovalsApiV1BoardsBoardIdApprovalsStreamGetResponseError;

export const getStreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetUrl = (
  boardId: string,
  params?: StreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetParams,
) => {
  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/boards/${boardId}/approvals/stream?${stringifiedParams}`
    : `/api/v1/boards/${boardId}/approvals/stream`;
};

export const streamApprovalsApiV1BoardsBoardIdApprovalsStreamGet = async (
  boardId: string,
  params?: StreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetParams,
  options?: RequestInit,
): Promise<streamApprovalsApiV1BoardsBoardIdApprovalsStreamGetResponse> => {
  return customFetch<streamApprovalsApiV1BoardsBoardIdApprovalsStreamGetResponse>(
    getStreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetUrl(boardId, params),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getStreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetQueryKey = (
  boardId: string,
  params?: StreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetParams,
) => {
  return [
    `/api/v1/boards/${boardId}/approvals/stream`,
    ...(params ? [params] : []),
  ] as const;
};

export const getStreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetQueryOptions =
  <
    TData = Awaited<
      ReturnType<typeof streamApprovalsApiV1BoardsBoardIdApprovalsStreamGet>
    >,
    TError = HTTPValidationError,
  >(
    boardId: string,
    params?: StreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetParams,
    options?: {
      query?: Partial<
        UseQueryOptions<
          Awaited<
            ReturnType<
              typeof streamApprovalsApiV1BoardsBoardIdApprovalsStreamGet
            >
          >,
          TError,
          TData
        >
      >;
      request?: SecondParameter<typeof customFetch>;
    },
  ) => {
    const { query: queryOptions, request: requestOptions } = options ?? {};

    const queryKey =
      queryOptions?.queryKey ??
      getStreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetQueryKey(
        boardId,
        params,
      );

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

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

export type StreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetQueryResult =
  NonNullable<
    Awaited<
      ReturnType<typeof streamApprovalsApiV1BoardsBoardIdApprovalsStreamGet>
    >
  >;
export type StreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetQueryError =
  HTTPValidationError;

export function useStreamApprovalsApiV1BoardsBoardIdApprovalsStreamGet<
  TData = Awaited<
    ReturnType<typeof streamApprovalsApiV1BoardsBoardIdApprovalsStreamGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  params: undefined | StreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof streamApprovalsApiV1BoardsBoardIdApprovalsStreamGet>
        >,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof streamApprovalsApiV1BoardsBoardIdApprovalsStreamGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof streamApprovalsApiV1BoardsBoardIdApprovalsStreamGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useStreamApprovalsApiV1BoardsBoardIdApprovalsStreamGet<
  TData = Awaited<
    ReturnType<typeof streamApprovalsApiV1BoardsBoardIdApprovalsStreamGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  params?: StreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof streamApprovalsApiV1BoardsBoardIdApprovalsStreamGet>
        >,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof streamApprovalsApiV1BoardsBoardIdApprovalsStreamGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof streamApprovalsApiV1BoardsBoardIdApprovalsStreamGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useStreamApprovalsApiV1BoardsBoardIdApprovalsStreamGet<
  TData = Awaited<
    ReturnType<typeof streamApprovalsApiV1BoardsBoardIdApprovalsStreamGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  params?: StreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof streamApprovalsApiV1BoardsBoardIdApprovalsStreamGet>
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Stream Approvals
 */

export function useStreamApprovalsApiV1BoardsBoardIdApprovalsStreamGet<
  TData = Awaited<
    ReturnType<typeof streamApprovalsApiV1BoardsBoardIdApprovalsStreamGet>
  >,
  TError = HTTPValidationError,
>(
  boardId: string,
  params?: StreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof streamApprovalsApiV1BoardsBoardIdApprovalsStreamGet>
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getStreamApprovalsApiV1BoardsBoardIdApprovalsStreamGetQueryOptions(
      boardId,
      params,
      options,
    );

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

  return { ...query, queryKey: queryOptions.queryKey };
}

/**
 * Update an approval's status and resolution timestamp.
 * @summary Update Approval
 */
export type updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchResponse200 =
  {
    data: ApprovalRead;
    status: 200;
  };

export type updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchResponse422 =
  {
    data: HTTPValidationError;
    status: 422;
  };

export type updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchResponseSuccess =
  updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchResponse200 & {
    headers: Headers;
  };
export type updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchResponseError =
  updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchResponse422 & {
    headers: Headers;
  };

export type updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchResponse =
  | updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchResponseSuccess
  | updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchResponseError;

export const getUpdateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchUrl = (
  boardId: string,
  approvalId: string,
) => {
  return `/api/v1/boards/${boardId}/approvals/${approvalId}`;
};

export const updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatch = async (
  boardId: string,
  approvalId: string,
  approvalUpdate: ApprovalUpdate,
  options?: RequestInit,
): Promise<updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchResponse> => {
  return customFetch<updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchResponse>(
    getUpdateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchUrl(
      boardId,
      approvalId,
    ),
    {
      ...options,
      method: "PATCH",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(approvalUpdate),
    },
  );
};

export const getUpdateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchMutationOptions =
  <TError = HTTPValidationError, TContext = unknown>(options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatch
        >
      >,
      TError,
      { boardId: string; approvalId: string; data: ApprovalUpdate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  }): UseMutationOptions<
    Awaited<
      ReturnType<
        typeof updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatch
      >
    >,
    TError,
    { boardId: string; approvalId: string; data: ApprovalUpdate },
    TContext
  > => {
    const mutationKey = [
      "updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatch",
    ];
    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 updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatch
        >
      >,
      { boardId: string; approvalId: string; data: ApprovalUpdate }
    > = (props) => {
      const { boardId, approvalId, data } = props ?? {};

      return updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatch(
        boardId,
        approvalId,
        data,
        requestOptions,
      );
    };

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

export type UpdateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchMutationResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatch
      >
    >
  >;
export type UpdateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchMutationBody =
  ApprovalUpdate;
export type UpdateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchMutationError =
  HTTPValidationError;

/**
 * @summary Update Approval
 */
export const useUpdateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatch = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatch
        >
      >,
      TError,
      { boardId: string; approvalId: string; data: ApprovalUpdate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<
    ReturnType<typeof updateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatch>
  >,
  TError,
  { boardId: string; approvalId: string; data: ApprovalUpdate },
  TContext
> => {
  return useMutation(
    getUpdateApprovalApiV1BoardsBoardIdApprovalsApprovalIdPatchMutationOptions(
      options,
    ),
    queryClient,
  );
};
