/**
 * Generated by orval v8.8.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 {
  ApiDeutschepostBulkOrdersListParams,
  ApiDeutschepostOrdersListParams,
  DeutschePostBulkOrder,
  DeutschePostOrder,
  DeutschePostTracking,
  PaginatedDeutschePostBulkOrderList,
  PaginatedDeutschePostOrderList,
  PatchedDeutschePostOrder,
} 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>;

/**
 * Returns a paginated list of Deutsche Post bulk shipping orders. Admin only access.
 * @summary List Deutsche Post Bulk Orders
 */
export const apiDeutschepostBulkOrdersList = (
  params?: ApiDeutschepostBulkOrdersListParams,
  signal?: AbortSignal,
) => {
  return privateMutator<PaginatedDeutschePostBulkOrderList>({
    url: `/api/deutschepost/bulk-orders/`,
    method: "GET",
    params,
    signal,
  });
};

export const getApiDeutschepostBulkOrdersListQueryKey = (
  params?: ApiDeutschepostBulkOrdersListParams,
) => {
  return [
    `/api/deutschepost/bulk-orders/`,
    ...(params ? [params] : []),
  ] as const;
};

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

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

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

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

export type ApiDeutschepostBulkOrdersListQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiDeutschepostBulkOrdersList>>
>;
export type ApiDeutschepostBulkOrdersListQueryError = unknown;

export function useApiDeutschepostBulkOrdersList<
  TData = Awaited<ReturnType<typeof apiDeutschepostBulkOrdersList>>,
  TError = unknown,
