/** * Generated by orval 🍺 * Do not edit manually. * Lincodex API * OpenAPI spec version: 0.1.0 */ import { useQuery } from '@tanstack/react-query'; import type { DataTag, DefinedInitialDataOptions, DefinedUseQueryResult, QueryClient, QueryFunction, QueryKey, UndefinedInitialDataOptions, UseQueryOptions, UseQueryResult } from '@tanstack/react-query'; import type { ConsentRecordList, ListMyConsentsParams, Problem } from '../../schemas'; import { apiRequest } from '../../client'; import type { ErrorType } from '../../client'; type SecondParameter unknown> = Parameters[1]; const withQueryKey = (query: T, queryKey: K): T & { queryKey: K } => { const result = { queryKey } as T & { queryKey: K }; for (const key of Object.keys(query)) { // The explicit queryKey always wins, matching the previous // `{ ...query, queryKey }` spread where it was set last. if (key === 'queryKey') continue; Object.defineProperty(result, key, { enumerable: true, configurable: true, get: () => (query as Record)[key], }); } return result; }; export const getListMyConsentsUrl = (params?: ListMyConsentsParams,) => { const normalizedParams = new URLSearchParams(); Object.entries(params || {}).forEach(([key, value]) => { if (value !== undefined) { normalizedParams.append(key, value === null ? 'null' : String(value)) } }); const stringifiedParams = normalizedParams.toString(); return stringifiedParams.length > 0 ? `/api/v1/me/consents?${stringifiedParams}` : `/api/v1/me/consents` } /** * Requires the session cookie of a candidate or an employer account. The subject comes from the session, never from a request parameter, so the response holds only the caller's own consents: no request can name another account, and records of other accounts are never listed. Returns a page of the consent ledger of the account, newest grant first with the identifier as the tie-breaker, with cursor pagination. * * The ledger is append-only. Every grant is a record with its purpose, the accepted text version, the source, and the grant time; the server also stores the hash of exactly the text the subject saw. A newer text version of the same purpose is a new record, and the earlier one becomes `superseded` without any change. A revocation stamps every unrevoked record of the purpose, and for c4 of one organization, once; a later grant is a new record. Purposes are independent. * * Without `state` the page lists the whole history; `state=active` lists the consents that hold now, one per purpose for c1, c2, c3, and c5 and one per accepted invitation for c4. A c4 record names the organization with the name its consent text showed (a snapshot that a later rename does not change), the selected contact fields, and the invitation with its terms version; it never carries a contact value. A c2 record proves the consent to the publication text; the published field set and its changes are evidence of the publication history. * * Granting c1, c2, c3, and c5 in the consent settings and revoking any purpose are planned operations of this tag; c1 is given at registration and c4 only in AcceptMyInvitation. * * Access: a missing, unknown, expired, or revoked session answers 401 unauthenticated. A malformed `limit`, `cursor`, or `state` answers 400 validation_failed. * @summary List the consents of the current account with their history. */ export const listMyConsents = async (params?: ListMyConsentsParams, options?: Parameters[1]): Promise => { return apiRequest(getListMyConsentsUrl(params), { ...options, method: 'GET' } );} export const getListMyConsentsQueryKey = (params?: ListMyConsentsParams,) => { return [ `/api/v1/me/consents`, ...(params ? [params] : []) ] as const; } export const getListMyConsentsQueryOptions = >, TError = ErrorType>(params?: ListMyConsentsParams, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} ) => { const {query: queryOptions, request: requestOptions} = options ?? {}; const queryKey = queryOptions?.queryKey ?? getListMyConsentsQueryKey(params); const queryFn: QueryFunction>> = ({ signal }) => listMyConsents(params, { signal, ...requestOptions }); return { queryKey, queryFn, ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: DataTag } } export type ListMyConsentsQueryResult = NonNullable>> export type ListMyConsentsQueryError = ErrorType export function useListMyConsents>, TError = ErrorType>( params: undefined | ListMyConsentsParams, options: { query:Partial>, TError, TData>> & Pick< DefinedInitialDataOptions< Awaited>, TError, Awaited> > , 'initialData' >, request?: SecondParameter} , queryClient?: QueryClient ): DefinedUseQueryResult & { queryKey: DataTag } export function useListMyConsents>, TError = ErrorType>( params?: ListMyConsentsParams, options?: { query?:Partial>, TError, TData>> & Pick< UndefinedInitialDataOptions< Awaited>, TError, Awaited> > , 'initialData' >, request?: SecondParameter} , queryClient?: QueryClient ): UseQueryResult & { queryKey: DataTag } export function useListMyConsents>, TError = ErrorType>( params?: ListMyConsentsParams, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} , queryClient?: QueryClient ): UseQueryResult & { queryKey: DataTag } /** * @summary List the consents of the current account with their history. */ export function useListMyConsents>, TError = ErrorType>( params?: ListMyConsentsParams, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} , queryClient?: QueryClient ): UseQueryResult & { queryKey: DataTag } { const queryOptions = getListMyConsentsQueryOptions(params,options) const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; return withQueryKey(query, queryOptions.queryKey); }