/**
 * 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 {
  HTTPValidationError,
  InstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostParams,
  ListMarketplaceSkillsApiV1SkillsMarketplaceGetParams,
  MarketplaceSkillActionResponse,
  MarketplaceSkillCardRead,
  MarketplaceSkillCreate,
  MarketplaceSkillRead,
  OkResponse,
  UninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostParams,
} from ".././model";

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

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

/**
 * List marketplace cards for an org and annotate install state for a gateway.
 * @summary List Marketplace Skills
 */
export type listMarketplaceSkillsApiV1SkillsMarketplaceGetResponse200 = {
  data: MarketplaceSkillCardRead[];
  status: 200;
};

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

export type listMarketplaceSkillsApiV1SkillsMarketplaceGetResponseSuccess =
  listMarketplaceSkillsApiV1SkillsMarketplaceGetResponse200 & {
    headers: Headers;
  };
export type listMarketplaceSkillsApiV1SkillsMarketplaceGetResponseError =
  listMarketplaceSkillsApiV1SkillsMarketplaceGetResponse422 & {
    headers: Headers;
  };

export type listMarketplaceSkillsApiV1SkillsMarketplaceGetResponse =
  | listMarketplaceSkillsApiV1SkillsMarketplaceGetResponseSuccess
  | listMarketplaceSkillsApiV1SkillsMarketplaceGetResponseError;

