/**
 * Generated by orval v7.17.0 🍺
 * Do not edit manually.
 * OpenAPI spec version: 0.0.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 {
  ApiConfigurationAdminShopConfigurationListParams,
  PaginatedSiteConfigurationAdminList,
  PatchedSiteConfigurationAdmin,
  SiteConfigurationAdmin,
} from ".././models";

import { privateMutator } from "../../../privateClient";

// https://stackoverflow.com/questions/49579094/typescript-conditional-types-filter-out-readonly-properties-pick-only-requir/49579497#49579497
type IfEquals<X, Y, A = X, B = never> =
  (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;

type WritableKeys<T> = {
  [P in keyof T]-?: IfEquals<
    { [Q in P]: T[P] },
    { -readonly [Q in P]: T[P] },
    P
  >;
}[keyof T];

type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
  k: infer I,
) => void
  ? I
  : never;
type DistributeReadOnlyOverUnions<T> = T extends any ? NonReadonly<T> : never;

type Writable<T> = Pick<T, WritableKeys<T>>;
type NonReadonly<T> = [T] extends [UnionToIntersection<T>]
  ? {
      [P in keyof Writable<T>]: T[P] extends object
        ? NonReadonly<NonNullable<T[P]>>
        : T[P];
    }
  : DistributeReadOnlyOverUnions<T>;

/**
 * @summary List site configuration (admin)
 */
export const apiConfigurationAdminShopConfigurationList = (
  params?: ApiConfigurationAdminShopConfigurationListParams,
  signal?: AbortSignal,
) => {
  return privateMutator<PaginatedSiteConfigurationAdminList>({
    url: `/api/configuration/admin/shop-configuration/`,
    method: "GET",
    params,
    signal,
  });
};

export const getApiConfigurationAdminShopConfigurationListQueryKey = (
  params?: ApiConfigurationAdminShopConfigurationListParams,
) => {
  return [
    `/api/configuration/admin/shop-configuration/`,
    ...(params ? [params] : []),
  ] as const;
};

export const getApiConfigurationAdminShopConfigurationListQueryOptions = <
  TData = Awaited<
    ReturnType<typeof apiConfigurationAdminShopConfigurationList>
  >,
  TError = unknown,
