/**
 * 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 {
  BoardGroupCreate,
  BoardGroupHeartbeatApply,
  BoardGroupHeartbeatApplyResult,
  BoardGroupRead,
  BoardGroupSnapshot,
  BoardGroupUpdate,
  GetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetParams,
  HTTPValidationError,
  LimitOffsetPageTypeVarCustomizedBoardGroupRead,
  ListBoardGroupsApiV1BoardGroupsGetParams,
  OkResponse,
} from ".././model";

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

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

/**
 * List board groups in the active organization.
 * @summary List Board Groups
 */
export type listBoardGroupsApiV1BoardGroupsGetResponse200 = {
  data: LimitOffsetPageTypeVarCustomizedBoardGroupRead;
  status: 200;
};

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

export type listBoardGroupsApiV1BoardGroupsGetResponseSuccess =
  listBoardGroupsApiV1BoardGroupsGetResponse200 & {
    headers: Headers;
  };
export type listBoardGroupsApiV1BoardGroupsGetResponseError =
  listBoardGroupsApiV1BoardGroupsGetResponse422 & {
    headers: Headers;
  };

export type listBoardGroupsApiV1BoardGroupsGetResponse =
  | listBoardGroupsApiV1BoardGroupsGetResponseSuccess
  | listBoardGroupsApiV1BoardGroupsGetResponseError;