export const getListMarketplaceSkillsApiV1SkillsMarketplaceGetUrl = (
  params: ListMarketplaceSkillsApiV1SkillsMarketplaceGetParams,
) => {
  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/skills/marketplace?${stringifiedParams}`
    : `/api/v1/skills/marketplace`;
};

export const listMarketplaceSkillsApiV1SkillsMarketplaceGet = async (
  params: ListMarketplaceSkillsApiV1SkillsMarketplaceGetParams,
  options?: RequestInit,
): Promise<listMarketplaceSkillsApiV1SkillsMarketplaceGetResponse> => {
  return customFetch<listMarketplaceSkillsApiV1SkillsMarketplaceGetResponse>(
    getListMarketplaceSkillsApiV1SkillsMarketplaceGetUrl(params),
    {
      ...options,
      method: "GET",
    },
  );
};

export const getListMarketplaceSkillsApiV1SkillsMarketplaceGetQueryKey = (
  params?: ListMarketplaceSkillsApiV1SkillsMarketplaceGetParams,
) => {
  return [`/api/v1/skills/marketplace`, ...(params ? [params] : [])] as const;
};

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

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

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

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

export type ListMarketplaceSkillsApiV1SkillsMarketplaceGetQueryResult =
  NonNullable<
    Awaited<ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>>
  >;
export type ListMarketplaceSkillsApiV1SkillsMarketplaceGetQueryError =
  HTTPValidationError;

export function useListMarketplaceSkillsApiV1SkillsMarketplaceGet<
  TData = Awaited<
    ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
  >,
  TError = HTTPValidationError,
>(
  params: ListMarketplaceSkillsApiV1SkillsMarketplaceGetParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
        >,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useListMarketplaceSkillsApiV1SkillsMarketplaceGet<
  TData = Awaited<
    ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
  >,
  TError = HTTPValidationError,
>(
  params: ListMarketplaceSkillsApiV1SkillsMarketplaceGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
        >,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
          >,
          TError,
          Awaited<
            ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
          >
        >,
        "initialData"
      >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useListMarketplaceSkillsApiV1SkillsMarketplaceGet<
  TData = Awaited<
    ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
  >,
  TError = HTTPValidationError,
>(
  params: ListMarketplaceSkillsApiV1SkillsMarketplaceGetParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof listMarketplaceSkillsApiV1SkillsMarketplaceGet>
        >,
        TError,
        TData
      >
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary List Marketplace Skills
 */

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

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

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

/**
 * Register a skill source URL in the organization's marketplace catalog.
 * @summary Create Marketplace Skill
 */
export type createMarketplaceSkillApiV1SkillsMarketplacePostResponse200 = {
  data: MarketplaceSkillRead;
  status: 200;
};

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

export type createMarketplaceSkillApiV1SkillsMarketplacePostResponseSuccess =
  createMarketplaceSkillApiV1SkillsMarketplacePostResponse200 & {
    headers: Headers;
  };
export type createMarketplaceSkillApiV1SkillsMarketplacePostResponseError =
  createMarketplaceSkillApiV1SkillsMarketplacePostResponse422 & {
    headers: Headers;
  };

export type createMarketplaceSkillApiV1SkillsMarketplacePostResponse =
  | createMarketplaceSkillApiV1SkillsMarketplacePostResponseSuccess
  | createMarketplaceSkillApiV1SkillsMarketplacePostResponseError;

export const getCreateMarketplaceSkillApiV1SkillsMarketplacePostUrl = () => {
  return `/api/v1/skills/marketplace`;
};

export const createMarketplaceSkillApiV1SkillsMarketplacePost = async (
  marketplaceSkillCreate: MarketplaceSkillCreate,
  options?: RequestInit,
): Promise<createMarketplaceSkillApiV1SkillsMarketplacePostResponse> => {
  return customFetch<createMarketplaceSkillApiV1SkillsMarketplacePostResponse>(
    getCreateMarketplaceSkillApiV1SkillsMarketplacePostUrl(),
    {
      ...options,
      method: "POST",
      headers: { "Content-Type": "application/json", ...options?.headers },
      body: JSON.stringify(marketplaceSkillCreate),
    },
  );
};

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

      return createMarketplaceSkillApiV1SkillsMarketplacePost(
        data,
        requestOptions,
      );
    };

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

export type CreateMarketplaceSkillApiV1SkillsMarketplacePostMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof createMarketplaceSkillApiV1SkillsMarketplacePost>>
  >;
export type CreateMarketplaceSkillApiV1SkillsMarketplacePostMutationBody =
  MarketplaceSkillCreate;
export type CreateMarketplaceSkillApiV1SkillsMarketplacePostMutationError =
  HTTPValidationError;

/**
 * @summary Create Marketplace Skill
 */
export const useCreateMarketplaceSkillApiV1SkillsMarketplacePost = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<typeof createMarketplaceSkillApiV1SkillsMarketplacePost>
      >,
      TError,
      { data: MarketplaceSkillCreate },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof createMarketplaceSkillApiV1SkillsMarketplacePost>>,
  TError,
  { data: MarketplaceSkillCreate },
  TContext
> => {
  return useMutation(
    getCreateMarketplaceSkillApiV1SkillsMarketplacePostMutationOptions(options),
    queryClient,
  );
};
/**
 * Delete a marketplace catalog entry and any install records that reference it.
 * @summary Delete Marketplace Skill
 */
export type deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponse200 =
  {
    data: OkResponse;
    status: 200;
  };

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

export type deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponseSuccess =
  deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponse200 & {
    headers: Headers;
  };
export type deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponseError =
  deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponse422 & {
    headers: Headers;
  };

export type deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponse =
  | deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponseSuccess
  | deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponseError;

export const getDeleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteUrl = (
  skillId: string,
) => {
  return `/api/v1/skills/marketplace/${skillId}`;
};

export const deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDelete = async (
  skillId: string,
  options?: RequestInit,
): Promise<deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponse> => {
  return customFetch<deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteResponse>(
    getDeleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteUrl(skillId),
    {
      ...options,
      method: "DELETE",
    },
  );
};

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

      return deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDelete(
        skillId,
        requestOptions,
      );
    };

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

export type DeleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteMutationResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDelete
      >
    >
  >;

export type DeleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteMutationError =
  HTTPValidationError;

/**
 * @summary Delete Marketplace Skill
 */
export const useDeleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDelete = <
  TError = HTTPValidationError,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<
          typeof deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDelete
        >
      >,
      TError,
      { skillId: string },
      TContext
    >;
    request?: SecondParameter<typeof customFetch>;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<
    ReturnType<typeof deleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDelete>
  >,
  TError,
  { skillId: string },
  TContext
> => {
  return useMutation(
    getDeleteMarketplaceSkillApiV1SkillsMarketplaceSkillIdDeleteMutationOptions(
      options,
    ),
    queryClient,
  );
};
/**
 * Install a marketplace skill by dispatching instructions to the gateway agent.
 * @summary Install Marketplace Skill
 */
export type installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponse200 =
  {
    data: MarketplaceSkillActionResponse;
    status: 200;
  };

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

export type installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponseSuccess =
  installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponse200 & {
    headers: Headers;
  };
export type installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponseError =
  installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponse422 & {
    headers: Headers;
  };

export type installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponse =

    | installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponseSuccess
    | installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponseError;

export const getInstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostUrl =
  (
    skillId: string,
    params: InstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostParams,
  ) => {
    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/skills/marketplace/${skillId}/install?${stringifiedParams}`
      : `/api/v1/skills/marketplace/${skillId}/install`;
  };