>(
  params: undefined | ApiDeutschepostBulkOrdersListParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostBulkOrdersList>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiDeutschepostBulkOrdersList>>,
          TError,
          Awaited<ReturnType<typeof apiDeutschepostBulkOrdersList>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiDeutschepostBulkOrdersList<
  TData = Awaited<ReturnType<typeof apiDeutschepostBulkOrdersList>>,
  TError = unknown,
>(
  params?: ApiDeutschepostBulkOrdersListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostBulkOrdersList>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiDeutschepostBulkOrdersList>>,
          TError,
          Awaited<ReturnType<typeof apiDeutschepostBulkOrdersList>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiDeutschepostBulkOrdersList<
  TData = Awaited<ReturnType<typeof apiDeutschepostBulkOrdersList>>,
  TError = unknown,
>(
  params?: ApiDeutschepostBulkOrdersListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostBulkOrdersList>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary List Deutsche Post Bulk Orders
 */

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

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

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

/**
 *
        Create a new Deutsche Post bulk order from multiple individual orders.

        Requirements:
        - All orders must be created remotely (have order_id)
        - All linked commerce orders must use Deutsche Post delivery
        - All linked commerce orders must be completed
        - Orders cannot already be part of another bulk order

 * @summary Create Deutsche Post Bulk Order
 */
export const apiDeutschepostBulkOrdersCreate = (
  deutschePostBulkOrder: NonReadonly<DeutschePostBulkOrder>,
  signal?: AbortSignal,
) => {
  return privateMutator<DeutschePostBulkOrder>({
    url: `/api/deutschepost/bulk-orders/`,
    method: "POST",
    headers: { "Content-Type": "application/json" },
    data: deutschePostBulkOrder,
    signal,
  });
};

export const getApiDeutschepostBulkOrdersCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiDeutschepostBulkOrdersCreate>>,
    TError,
    { data: NonReadonly<DeutschePostBulkOrder> },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiDeutschepostBulkOrdersCreate>>,
  TError,
  { data: NonReadonly<DeutschePostBulkOrder> },
  TContext
> => {
  const mutationKey = ["apiDeutschepostBulkOrdersCreate"];
  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 apiDeutschepostBulkOrdersCreate>>,
    { data: NonReadonly<DeutschePostBulkOrder> }
  > = (props) => {
    const { data } = props ?? {};

    return apiDeutschepostBulkOrdersCreate(data);
  };

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

export type ApiDeutschepostBulkOrdersCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiDeutschepostBulkOrdersCreate>>
>;
export type ApiDeutschepostBulkOrdersCreateMutationBody =
  NonReadonly<DeutschePostBulkOrder>;
export type ApiDeutschepostBulkOrdersCreateMutationError = void;

/**
 * @summary Create Deutsche Post Bulk Order
 */
export const useApiDeutschepostBulkOrdersCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiDeutschepostBulkOrdersCreate>>,
      TError,
      { data: NonReadonly<DeutschePostBulkOrder> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiDeutschepostBulkOrdersCreate>>,
  TError,
  { data: NonReadonly<DeutschePostBulkOrder> },
  TContext
> => {
  return useMutation(
    getApiDeutschepostBulkOrdersCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * Returns detailed information for a single Deutsche Post bulk order including all constituent orders.
 * @summary Get Deutsche Post Bulk Order Detail
 */
export const apiDeutschepostBulkOrdersRetrieve = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<DeutschePostBulkOrder>({
    url: `/api/deutschepost/bulk-orders/${id}/`,
    method: "GET",
    signal,
  });
};

export const getApiDeutschepostBulkOrdersRetrieveQueryKey = (id: number) => {
  return [`/api/deutschepost/bulk-orders/${id}/`] as const;
};

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

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

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

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

export type ApiDeutschepostBulkOrdersRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiDeutschepostBulkOrdersRetrieve>>
>;
export type ApiDeutschepostBulkOrdersRetrieveQueryError = unknown;

export function useApiDeutschepostBulkOrdersRetrieve<
  TData = Awaited<ReturnType<typeof apiDeutschepostBulkOrdersRetrieve>>,
  TError = unknown,
>(
  id: number,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostBulkOrdersRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiDeutschepostBulkOrdersRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiDeutschepostBulkOrdersRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiDeutschepostBulkOrdersRetrieve<
  TData = Awaited<ReturnType<typeof apiDeutschepostBulkOrdersRetrieve>>,
  TError = unknown,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostBulkOrdersRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiDeutschepostBulkOrdersRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiDeutschepostBulkOrdersRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiDeutschepostBulkOrdersRetrieve<
  TData = Awaited<ReturnType<typeof apiDeutschepostBulkOrdersRetrieve>>,
  TError = unknown,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostBulkOrdersRetrieve>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Get Deutsche Post Bulk Order Detail
 */

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

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

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

/**
 *
        Cancel the bulk order in Deutsche Post API system. This will:
        - Call Deutsche Post API to cancel the bulk order
        - Update the bulk order status to ERROR (cancelled state)
        - Cannot be undone once cancelled
        - Only works for bulk orders that are not yet completed

 * @summary Cancel Remote Bulk Order
 */
export const apiDeutschepostBulkOrdersCancelBulkOrderCreate = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<DeutschePostBulkOrder>({
    url: `/api/deutschepost/bulk-orders/${id}/cancel_bulk_order/`,
    method: "POST",
    signal,
  });
};

export const getApiDeutschepostBulkOrdersCancelBulkOrderCreateMutationOptions =
  <TError = void, TContext = unknown>(options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<typeof apiDeutschepostBulkOrdersCancelBulkOrderCreate>
      >,
      TError,
      { id: number },
      TContext
    >;
  }): UseMutationOptions<
    Awaited<ReturnType<typeof apiDeutschepostBulkOrdersCancelBulkOrderCreate>>,
    TError,
    { id: number },
    TContext
  > => {
    const mutationKey = ["apiDeutschepostBulkOrdersCancelBulkOrderCreate"];
    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 apiDeutschepostBulkOrdersCancelBulkOrderCreate>
      >,
      { id: number }
    > = (props) => {
      const { id } = props ?? {};

      return apiDeutschepostBulkOrdersCancelBulkOrderCreate(id);
    };

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

export type ApiDeutschepostBulkOrdersCancelBulkOrderCreateMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof apiDeutschepostBulkOrdersCancelBulkOrderCreate>>
  >;

export type ApiDeutschepostBulkOrdersCancelBulkOrderCreateMutationError = void;

/**
 * @summary Cancel Remote Bulk Order
 */
export const useApiDeutschepostBulkOrdersCancelBulkOrderCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<
        ReturnType<typeof apiDeutschepostBulkOrdersCancelBulkOrderCreate>
      >,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiDeutschepostBulkOrdersCancelBulkOrderCreate>>,
  TError,
  { id: number },
  TContext
> => {
  return useMutation(
    getApiDeutschepostBulkOrdersCancelBulkOrderCreateMutationOptions(options),
    queryClient,
  );
};
/**
 *
        Create the bulk order in Deutsche Post API system. This will:
        - Validate all constituent orders are eligible
        - Call Deutsche Post API to create the bulk order
        - Store the returned bulk_order_id
        - Update the bulk order status to PROCESSING
        - Handle API errors and validation

 * @summary Create Remote Bulk Order
 */
export const apiDeutschepostBulkOrdersCreateRemoteCreate = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<DeutschePostBulkOrder>({
    url: `/api/deutschepost/bulk-orders/${id}/create_remote/`,
    method: "POST",
    signal,
  });
};

export const getApiDeutschepostBulkOrdersCreateRemoteCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiDeutschepostBulkOrdersCreateRemoteCreate>>,
    TError,
    { id: number },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiDeutschepostBulkOrdersCreateRemoteCreate>>,
  TError,
  { id: number },
  TContext
> => {
  const mutationKey = ["apiDeutschepostBulkOrdersCreateRemoteCreate"];
  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 apiDeutschepostBulkOrdersCreateRemoteCreate>>,
    { id: number }
  > = (props) => {
    const { id } = props ?? {};

    return apiDeutschepostBulkOrdersCreateRemoteCreate(id);
  };

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

export type ApiDeutschepostBulkOrdersCreateRemoteCreateMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof apiDeutschepostBulkOrdersCreateRemoteCreate>>
  >;

export type ApiDeutschepostBulkOrdersCreateRemoteCreateMutationError = void;

/**
 * @summary Create Remote Bulk Order
 */
export const useApiDeutschepostBulkOrdersCreateRemoteCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiDeutschepostBulkOrdersCreateRemoteCreate>>,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiDeutschepostBulkOrdersCreateRemoteCreate>>,
  TError,
  { id: number },
  TContext
> => {
  return useMutation(
    getApiDeutschepostBulkOrdersCreateRemoteCreateMutationOptions(options),
    queryClient,
  );
};
/**
 *
        Generate combined PDF with all order labels for bulk shipment. This will:
        - Create multi-page PDF with all order details
        - Include recipient addresses and tracking information
        - Format for warehouse processing
        - Save PDF to bulk_order.bulk_label_pdf field

 * @summary Generate Bulk Labels
 */
export const apiDeutschepostBulkOrdersGenerateLabelsCreate = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<void>({
    url: `/api/deutschepost/bulk-orders/${id}/generate_labels/`,
    method: "POST",
    signal,
  });
};

export const getApiDeutschepostBulkOrdersGenerateLabelsCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiDeutschepostBulkOrdersGenerateLabelsCreate>>,
    TError,
    { id: number },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiDeutschepostBulkOrdersGenerateLabelsCreate>>,
  TError,
  { id: number },
  TContext
> => {
  const mutationKey = ["apiDeutschepostBulkOrdersGenerateLabelsCreate"];
  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 apiDeutschepostBulkOrdersGenerateLabelsCreate>>,
    { id: number }
  > = (props) => {
    const { id } = props ?? {};

    return apiDeutschepostBulkOrdersGenerateLabelsCreate(id);
  };

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

export type ApiDeutschepostBulkOrdersGenerateLabelsCreateMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof apiDeutschepostBulkOrdersGenerateLabelsCreate>>
  >;

export type ApiDeutschepostBulkOrdersGenerateLabelsCreateMutationError = void;

/**
 * @summary Generate Bulk Labels
 */
export const useApiDeutschepostBulkOrdersGenerateLabelsCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiDeutschepostBulkOrdersGenerateLabelsCreate>>,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiDeutschepostBulkOrdersGenerateLabelsCreate>>,
  TError,
  { id: number },
  TContext
> => {
  return useMutation(
    getApiDeutschepostBulkOrdersGenerateLabelsCreateMutationOptions(options),
    queryClient,
  );
};
/**
 *
        Get tracking and status URLs for the bulk order. Returns:
        - tracking_url: Public URL for tracking bulk shipment progress
        - status_url: URL for monitoring bulk order processing status

 * @summary Get Bulk Order URLs
 */
export const apiDeutschepostBulkOrdersGetUrlsRetrieve = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<void>({
    url: `/api/deutschepost/bulk-orders/${id}/get_urls/`,
    method: "GET",
    signal,
  });
};

export const getApiDeutschepostBulkOrdersGetUrlsRetrieveQueryKey = (
  id: number,
) => {
  return [`/api/deutschepost/bulk-orders/${id}/get_urls/`] as const;
};

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

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

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

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

export type ApiDeutschepostBulkOrdersGetUrlsRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiDeutschepostBulkOrdersGetUrlsRetrieve>>
>;
export type ApiDeutschepostBulkOrdersGetUrlsRetrieveQueryError = void;

export function useApiDeutschepostBulkOrdersGetUrlsRetrieve<
  TData = Awaited<ReturnType<typeof apiDeutschepostBulkOrdersGetUrlsRetrieve>>,
  TError = void,
>(
  id: number,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostBulkOrdersGetUrlsRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiDeutschepostBulkOrdersGetUrlsRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiDeutschepostBulkOrdersGetUrlsRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiDeutschepostBulkOrdersGetUrlsRetrieve<
  TData = Awaited<ReturnType<typeof apiDeutschepostBulkOrdersGetUrlsRetrieve>>,
  TError = void,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostBulkOrdersGetUrlsRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiDeutschepostBulkOrdersGetUrlsRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiDeutschepostBulkOrdersGetUrlsRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiDeutschepostBulkOrdersGetUrlsRetrieve<
  TData = Awaited<ReturnType<typeof apiDeutschepostBulkOrdersGetUrlsRetrieve>>,
  TError = void,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostBulkOrdersGetUrlsRetrieve>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Get Bulk Order URLs
 */

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

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

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

/**
 *
        Refresh bulk order status from Deutsche Post API. This will:
        - Fetch latest bulk order status from Deutsche Post
        - Update bulk order status (PROCESSING, COMPLETED, etc.)
        - Store raw API response data in metadata
        - Update individual order statuses if needed

 * @summary Refresh Bulk Order Status
 */
export const apiDeutschepostBulkOrdersRefreshStatusCreate = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<DeutschePostBulkOrder>({
    url: `/api/deutschepost/bulk-orders/${id}/refresh_status/`,
    method: "POST",
    signal,
  });
};

export const getApiDeutschepostBulkOrdersRefreshStatusCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiDeutschepostBulkOrdersRefreshStatusCreate>>,
    TError,
    { id: number },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiDeutschepostBulkOrdersRefreshStatusCreate>>,
  TError,
  { id: number },
  TContext
> => {
  const mutationKey = ["apiDeutschepostBulkOrdersRefreshStatusCreate"];
  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 apiDeutschepostBulkOrdersRefreshStatusCreate>>,
    { id: number }
  > = (props) => {
    const { id } = props ?? {};

    return apiDeutschepostBulkOrdersRefreshStatusCreate(id);
  };

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

export type ApiDeutschepostBulkOrdersRefreshStatusCreateMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof apiDeutschepostBulkOrdersRefreshStatusCreate>>
  >;

export type ApiDeutschepostBulkOrdersRefreshStatusCreateMutationError = void;

/**
 * @summary Refresh Bulk Order Status
 */
export const useApiDeutschepostBulkOrdersRefreshStatusCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiDeutschepostBulkOrdersRefreshStatusCreate>>,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiDeutschepostBulkOrdersRefreshStatusCreate>>,
  TError,
  { id: number },
  TContext
> => {
  return useMutation(
    getApiDeutschepostBulkOrdersRefreshStatusCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * Returns a paginated list of Deutsche Post shipping orders. Orders are created internally through Carrier model. Admin only access.
 * @summary List Deutsche Post Orders
 */
export const apiDeutschepostOrdersList = (
  params?: ApiDeutschepostOrdersListParams,
  signal?: AbortSignal,
) => {
  return privateMutator<PaginatedDeutschePostOrderList>({
    url: `/api/deutschepost/orders/`,
    method: "GET",
    params,
    signal,
  });
};

export const getApiDeutschepostOrdersListQueryKey = (
  params?: ApiDeutschepostOrdersListParams,
) => {
  return [`/api/deutschepost/orders/`, ...(params ? [params] : [])] as const;
};

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

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

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

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

export type ApiDeutschepostOrdersListQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiDeutschepostOrdersList>>
>;
export type ApiDeutschepostOrdersListQueryError = unknown;

export function useApiDeutschepostOrdersList<
  TData = Awaited<ReturnType<typeof apiDeutschepostOrdersList>>,
  TError = unknown,
>(
  params: undefined | ApiDeutschepostOrdersListParams,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostOrdersList>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiDeutschepostOrdersList>>,
          TError,
          Awaited<ReturnType<typeof apiDeutschepostOrdersList>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiDeutschepostOrdersList<
  TData = Awaited<ReturnType<typeof apiDeutschepostOrdersList>>,
  TError = unknown,
>(
  params?: ApiDeutschepostOrdersListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostOrdersList>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiDeutschepostOrdersList>>,
          TError,
          Awaited<ReturnType<typeof apiDeutschepostOrdersList>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiDeutschepostOrdersList<
  TData = Awaited<ReturnType<typeof apiDeutschepostOrdersList>>,
  TError = unknown,
>(
  params?: ApiDeutschepostOrdersListParams,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostOrdersList>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary List Deutsche Post Orders
 */

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

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

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

/**
 * Create a new Deutsche Post order with recipient and shipment details. Order will automatically be created remotely if validation passes.
 * @summary Create Deutsche Post Order
 */
export const apiDeutschepostOrdersCreate = (
  deutschePostOrder: NonReadonly<DeutschePostOrder>,
  signal?: AbortSignal,
) => {
  return privateMutator<DeutschePostOrder>({
    url: `/api/deutschepost/orders/`,
    method: "POST",
    headers: { "Content-Type": "application/json" },
    data: deutschePostOrder,
    signal,
  });
};

export const getApiDeutschepostOrdersCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiDeutschepostOrdersCreate>>,
    TError,
    { data: NonReadonly<DeutschePostOrder> },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiDeutschepostOrdersCreate>>,
  TError,
  { data: NonReadonly<DeutschePostOrder> },
  TContext
> => {
  const mutationKey = ["apiDeutschepostOrdersCreate"];
  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 apiDeutschepostOrdersCreate>>,
    { data: NonReadonly<DeutschePostOrder> }
  > = (props) => {
    const { data } = props ?? {};

    return apiDeutschepostOrdersCreate(data);
  };

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

export type ApiDeutschepostOrdersCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiDeutschepostOrdersCreate>>
>;
export type ApiDeutschepostOrdersCreateMutationBody =
  NonReadonly<DeutschePostOrder>;
export type ApiDeutschepostOrdersCreateMutationError = void;

/**
 * @summary Create Deutsche Post Order
 */
export const useApiDeutschepostOrdersCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiDeutschepostOrdersCreate>>,
      TError,
      { data: NonReadonly<DeutschePostOrder> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiDeutschepostOrdersCreate>>,
  TError,
  { data: NonReadonly<DeutschePostOrder> },
  TContext
> => {
  return useMutation(
    getApiDeutschepostOrdersCreateMutationOptions(options),
    queryClient,
  );
};
/**
 * Returns detailed information for a single Deutsche Post order including tracking data. Orders are managed through Carrier model.
 * @summary Get Deutsche Post Order Detail
 */
export const apiDeutschepostOrdersRetrieve = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<DeutschePostOrder>({
    url: `/api/deutschepost/orders/${id}/`,
    method: "GET",
    signal,
  });
};

export const getApiDeutschepostOrdersRetrieveQueryKey = (id: number) => {
  return [`/api/deutschepost/orders/${id}/`] as const;
};

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

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

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

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

export type ApiDeutschepostOrdersRetrieveQueryResult = NonNullable<
  Awaited<ReturnType<typeof apiDeutschepostOrdersRetrieve>>
>;
export type ApiDeutschepostOrdersRetrieveQueryError = unknown;

export function useApiDeutschepostOrdersRetrieve<
  TData = Awaited<ReturnType<typeof apiDeutschepostOrdersRetrieve>>,
  TError = unknown,
>(
  id: number,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostOrdersRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiDeutschepostOrdersRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiDeutschepostOrdersRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiDeutschepostOrdersRetrieve<
  TData = Awaited<ReturnType<typeof apiDeutschepostOrdersRetrieve>>,
  TError = unknown,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostOrdersRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<ReturnType<typeof apiDeutschepostOrdersRetrieve>>,
          TError,
          Awaited<ReturnType<typeof apiDeutschepostOrdersRetrieve>>
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiDeutschepostOrdersRetrieve<
  TData = Awaited<ReturnType<typeof apiDeutschepostOrdersRetrieve>>,
  TError = unknown,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostOrdersRetrieve>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Get Deutsche Post Order Detail
 */

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

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

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

/**
 * Update Deutsche Post order details. Cannot update orders that are already created remotely.
 * @summary Update Deutsche Post Order
 */
export const apiDeutschepostOrdersUpdate = (
  id: number,
  deutschePostOrder: NonReadonly<DeutschePostOrder>,
  signal?: AbortSignal,
) => {
  return privateMutator<DeutschePostOrder>({
    url: `/api/deutschepost/orders/${id}/`,
    method: "PUT",
    headers: { "Content-Type": "application/json" },
    data: deutschePostOrder,
    signal,
  });
};

export const getApiDeutschepostOrdersUpdateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiDeutschepostOrdersUpdate>>,
    TError,
    { id: number; data: NonReadonly<DeutschePostOrder> },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiDeutschepostOrdersUpdate>>,
  TError,
  { id: number; data: NonReadonly<DeutschePostOrder> },
  TContext
> => {
  const mutationKey = ["apiDeutschepostOrdersUpdate"];
  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 apiDeutschepostOrdersUpdate>>,
    { id: number; data: NonReadonly<DeutschePostOrder> }
  > = (props) => {
    const { id, data } = props ?? {};

    return apiDeutschepostOrdersUpdate(id, data);
  };

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

export type ApiDeutschepostOrdersUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiDeutschepostOrdersUpdate>>
>;
export type ApiDeutschepostOrdersUpdateMutationBody =
  NonReadonly<DeutschePostOrder>;
export type ApiDeutschepostOrdersUpdateMutationError = void;

/**
 * @summary Update Deutsche Post Order
 */
export const useApiDeutschepostOrdersUpdate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiDeutschepostOrdersUpdate>>,
      TError,
      { id: number; data: NonReadonly<DeutschePostOrder> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiDeutschepostOrdersUpdate>>,
  TError,
  { id: number; data: NonReadonly<DeutschePostOrder> },
  TContext
> => {
  return useMutation(
    getApiDeutschepostOrdersUpdateMutationOptions(options),
    queryClient,
  );
};
/**
 * Partially update Deutsche Post order details. Cannot update orders that are already created remotely.
 * @summary Partially Update Deutsche Post Order
 */
export const apiDeutschepostOrdersPartialUpdate = (
  id: number,
  patchedDeutschePostOrder: NonReadonly<PatchedDeutschePostOrder>,
  signal?: AbortSignal,
) => {
  return privateMutator<DeutschePostOrder>({
    url: `/api/deutschepost/orders/${id}/`,
    method: "PATCH",
    headers: { "Content-Type": "application/json" },
    data: patchedDeutschePostOrder,
    signal,
  });
};

export const getApiDeutschepostOrdersPartialUpdateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiDeutschepostOrdersPartialUpdate>>,
    TError,
    { id: number; data: NonReadonly<PatchedDeutschePostOrder> },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiDeutschepostOrdersPartialUpdate>>,
  TError,
  { id: number; data: NonReadonly<PatchedDeutschePostOrder> },
  TContext
> => {
  const mutationKey = ["apiDeutschepostOrdersPartialUpdate"];
  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 apiDeutschepostOrdersPartialUpdate>>,
    { id: number; data: NonReadonly<PatchedDeutschePostOrder> }
  > = (props) => {
    const { id, data } = props ?? {};

    return apiDeutschepostOrdersPartialUpdate(id, data);
  };

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

export type ApiDeutschepostOrdersPartialUpdateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiDeutschepostOrdersPartialUpdate>>
>;
export type ApiDeutschepostOrdersPartialUpdateMutationBody =
  NonReadonly<PatchedDeutschePostOrder>;
export type ApiDeutschepostOrdersPartialUpdateMutationError = void;

/**
 * @summary Partially Update Deutsche Post Order
 */
export const useApiDeutschepostOrdersPartialUpdate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiDeutschepostOrdersPartialUpdate>>,
      TError,
      { id: number; data: NonReadonly<PatchedDeutschePostOrder> },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiDeutschepostOrdersPartialUpdate>>,
  TError,
  { id: number; data: NonReadonly<PatchedDeutschePostOrder> },
  TContext
> => {
  return useMutation(
    getApiDeutschepostOrdersPartialUpdateMutationOptions(options),
    queryClient,
  );
};
/**
 * Delete Deutsche Post order. If order is created remotely, it will attempt to cancel it first.
 * @summary Delete Deutsche Post Order
 */
export const apiDeutschepostOrdersDestroy = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<void>({
    url: `/api/deutschepost/orders/${id}/`,
    method: "DELETE",
    signal,
  });
};

export const getApiDeutschepostOrdersDestroyMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiDeutschepostOrdersDestroy>>,
    TError,
    { id: number },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiDeutschepostOrdersDestroy>>,
  TError,
  { id: number },
  TContext
> => {
  const mutationKey = ["apiDeutschepostOrdersDestroy"];
  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 apiDeutschepostOrdersDestroy>>,
    { id: number }
  > = (props) => {
    const { id } = props ?? {};

    return apiDeutschepostOrdersDestroy(id);
  };

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

export type ApiDeutschepostOrdersDestroyMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiDeutschepostOrdersDestroy>>
>;

export type ApiDeutschepostOrdersDestroyMutationError = void;

/**
 * @summary Delete Deutsche Post Order
 */
export const useApiDeutschepostOrdersDestroy = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiDeutschepostOrdersDestroy>>,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiDeutschepostOrdersDestroy>>,
  TError,
  { id: number },
  TContext
> => {
  return useMutation(
    getApiDeutschepostOrdersDestroyMutationOptions(options),
    queryClient,
  );
};
/**
 *
        Cancel the order in Deutsche Post API system. This will:
        - Call Deutsche Post API to cancel the order
        - Update the order state to CANCELLED
        - Cannot be undone once cancelled
        - Only works for orders that are not yet shipped or delivered

        Note: Orders are created and managed through the Carrier model in commerce app.

 * @summary Cancel Deutsche Post Order
 */
export const apiDeutschepostOrdersCancelOrderCreate = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<DeutschePostOrder>({
    url: `/api/deutschepost/orders/${id}/cancel_order/`,
    method: "POST",
    signal,
  });
};

export const getApiDeutschepostOrdersCancelOrderCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiDeutschepostOrdersCancelOrderCreate>>,
    TError,
    { id: number },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiDeutschepostOrdersCancelOrderCreate>>,
  TError,
  { id: number },
  TContext
> => {
  const mutationKey = ["apiDeutschepostOrdersCancelOrderCreate"];
  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 apiDeutschepostOrdersCancelOrderCreate>>,
    { id: number }
  > = (props) => {
    const { id } = props ?? {};

    return apiDeutschepostOrdersCancelOrderCreate(id);
  };

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

export type ApiDeutschepostOrdersCancelOrderCreateMutationResult = NonNullable<
  Awaited<ReturnType<typeof apiDeutschepostOrdersCancelOrderCreate>>
>;

export type ApiDeutschepostOrdersCancelOrderCreateMutationError = void;

/**
 * @summary Cancel Deutsche Post Order
 */
export const useApiDeutschepostOrdersCancelOrderCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiDeutschepostOrdersCancelOrderCreate>>,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiDeutschepostOrdersCancelOrderCreate>>,
  TError,
  { id: number },
  TContext
> => {
  return useMutation(
    getApiDeutschepostOrdersCancelOrderCreateMutationOptions(options),
    queryClient,
  );
};
/**
 *
        Finalize the order in Deutsche Post API system. This will:
        - Call Deutsche Post API to finalize the order
        - Update the order state to FINALIZED
        - Retrieve AWB number and barcode for tracking
        - Enable label generation
        - Required before the order can be shipped

 * @summary Finalize Deutsche Post Order
 */
export const apiDeutschepostOrdersFinalizeOrderCreate = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<DeutschePostOrder>({
    url: `/api/deutschepost/orders/${id}/finalize_order/`,
    method: "POST",
    signal,
  });
};

export const getApiDeutschepostOrdersFinalizeOrderCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiDeutschepostOrdersFinalizeOrderCreate>>,
    TError,
    { id: number },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiDeutschepostOrdersFinalizeOrderCreate>>,
  TError,
  { id: number },
  TContext
> => {
  const mutationKey = ["apiDeutschepostOrdersFinalizeOrderCreate"];
  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 apiDeutschepostOrdersFinalizeOrderCreate>>,
    { id: number }
  > = (props) => {
    const { id } = props ?? {};

    return apiDeutschepostOrdersFinalizeOrderCreate(id);
  };

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

export type ApiDeutschepostOrdersFinalizeOrderCreateMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof apiDeutschepostOrdersFinalizeOrderCreate>>
  >;

export type ApiDeutschepostOrdersFinalizeOrderCreateMutationError = void;

/**
 * @summary Finalize Deutsche Post Order
 */
export const useApiDeutschepostOrdersFinalizeOrderCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiDeutschepostOrdersFinalizeOrderCreate>>,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiDeutschepostOrdersFinalizeOrderCreate>>,
  TError,
  { id: number },
  TContext
> => {
  return useMutation(
    getApiDeutschepostOrdersFinalizeOrderCreateMutationOptions(options),
    queryClient,
  );
};
/**
 *
        Generate and download shipping label PDF. This will:
        - Attempt to download label from Deutsche Post API
        - If API label not available, generate simple label with order details
        - Save label PDF to order.label_pdf field
        - Include barcode and tracking information
        - Requires order to be created remotely first

 * @summary Generate Shipping Label
 */
export const apiDeutschepostOrdersGenerateLabelCreate = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<void>({
    url: `/api/deutschepost/orders/${id}/generate_label/`,
    method: "POST",
    signal,
  });
};

export const getApiDeutschepostOrdersGenerateLabelCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiDeutschepostOrdersGenerateLabelCreate>>,
    TError,
    { id: number },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiDeutschepostOrdersGenerateLabelCreate>>,
  TError,
  { id: number },
  TContext
> => {
  const mutationKey = ["apiDeutschepostOrdersGenerateLabelCreate"];
  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 apiDeutschepostOrdersGenerateLabelCreate>>,
    { id: number }
  > = (props) => {
    const { id } = props ?? {};

    return apiDeutschepostOrdersGenerateLabelCreate(id);
  };

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

export type ApiDeutschepostOrdersGenerateLabelCreateMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof apiDeutschepostOrdersGenerateLabelCreate>>
  >;

export type ApiDeutschepostOrdersGenerateLabelCreateMutationError = void;

/**
 * @summary Generate Shipping Label
 */
export const useApiDeutschepostOrdersGenerateLabelCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiDeutschepostOrdersGenerateLabelCreate>>,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiDeutschepostOrdersGenerateLabelCreate>>,
  TError,
  { id: number },
  TContext
> => {
  return useMutation(
    getApiDeutschepostOrdersGenerateLabelCreateMutationOptions(options),
    queryClient,
  );
};
/**
 *
        Get the public tracking URL for the order that customers can use to track their shipment.
        Returns the URL if available, or null if tracking is not yet available.

 * @summary Get Tracking URL
 */
export const apiDeutschepostOrdersGetTrackingUrlRetrieve = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<void>({
    url: `/api/deutschepost/orders/${id}/get_tracking_url/`,
    method: "GET",
    signal,
  });
};

export const getApiDeutschepostOrdersGetTrackingUrlRetrieveQueryKey = (
  id: number,
) => {
  return [`/api/deutschepost/orders/${id}/get_tracking_url/`] as const;
};

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

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

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

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

export type ApiDeutschepostOrdersGetTrackingUrlRetrieveQueryResult =
  NonNullable<
    Awaited<ReturnType<typeof apiDeutschepostOrdersGetTrackingUrlRetrieve>>
  >;
export type ApiDeutschepostOrdersGetTrackingUrlRetrieveQueryError = void;

export function useApiDeutschepostOrdersGetTrackingUrlRetrieve<
  TData = Awaited<
    ReturnType<typeof apiDeutschepostOrdersGetTrackingUrlRetrieve>
  >,
  TError = void,
>(
  id: number,
  options: {
    query: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostOrdersGetTrackingUrlRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        DefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof apiDeutschepostOrdersGetTrackingUrlRetrieve>
          >,
          TError,
          Awaited<
            ReturnType<typeof apiDeutschepostOrdersGetTrackingUrlRetrieve>
          >
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): DefinedUseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiDeutschepostOrdersGetTrackingUrlRetrieve<
  TData = Awaited<
    ReturnType<typeof apiDeutschepostOrdersGetTrackingUrlRetrieve>
  >,
  TError = void,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostOrdersGetTrackingUrlRetrieve>>,
        TError,
        TData
      >
    > &
      Pick<
        UndefinedInitialDataOptions<
          Awaited<
            ReturnType<typeof apiDeutschepostOrdersGetTrackingUrlRetrieve>
          >,
          TError,
          Awaited<
            ReturnType<typeof apiDeutschepostOrdersGetTrackingUrlRetrieve>
          >
        >,
        "initialData"
      >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
export function useApiDeutschepostOrdersGetTrackingUrlRetrieve<
  TData = Awaited<
    ReturnType<typeof apiDeutschepostOrdersGetTrackingUrlRetrieve>
  >,
  TError = void,
>(
  id: number,
  options?: {
    query?: Partial<
      UseQueryOptions<
        Awaited<ReturnType<typeof apiDeutschepostOrdersGetTrackingUrlRetrieve>>,
        TError,
        TData
      >
    >;
  },
  queryClient?: QueryClient,
): UseQueryResult<TData, TError> & {
  queryKey: DataTag<QueryKey, TData, TError>;
};
/**
 * @summary Get Tracking URL
 */

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

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

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

/**
 *
        Refresh tracking information from Deutsche Post API. This will:
        - Fetch latest order status from Deutsche Post
        - Update AWB number, barcode, and tracking URL
        - Update order state based on shipment status
        - Store raw tracking data in metadata

        Note: Orders are created and managed through the Carrier model in commerce app.

 * @summary Refresh Tracking Information
 */
export const apiDeutschepostOrdersRefreshTrackingCreate = (
  id: number,
  signal?: AbortSignal,
) => {
  return privateMutator<DeutschePostTracking>({
    url: `/api/deutschepost/orders/${id}/refresh_tracking/`,
    method: "POST",
    signal,
  });
};

export const getApiDeutschepostOrdersRefreshTrackingCreateMutationOptions = <
  TError = void,
  TContext = unknown,
>(options?: {
  mutation?: UseMutationOptions<
    Awaited<ReturnType<typeof apiDeutschepostOrdersRefreshTrackingCreate>>,
    TError,
    { id: number },
    TContext
  >;
}): UseMutationOptions<
  Awaited<ReturnType<typeof apiDeutschepostOrdersRefreshTrackingCreate>>,
  TError,
  { id: number },
  TContext
> => {
  const mutationKey = ["apiDeutschepostOrdersRefreshTrackingCreate"];
  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 apiDeutschepostOrdersRefreshTrackingCreate>>,
    { id: number }
  > = (props) => {
    const { id } = props ?? {};

    return apiDeutschepostOrdersRefreshTrackingCreate(id);
  };

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

export type ApiDeutschepostOrdersRefreshTrackingCreateMutationResult =
  NonNullable<
    Awaited<ReturnType<typeof apiDeutschepostOrdersRefreshTrackingCreate>>
  >;

export type ApiDeutschepostOrdersRefreshTrackingCreateMutationError = void;

/**
 * @summary Refresh Tracking Information
 */
export const useApiDeutschepostOrdersRefreshTrackingCreate = <
  TError = void,
  TContext = unknown,
>(
  options?: {
    mutation?: UseMutationOptions<
      Awaited<ReturnType<typeof apiDeutschepostOrdersRefreshTrackingCreate>>,
      TError,
      { id: number },
      TContext
    >;
  },
  queryClient?: QueryClient,
): UseMutationResult<
  Awaited<ReturnType<typeof apiDeutschepostOrdersRefreshTrackingCreate>>,
  TError,
  { id: number },
  TContext
> => {
  return useMutation(
    getApiDeutschepostOrdersRefreshTrackingCreateMutationOptions(options),
    queryClient,
  );
};
