/* eslint-disable */
// This code is autogenerated using @harnessio/oats-cli.
// Please do not modify this code directly.
import { useQuery, UseQueryOptions } from '@tanstack/react-query';

import type { GetInvitationResponse } from '../schemas/GetInvitationResponse';
import { fetcher, FetcherOptions } from 'services/fetcher';

export interface ListInvitationsQueryPathParams {
  invitation_state: 'Accepted' | 'Declined' | 'Exited' | 'Pending';
}

export type ListInvitationsOkResponse = {
  data?: GetInvitationResponse[];
};

export type ListInvitationsErrorResponse = unknown;

export interface ListInvitationsProps
  extends ListInvitationsQueryPathParams,
    Omit<FetcherOptions<unknown, unknown>, 'url'> {}

export function listInvitations(props: ListInvitationsProps): Promise<ListInvitationsOkResponse> {
  return fetcher<ListInvitationsOkResponse, unknown, unknown>({
    url: `/auth/list_invitations_with_filters/${props.invitation_state}`,
    method: 'GET',
    ...props
  });
}

/**
 * This API is used to list all the pending invitations of the user
 *
 */
export function useListInvitationsQuery(
  props: ListInvitationsProps,
  options?: Omit<UseQueryOptions<ListInvitationsOkResponse, ListInvitationsErrorResponse>, 'queryKey' | 'queryFn'>
) {
  return useQuery<ListInvitationsOkResponse, ListInvitationsErrorResponse>(
    ['listInvitations', props.invitation_state],
    ({ signal }) => listInvitations({ ...props, signal }),
    options
  );
}