export const installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPost =
  async (
    skillId: string,
    params: InstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostParams,
    options?: RequestInit,
  ): Promise<installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponse> => {
    return customFetch<installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostResponse>(
      getInstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostUrl(
        skillId,
        params,
      ),
      {
        ...options,
        method: "POST",
      },
    );
  };

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

      return installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPost(
        skillId,
        params,
        requestOptions,
      );
    };

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

export type InstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostMutationResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPost
      >
    >
  >;

export type InstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostMutationError =
  HTTPValidationError;

/**
 * @summary Install Marketplace Skill
 */
export const useInstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPost =
  <TError = HTTPValidationError, TContext = unknown>(
    options?: {
      mutation?: UseMutationOptions<
        Awaited<
          ReturnType<
            typeof installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPost
          >
        >,
        TError,
        {
          skillId: string;
          params: InstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostParams;
        },
        TContext
      >;
      request?: SecondParameter<typeof customFetch>;
    },
    queryClient?: QueryClient,
  ): UseMutationResult<
    Awaited<
      ReturnType<
        typeof installMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPost
      >
    >,
    TError,
    {
      skillId: string;
      params: InstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostParams;
    },
    TContext
  > => {
    return useMutation(
      getInstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdInstallPostMutationOptions(
        options,
      ),
      queryClient,
    );
  };
/**
 * Uninstall a marketplace skill by dispatching instructions to the gateway agent.
 * @summary Uninstall Marketplace Skill
 */
export type uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponse200 =
  {
    data: MarketplaceSkillActionResponse;
    status: 200;
  };

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

export type uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponseSuccess =
  uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponse200 & {
    headers: Headers;
  };
export type uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponseError =
  uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponse422 & {
    headers: Headers;
  };

export type uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponse =

    | uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponseSuccess
    | uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponseError;

export const getUninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostUrl =
  (
    skillId: string,
    params: UninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostParams,
  ) => {
    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/skills/marketplace/${skillId}/uninstall?${stringifiedParams}`
      : `/api/v1/skills/marketplace/${skillId}/uninstall`;
  };

export const uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPost =
  async (
    skillId: string,
    params: UninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostParams,
    options?: RequestInit,
  ): Promise<uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponse> => {
    return customFetch<uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostResponse>(
      getUninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostUrl(
        skillId,
        params,
      ),
      {
        ...options,
        method: "POST",
      },
    );
  };

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

      return uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPost(
        skillId,
        params,
        requestOptions,
      );
    };

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

export type UninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostMutationResult =
  NonNullable<
    Awaited<
      ReturnType<
        typeof uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPost
      >
    >
  >;

export type UninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostMutationError =
  HTTPValidationError;

/**
 * @summary Uninstall Marketplace Skill
 */
export const useUninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPost =
  <TError = HTTPValidationError, TContext = unknown>(
    options?: {
      mutation?: UseMutationOptions<
        Awaited<
          ReturnType<
            typeof uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPost
          >
        >,
        TError,
        {
          skillId: string;
          params: UninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostParams;
        },
        TContext
      >;
      request?: SecondParameter<typeof customFetch>;
    },
    queryClient?: QueryClient,
  ): UseMutationResult<
    Awaited<
      ReturnType<
        typeof uninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPost
      >
    >,
    TError,
    {
      skillId: string;
      params: UninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostParams;
    },
    TContext
  > => {
    return useMutation(
      getUninstallMarketplaceSkillApiV1SkillsMarketplaceSkillIdUninstallPostMutationOptions(
        options,
      ),
      queryClient,
    );
  };