export const getListBoardGroupsApiV1BoardGroupsGetUrl = (
  params?: ListBoardGroupsApiV1BoardGroupsGetParams,
) => {
  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/board-groups?${stringifiedParams}`
    : `/api/v1/board-groups`;
};

export const listBoardGroupsApiV1BoardGroupsGet = async (
  params?: ListBoardGroupsApiV1BoardGroupsGetParams,
  options?: RequestInit,
): Promise<listBoardGroupsApiV1BoardGroupsGetResponse> => {
  return customFetch<listBoardGroupsApiV1BoardGroupsGetResponse>(
    getListBoardGroupsApiV1BoardGroupsGetUrl(params),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getListBoardGroupsApiV1BoardGroupsGetQueryKey = (
  params?: ListBoardGroupsApiV1BoardGroupsGetParams,
) => {
  return [`/api/v1/board-groups`, ...(params ? [params] : [])] as const;
};

export const getListBoardGroupsApiV1BoardGroupsGetQueryOptions = <
  TData = Awaited<ReturnType<typeof listBoardGroupsApiV1BoardGroupsGet>>,
  TError = HTTPValidationError,
>(
  params?: ListBoardGroupsApiV1BoardGroupsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listBoardGroupsApiV1BoardGroupsGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

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

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

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

export type ListBoardGroupsApiV1BoardGroupsGetQueryResult = NonNullable<
  Awaited<ReturnType<typeof listBoardGroupsApiV1BoardGroupsGet>>
>;
export type ListBoardGroupsApiV1BoardGroupsGetQueryError = HTTPValidationError;

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

export function useListBoardGroupsApiV1BoardGroupsGet<
  TData = Awaited<ReturnType<typeof listBoardGroupsApiV1BoardGroupsGet>>,
  TError = HTTPValidationError,
>(
  params?: ListBoardGroupsApiV1BoardGroupsGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof listBoardGroupsApiV1BoardGroupsGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getListBoardGroupsApiV1BoardGroupsGetQueryOptions(
    params,
    options,
  );

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

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

/**
 * Create a board group in the active organization.
 * @summary Create Board Group
 */
export type createBoardGroupApiV1BoardGroupsPostResponse200 = {
  data: BoardGroupRead;
  status: 200;
};

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

export type createBoardGroupApiV1BoardGroupsPostResponseSuccess =
  createBoardGroupApiV1BoardGroupsPostResponse200 & {
    headers: Headers;
  };
export type createBoardGroupApiV1BoardGroupsPostResponseError =
  createBoardGroupApiV1BoardGroupsPostResponse422 & {
    headers: Headers;
  };

export type createBoardGroupApiV1BoardGroupsPostResponse =
  | createBoardGroupApiV1BoardGroupsPostResponseSuccess
  | createBoardGroupApiV1BoardGroupsPostResponseError;

export const getCreateBoardGroupApiV1BoardGroupsPostUrl = () => {
  return `/api/v1/board-groups`;
};

export const createBoardGroupApiV1BoardGroupsPost = async (
  boardGroupCreate: BoardGroupCreate,
  options?: RequestInit,
): Promise<createBoardGroupApiV1BoardGroupsPostResponse> => {
  return customFetch<createBoardGroupApiV1BoardGroupsPostResponse>(
    getCreateBoardGroupApiV1BoardGroupsPostUrl(),
    {
      ...options,
      method: "POST",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(boardGroupCreate),
    },
  );
};

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

    return createBoardGroupApiV1BoardGroupsPost(data, requestOptions);
  };

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

export type CreateBoardGroupApiV1BoardGroupsPostMutationResult = NonNullable<
  Awaited<ReturnType<typeof createBoardGroupApiV1BoardGroupsPost>>
>;
export type CreateBoardGroupApiV1BoardGroupsPostMutationBody = BoardGroupCreate;
export type CreateBoardGroupApiV1BoardGroupsPostMutationError =
  HTTPValidationError;

/**
 * @summary Create Board Group
 */
export const useCreateBoardGroupApiV1BoardGroupsPost = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof createBoardGroupApiV1BoardGroupsPost>>,
      TError,
      { data: BoardGroupCreate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof createBoardGroupApiV1BoardGroupsPost>>,
  TError,
  { data: BoardGroupCreate },
  TContext
> => {
  return useMutation(
    getCreateBoardGroupApiV1BoardGroupsPostMutationOptions(options),
    queryClient,
  );
};
/**
 * Delete a board group.
 * @summary Delete Board Group
 */
export type deleteBoardGroupApiV1BoardGroupsGroupIdDeleteResponse200 = {
  data: OkResponse;
  status: 200;
};

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

export type deleteBoardGroupApiV1BoardGroupsGroupIdDeleteResponseSuccess =
  deleteBoardGroupApiV1BoardGroupsGroupIdDeleteResponse200 & {
    headers: Headers;
  };
export type deleteBoardGroupApiV1BoardGroupsGroupIdDeleteResponseError =
  deleteBoardGroupApiV1BoardGroupsGroupIdDeleteResponse422 & {
    headers: Headers;
  };

export type deleteBoardGroupApiV1BoardGroupsGroupIdDeleteResponse =
  | deleteBoardGroupApiV1BoardGroupsGroupIdDeleteResponseSuccess
  | deleteBoardGroupApiV1BoardGroupsGroupIdDeleteResponseError;

export const getDeleteBoardGroupApiV1BoardGroupsGroupIdDeleteUrl = (
  groupId: string,
) => {
  return `/api/v1/board-groups/${groupId}`;
};

export const deleteBoardGroupApiV1BoardGroupsGroupIdDelete = async (
  groupId: string,
  options?: RequestInit,
): Promise<deleteBoardGroupApiV1BoardGroupsGroupIdDeleteResponse> => {
  return customFetch<deleteBoardGroupApiV1BoardGroupsGroupIdDeleteResponse>(
    getDeleteBoardGroupApiV1BoardGroupsGroupIdDeleteUrl(groupId),
    {
      ...options,
      method: "DELETE",
    },
  );
};

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

    return deleteBoardGroupApiV1BoardGroupsGroupIdDelete(
      groupId,
      requestOptions,
    );
  };

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

export type DeleteBoardGroupApiV1BoardGroupsGroupIdDeleteMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof deleteBoardGroupApiV1BoardGroupsGroupIdDelete>>
  >;

export type DeleteBoardGroupApiV1BoardGroupsGroupIdDeleteMutationError =
  HTTPValidationError;

/**
 * @summary Delete Board Group
 */
export const useDeleteBoardGroupApiV1BoardGroupsGroupIdDelete = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof deleteBoardGroupApiV1BoardGroupsGroupIdDelete>>,
      TError,
      { groupId: string },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof deleteBoardGroupApiV1BoardGroupsGroupIdDelete>>,
  TError,
  { groupId: string },
  TContext
> => {
  return useMutation(
    getDeleteBoardGroupApiV1BoardGroupsGroupIdDeleteMutationOptions(options),
    queryClient,
  );
};
/**
 * Get a board group by id.
 * @summary Get Board Group
 */
export type getBoardGroupApiV1BoardGroupsGroupIdGetResponse200 = {
  data: BoardGroupRead;
  status: 200;
};

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

export type getBoardGroupApiV1BoardGroupsGroupIdGetResponseSuccess =
  getBoardGroupApiV1BoardGroupsGroupIdGetResponse200 & {
    headers: Headers;
  };
export type getBoardGroupApiV1BoardGroupsGroupIdGetResponseError =
  getBoardGroupApiV1BoardGroupsGroupIdGetResponse422 & {
    headers: Headers;
  };

export type getBoardGroupApiV1BoardGroupsGroupIdGetResponse =
  | getBoardGroupApiV1BoardGroupsGroupIdGetResponseSuccess
  | getBoardGroupApiV1BoardGroupsGroupIdGetResponseError;

export const getGetBoardGroupApiV1BoardGroupsGroupIdGetUrl = (
  groupId: string,
) => {
  return `/api/v1/board-groups/${groupId}`;
};

export const getBoardGroupApiV1BoardGroupsGroupIdGet = async (
  groupId: string,
  options?: RequestInit,
): Promise<getBoardGroupApiV1BoardGroupsGroupIdGetResponse> => {
  return customFetch<getBoardGroupApiV1BoardGroupsGroupIdGetResponse>(
    getGetBoardGroupApiV1BoardGroupsGroupIdGetUrl(groupId),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getGetBoardGroupApiV1BoardGroupsGroupIdGetQueryKey = (
  groupId: string,
) => {
  return [`/api/v1/board-groups/${groupId}`] as const;
};

export const getGetBoardGroupApiV1BoardGroupsGroupIdGetQueryOptions = <
  TData = Awaited<ReturnType<typeof getBoardGroupApiV1BoardGroupsGroupIdGet>>,
  TError = HTTPValidationError,
>(
  groupId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getBoardGroupApiV1BoardGroupsGroupIdGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
) => {
  const { query: queryOptions, request: requestOptions } = options ?? {};

  const queryKey =
    queryOptions?.queryKey ??
    getGetBoardGroupApiV1BoardGroupsGroupIdGetQueryKey(groupId);

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

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

export type GetBoardGroupApiV1BoardGroupsGroupIdGetQueryResult = NonNullable<
  Awaited<ReturnType<typeof getBoardGroupApiV1BoardGroupsGroupIdGet>>
>;
export type GetBoardGroupApiV1BoardGroupsGroupIdGetQueryError =
  HTTPValidationError;

export function useGetBoardGroupApiV1BoardGroupsGroupIdGet<
  TData = Awaited<ReturnType<typeof getBoardGroupApiV1BoardGroupsGroupIdGet>>,
  TError = HTTPValidationError,
>(
  groupId: string,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getBoardGroupApiV1BoardGroupsGroupIdGet>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof getBoardGroupApiV1BoardGroupsGroupIdGet>>,
          TError,
          Awaited<ReturnType<typeof getBoardGroupApiV1BoardGroupsGroupIdGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetBoardGroupApiV1BoardGroupsGroupIdGet<
  TData = Awaited<ReturnType<typeof getBoardGroupApiV1BoardGroupsGroupIdGet>>,
  TError = HTTPValidationError,
>(
  groupId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getBoardGroupApiV1BoardGroupsGroupIdGet>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof getBoardGroupApiV1BoardGroupsGroupIdGet>>,
          TError,
          Awaited<ReturnType<typeof getBoardGroupApiV1BoardGroupsGroupIdGet>>
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetBoardGroupApiV1BoardGroupsGroupIdGet<
  TData = Awaited<ReturnType<typeof getBoardGroupApiV1BoardGroupsGroupIdGet>>,
  TError = HTTPValidationError,
>(
  groupId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getBoardGroupApiV1BoardGroupsGroupIdGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Get Board Group
 */

export function useGetBoardGroupApiV1BoardGroupsGroupIdGet<
  TData = Awaited<ReturnType<typeof getBoardGroupApiV1BoardGroupsGroupIdGet>>,
  TError = HTTPValidationError,
>(
  groupId: string,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof getBoardGroupApiV1BoardGroupsGroupIdGet>>,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions = getGetBoardGroupApiV1BoardGroupsGroupIdGetQueryOptions(
    groupId,
    options,
  );

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

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

/**
 * Update a board group.
 * @summary Update Board Group
 */
export type updateBoardGroupApiV1BoardGroupsGroupIdPatchResponse200 = {
  data: BoardGroupRead;
  status: 200;
};

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

export type updateBoardGroupApiV1BoardGroupsGroupIdPatchResponseSuccess =
  updateBoardGroupApiV1BoardGroupsGroupIdPatchResponse200 & {
    headers: Headers;
  };
export type updateBoardGroupApiV1BoardGroupsGroupIdPatchResponseError =
  updateBoardGroupApiV1BoardGroupsGroupIdPatchResponse422 & {
    headers: Headers;
  };

export type updateBoardGroupApiV1BoardGroupsGroupIdPatchResponse =
  | updateBoardGroupApiV1BoardGroupsGroupIdPatchResponseSuccess
  | updateBoardGroupApiV1BoardGroupsGroupIdPatchResponseError;

export const getUpdateBoardGroupApiV1BoardGroupsGroupIdPatchUrl = (
  groupId: string,
) => {
  return `/api/v1/board-groups/${groupId}`;
};

export const updateBoardGroupApiV1BoardGroupsGroupIdPatch = async (
  groupId: string,
  boardGroupUpdate: BoardGroupUpdate,
  options?: RequestInit,
): Promise<updateBoardGroupApiV1BoardGroupsGroupIdPatchResponse> => {
  return customFetch<updateBoardGroupApiV1BoardGroupsGroupIdPatchResponse>(
    getUpdateBoardGroupApiV1BoardGroupsGroupIdPatchUrl(groupId),
    {
      ...options,
      method: "PATCH",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(boardGroupUpdate),
    },
  );
};

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

    return updateBoardGroupApiV1BoardGroupsGroupIdPatch(
      groupId,
      data,
      requestOptions,
    );
  };

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

export type UpdateBoardGroupApiV1BoardGroupsGroupIdPatchMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof updateBoardGroupApiV1BoardGroupsGroupIdPatch>>
  >;
export type UpdateBoardGroupApiV1BoardGroupsGroupIdPatchMutationBody =
  BoardGroupUpdate;
export type UpdateBoardGroupApiV1BoardGroupsGroupIdPatchMutationError =
  HTTPValidationError;

/**
 * @summary Update Board Group
 */
export const useUpdateBoardGroupApiV1BoardGroupsGroupIdPatch = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof updateBoardGroupApiV1BoardGroupsGroupIdPatch>>,
      TError,
      { groupId: string; data: BoardGroupUpdate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof updateBoardGroupApiV1BoardGroupsGroupIdPatch>>,
  TError,
  { groupId: string; data: BoardGroupUpdate },
  TContext
> => {
  return useMutation(
    getUpdateBoardGroupApiV1BoardGroupsGroupIdPatchMutationOptions(options),
    queryClient,
  );
};
/**
 * Apply heartbeat settings to agents in a board group.
 * @summary Apply Board Group Heartbeat
 */
export type applyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPostResponse200 =
  {
    data: BoardGroupHeartbeatApplyResult;
    status: 200;
  };

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

export type applyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPostResponseSuccess =
  applyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPostResponse200 & {
    headers: Headers;
  };
export type applyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPostResponseError =
  applyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPostResponse422 & {
    headers: Headers;
  };

export type applyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPostResponse =

    | applyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPostResponseSuccess
    | applyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPostResponseError;

export const getApplyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPostUrl =
  (groupId: string) => {
    return `/api/v1/board-groups/${groupId}/heartbeat`;
  };

export const applyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPost =
  async (
    groupId: string,
    boardGroupHeartbeatApply: BoardGroupHeartbeatApply,
    options?: RequestInit,
  ): Promise<applyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPostResponse> => {
    return customFetch<applyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPostResponse>(
      getApplyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPostUrl(
        groupId,
      ),
      {
        ...options,
        method: "POST",
        headers: { "Content-Type": "application/json", ...options?.headers },
        body: JSON.stringify(boardGroupHeartbeatApply),
      },
    );
  };

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

      return applyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPost(
        groupId,
        data,
        requestOptions,
      );
    };

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

export type ApplyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPostMutationResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof applyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPost
      >
    >
  >;
export type ApplyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPostMutationBody =
  BoardGroupHeartbeatApply;
export type ApplyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPostMutationError =
  HTTPValidationError;

/**
 * @summary Apply Board Group Heartbeat
 */
export const useApplyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPost = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof applyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPost
        >
      >,
      TError,
      { groupId: string; data: BoardGroupHeartbeatApply },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<
    ReturnType<
      typeof applyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPost
    >
  >,
  TError,
  { groupId: string; data: BoardGroupHeartbeatApply },
  TContext
> => {
  return useMutation(
    getApplyBoardGroupHeartbeatApiV1BoardGroupsGroupIdHeartbeatPostMutationOptions(
      options,
    ),
    queryClient,
  );
};
/**
 * Get a snapshot across boards in a group.
 * @summary Get Board Group Snapshot
 */
export type getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetResponse200 =
  {
    data: BoardGroupSnapshot;
    status: 200;
  };

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

export type getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetResponseSuccess =
  getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetResponse200 & {
    headers: Headers;
  };
export type getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetResponseError =
  getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetResponse422 & {
    headers: Headers;
  };

export type getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetResponse =
  | getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetResponseSuccess
  | getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetResponseError;

export const getGetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetUrl = (
  groupId: string,
  params?: GetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetParams,
) => {
  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/board-groups/${groupId}/snapshot?${stringifiedParams}`
    : `/api/v1/board-groups/${groupId}/snapshot`;
};