>(
  params?: ApiConfigurationAdminShopConfigurationListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>,
        TError,
        TData
      >
    >;
  },
) => {
  const { query: queryOptions } = options ?? {};

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

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

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

export type ApiConfigurationAdminShopConfigurationListQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>
>;
export type ApiConfigurationAdminShopConfigurationListQueryError = unknown;

export function useApiConfigurationAdminShopConfigurationList<
  TData = Awaited<
    ReturnType<typeof apiConfigurationAdminShopConfigurationList>
  >,
  TError = unknown,
>(
  params: undefined | ApiConfigurationAdminShopConfigurationListParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof apiConfigurationAdminShopConfigurationList>
          >,
          TError,
          Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiConfigurationAdminShopConfigurationList<
  TData = Awaited<
    ReturnType<typeof apiConfigurationAdminShopConfigurationList>
  >,
  TError = unknown,
>(
  params?: ApiConfigurationAdminShopConfigurationListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof apiConfigurationAdminShopConfigurationList>
          >,
          TError,
          Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiConfigurationAdminShopConfigurationList<
  TData = Awaited<
    ReturnType<typeof apiConfigurationAdminShopConfigurationList>
  >,
  TError = unknown,
>(
  params?: ApiConfigurationAdminShopConfigurationListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary List site configuration (admin)
 */

export function useApiConfigurationAdminShopConfigurationList<
  TData = Awaited<
    ReturnType<typeof apiConfigurationAdminShopConfigurationList>
  >,
  TError = unknown,
>(
  params?: ApiConfigurationAdminShopConfigurationListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationList>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getApiConfigurationAdminShopConfigurationListQueryOptions(params, options);

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * @summary Create site configuration (admin)
 */
export const apiConfigurationAdminShopConfigurationCreate = (
  siteConfigurationAdmin: NonReadonly<SiteConfigurationAdmin>,
  signal?: AbortSignal,
) => {
  return privateMutator<SiteConfigurationAdmin>({
    url: `/api/configuration/admin/shop-configuration/`,
    method: "POST",
    headers: { "Content-Type": "application/json" },
    data: siteConfigurationAdmin,
    signal,
  });
};

export const getApiConfigurationAdminShopConfigurationCreateMutationOptions = <
  TError = unknown,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationCreate>>,
    TError,
    { data: NonReadonly<SiteConfigurationAdmin> },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationCreate>>,
  TError,
  { data: NonReadonly<SiteConfigurationAdmin> },
  TContext
> => {
  const mutationKey = ["apiConfigurationAdminShopConfigurationCreate"];
  const { mutation: mutationOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey } };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationCreate>>,
    { data: NonReadonly<SiteConfigurationAdmin> }
  > = (props) => {
    const { data } = props ?? {};

    return apiConfigurationAdminShopConfigurationCreate(data);
  };

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

export type ApiConfigurationAdminShopConfigurationCreateMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationCreate>>
  >;
export type ApiConfigurationAdminShopConfigurationCreateMutationBody =
  NonReadonly<SiteConfigurationAdmin>;
export type ApiConfigurationAdminShopConfigurationCreateMutationError = unknown;

/**
 * @summary Create site configuration (admin)
 */
export const useApiConfigurationAdminShopConfigurationCreate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationCreate>>,
      TError,
      { data: NonReadonly<SiteConfigurationAdmin> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationCreate>>,
  TError,
  { data: NonReadonly<SiteConfigurationAdmin> },
  TContext
> => {
  const mutationOptions =
    getApiConfigurationAdminShopConfigurationCreateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * @summary Retrieve site configuration (admin)
 */
export const apiConfigurationAdminShopConfigurationRetrieve = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<SiteConfigurationAdmin>({
    url: `/api/configuration/admin/shop-configuration/${id}/`,
    method: "GET",
    signal,
  });
};

export const getApiConfigurationAdminShopConfigurationRetrieveQueryKey = (
  id?: number,
) => {
  return [`/api/configuration/admin/shop-configuration/${id}/`] as const;
};

export const getApiConfigurationAdminShopConfigurationRetrieveQueryOptions = <
  TData = Awaited<
    ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
  >,
  TError = unknown,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
        >,
        TError,
        TData
      >
    >;
  },
) => {
  const { query: queryOptions } = options ?? {};

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

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

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

export type ApiConfigurationAdminShopConfigurationRetrieveQueryResult =
  NonNullable<
    Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>>
  >;
export type ApiConfigurationAdminShopConfigurationRetrieveQueryError = unknown;

export function useApiConfigurationAdminShopConfigurationRetrieve<
  TData = Awaited<
    ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
  >,
  TError = unknown,
>(
  id: number,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
        >,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
          >,
          TError,
          Awaited<
            ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
          >
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiConfigurationAdminShopConfigurationRetrieve<
  TData = Awaited<
    ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
  >,
  TError = unknown,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
        >,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
          >,
          TError,
          Awaited<
            ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
          >
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiConfigurationAdminShopConfigurationRetrieve<
  TData = Awaited<
    ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
  >,
  TError = unknown,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
        >,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Retrieve site configuration (admin)
 */

export function useApiConfigurationAdminShopConfigurationRetrieve<
  TData = Awaited<
    ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
  >,
  TError = unknown,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<
          ReturnType<typeof apiConfigurationAdminShopConfigurationRetrieve>
        >,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
} {
  const queryOptions =
    getApiConfigurationAdminShopConfigurationRetrieveQueryOptions(id, options);

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

  query.queryKey = queryOptions.queryKey;

  return query;
}

/**
 * @summary Replace site configuration (admin)
 */
export const apiConfigurationAdminShopConfigurationUpdate = (
  id: number,
  siteConfigurationAdmin: NonReadonly<SiteConfigurationAdmin>,
) => {
  return privateMutator<SiteConfigurationAdmin>({
    url: `/api/configuration/admin/shop-configuration/${id}/`,
    method: "PUT",
    headers: { "Content-Type": "application/json" },
    data: siteConfigurationAdmin,
  });
};

export const getApiConfigurationAdminShopConfigurationUpdateMutationOptions = <
  TError = unknown,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationUpdate>>,
    TError,
    { id: number; data: NonReadonly<SiteConfigurationAdmin> },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationUpdate>>,
  TError,
  { id: number; data: NonReadonly<SiteConfigurationAdmin> },
  TContext
> => {
  const mutationKey = ["apiConfigurationAdminShopConfigurationUpdate"];
  const { mutation: mutationOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey } };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationUpdate>>,
    { id: number; data: NonReadonly<SiteConfigurationAdmin> }
  > = (props) => {
    const { id, data } = props ?? {};

    return apiConfigurationAdminShopConfigurationUpdate(id, data);
  };

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

export type ApiConfigurationAdminShopConfigurationUpdateMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationUpdate>>
  >;
export type ApiConfigurationAdminShopConfigurationUpdateMutationBody =
  NonReadonly<SiteConfigurationAdmin>;
export type ApiConfigurationAdminShopConfigurationUpdateMutationError = unknown;

/**
 * @summary Replace site configuration (admin)
 */
export const useApiConfigurationAdminShopConfigurationUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationUpdate>>,
      TError,
      { id: number; data: NonReadonly<SiteConfigurationAdmin> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationUpdate>>,
  TError,
  { id: number; data: NonReadonly<SiteConfigurationAdmin> },
  TContext
> => {
  const mutationOptions =
    getApiConfigurationAdminShopConfigurationUpdateMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
/**
 * @summary Update site configuration (admin)
 */
export const apiConfigurationAdminShopConfigurationPartialUpdate = (
  id: number,
  patchedSiteConfigurationAdmin: NonReadonly<PatchedSiteConfigurationAdmin>,
) => {
  return privateMutator<SiteConfigurationAdmin>({
    url: `/api/configuration/admin/shop-configuration/${id}/`,
    method: "PATCH",
    headers: { "Content-Type": "application/json" },
    data: patchedSiteConfigurationAdmin,
  });
};

export const getApiConfigurationAdminShopConfigurationPartialUpdateMutationOptions =
  <TError = unknown, TContext = unknown>(options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<typeof apiConfigurationAdminShopConfigurationPartialUpdate>
      >,
      TError,
      { id: number; data: NonReadonly<PatchedSiteConfigurationAdmin> },
      TContext
    >;
  }): UseMutationOptions<
    Awaited<
      ReturnType<typeof apiConfigurationAdminShopConfigurationPartialUpdate>
    >,
    TError,
    { id: number; data: NonReadonly<PatchedSiteConfigurationAdmin> },
    TContext
  > => {
    const mutationKey = ["apiConfigurationAdminShopConfigurationPartialUpdate"];
    const { mutation: mutationOptions } = options
      ? options.mutation &&
        "mutationKey" in options.mutation &&
        options.mutation.mutationKey
        ? options
        : { ...options, mutation: { ...options.mutation, mutationKey } }
      : { mutation: { mutationKey } };

    const mutationFn: MutationFunction<
      Awaited<
        ReturnType<typeof apiConfigurationAdminShopConfigurationPartialUpdate>
      >,
      { id: number; data: NonReadonly<PatchedSiteConfigurationAdmin> }
    > = (props) => {
      const { id, data } = props ?? {};

      return apiConfigurationAdminShopConfigurationPartialUpdate(id, data);
    };

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

export type ApiConfigurationAdminShopConfigurationPartialUpdateMutationResult =
  NonNullable<
    Awaited<
      ReturnType<typeof apiConfigurationAdminShopConfigurationPartialUpdate>
    >
  >;
export type ApiConfigurationAdminShopConfigurationPartialUpdateMutationBody =
  NonReadonly<PatchedSiteConfigurationAdmin>;
export type ApiConfigurationAdminShopConfigurationPartialUpdateMutationError =
  unknown;

/**
 * @summary Update site configuration (admin)
 */
export const useApiConfigurationAdminShopConfigurationPartialUpdate = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<typeof apiConfigurationAdminShopConfigurationPartialUpdate>
      >,
      TError,
      { id: number; data: NonReadonly<PatchedSiteConfigurationAdmin> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<
    ReturnType<typeof apiConfigurationAdminShopConfigurationPartialUpdate>
  >,
  TError,
  { id: number; data: NonReadonly<PatchedSiteConfigurationAdmin> },
  TContext
> => {
  const mutationOptions =
    getApiConfigurationAdminShopConfigurationPartialUpdateMutationOptions(
      options,
    );

  return useMutation(mutationOptions, queryClient);
};
/**
 * @summary Delete site configuration (admin)
 */
export const apiConfigurationAdminShopConfigurationDestroy = (id: number) => {
  return privateMutator<void>({
    url: `/api/configuration/admin/shop-configuration/${id}/`,
    method: "DELETE",
  });
};

export const getApiConfigurationAdminShopConfigurationDestroyMutationOptions = <
  TError = unknown,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationDestroy>>,
    TError,
    { id: number },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationDestroy>>,
  TError,
  { id: number },
  TContext
> => {
  const mutationKey = ["apiConfigurationAdminShopConfigurationDestroy"];
  const { mutation: mutationOptions } = options
    ? options.mutation &&
      "mutationKey" in options.mutation &&
      options.mutation.mutationKey
      ? options
      : { ...options, mutation: { ...options.mutation, mutationKey } }
    : { mutation: { mutationKey } };

  const mutationFn: MutationFunction<
    Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationDestroy>>,
    { id: number }
  > = (props) => {
    const { id } = props ?? {};

    return apiConfigurationAdminShopConfigurationDestroy(id);
  };

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

export type ApiConfigurationAdminShopConfigurationDestroyMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationDestroy>>
  >;

export type ApiConfigurationAdminShopConfigurationDestroyMutationError =
  unknown;

/**
 * @summary Delete site configuration (admin)
 */
export const useApiConfigurationAdminShopConfigurationDestroy = <
  TError = unknown,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationDestroy>>,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiConfigurationAdminShopConfigurationDestroy>>,
  TError,
  { id: number },
  TContext
> => {
  const mutationOptions =
    getApiConfigurationAdminShopConfigurationDestroyMutationOptions(options);

  return useMutation(mutationOptions, queryClient);
};