export const getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet = async (
  groupId: string,
  params?: GetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetParams,
  options?: RequestInit,
): Promise<getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetResponse> => {
  return customFetch<getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetResponse>(
    getGetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetUrl(
      groupId,
      params,
    ),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getGetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetQueryKey =
  (
    groupId: string,
    params?: GetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetParams,
  ) => {
    return [
      `/api/v1/board-groups/${groupId}/snapshot`,
      ...(params ? [params] : []),
    ] as const;
  };

export const getGetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetQueryOptions =
  <
    TData = Awaited<
      ReturnType<typeof getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet>
    >,
    TError = HTTPValidationError,
  >(
    groupId: string,
    params?: GetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetParams,
    options?: {
      query?: Partial<
        UseQueryOptions<
          Awaited<
            ReturnType<
              typeof getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet
            >
          >,
          TError,
          TData
        >
      >;
      request?: SecondParameter<typeof customFetch>;
    },
  ) => {
    const { query: queryOptions, request: requestOptions } = options ?? {};

    const queryKey =
      queryOptions?.queryKey ??
      getGetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetQueryKey(
        groupId,
        params,
      );

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

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

export type GetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetQueryResult =
  NonNullable<
    Awaited<
      ReturnType<typeof getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet>
    >
  >;
export type GetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetQueryError =
  HTTPValidationError;

export function useGetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet<
  TData = Awaited<
    ReturnType<typeof getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet>
  >,
  TError = HTTPValidationError,
>(
  groupId: string,
  params:
    | undefined
    | GetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet
          >
        >,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet<
  TData = Awaited<
    ReturnType<typeof getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet>
  >,
  TError = HTTPValidationError,
>(
  groupId: string,
  params?: GetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet
          >
        >,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<
              typeof getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet
            >
          >,
          TError,
          Awaited<
            ReturnType<
              typeof getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet
            >
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useGetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet<
  TData = Awaited<
    ReturnType<typeof getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet>
  >,
  TError = HTTPValidationError,
>(
  groupId: string,
  params?: GetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet
          >
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Get Board Group Snapshot
 */

export function useGetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet<
  TData = Awaited<
    ReturnType<typeof getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet>
  >,
  TError = HTTPValidationError,
>(
  groupId: string,
  params?: GetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<
            typeof getBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGet
          >
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getGetBoardGroupSnapshotApiV1BoardGroupsGroupIdSnapshotGetQueryOptions(
      groupId,
      params,
      options,
    );

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

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