Update client with new guest rsvp endpoint
This commit is contained in:
@@ -19,7 +19,8 @@ import {
|
||||
deleteGuest,
|
||||
getGuest,
|
||||
updateGuest,
|
||||
setGuestStatusApiV1EventsGuestsGuestIdStatusPatch,
|
||||
setGuestStatus,
|
||||
createGuestRsvp,
|
||||
getRsvps,
|
||||
createRsvp,
|
||||
deleteRsvp,
|
||||
@@ -76,9 +77,12 @@ import type {
|
||||
UpdateGuestData,
|
||||
UpdateGuestError,
|
||||
UpdateGuestResponse,
|
||||
SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchData,
|
||||
SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchError,
|
||||
SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchResponse,
|
||||
SetGuestStatusData,
|
||||
SetGuestStatusError,
|
||||
SetGuestStatusResponse,
|
||||
CreateGuestRsvpData,
|
||||
CreateGuestRsvpError,
|
||||
CreateGuestRsvpResponse,
|
||||
GetRsvpsData,
|
||||
CreateRsvpData,
|
||||
CreateRsvpError,
|
||||
@@ -609,18 +613,57 @@ export const updateGuestMutation = (
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const setGuestStatusApiV1EventsGuestsGuestIdStatusPatchMutation = (
|
||||
options?: Partial<
|
||||
Options<SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchData>
|
||||
>,
|
||||
export const setGuestStatusMutation = (
|
||||
options?: Partial<Options<SetGuestStatusData>>,
|
||||
) => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchResponse,
|
||||
AxiosError<SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchError>,
|
||||
Options<SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchData>
|
||||
SetGuestStatusResponse,
|
||||
AxiosError<SetGuestStatusError>,
|
||||
Options<SetGuestStatusData>
|
||||
> = {
|
||||
mutationFn: async (localOptions) => {
|
||||
const { data } = await setGuestStatusApiV1EventsGuestsGuestIdStatusPatch({
|
||||
const { data } = await setGuestStatus({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
};
|
||||
return mutationOptions;
|
||||
};
|
||||
|
||||
export const createGuestRsvpQueryKey = (
|
||||
options: Options<CreateGuestRsvpData>,
|
||||
) => createQueryKey("createGuestRsvp", options);
|
||||
|
||||
export const createGuestRsvpOptions = (
|
||||
options: Options<CreateGuestRsvpData>,
|
||||
) => {
|
||||
return queryOptions({
|
||||
queryFn: async ({ queryKey, signal }) => {
|
||||
const { data } = await createGuestRsvp({
|
||||
...options,
|
||||
...queryKey[0],
|
||||
signal,
|
||||
throwOnError: true,
|
||||
});
|
||||
return data;
|
||||
},
|
||||
queryKey: createGuestRsvpQueryKey(options),
|
||||
});
|
||||
};
|
||||
|
||||
export const createGuestRsvpMutation = (
|
||||
options?: Partial<Options<CreateGuestRsvpData>>,
|
||||
) => {
|
||||
const mutationOptions: UseMutationOptions<
|
||||
CreateGuestRsvpResponse,
|
||||
AxiosError<CreateGuestRsvpError>,
|
||||
Options<CreateGuestRsvpData>
|
||||
> = {
|
||||
mutationFn: async (localOptions) => {
|
||||
const { data } = await createGuestRsvp({
|
||||
...options,
|
||||
...localOptions,
|
||||
throwOnError: true,
|
||||
|
||||
@@ -1506,6 +1506,29 @@ export const GuestUpdateSchema = {
|
||||
title: "GuestUpdate",
|
||||
} as const;
|
||||
|
||||
export const GuestWithRSVPResponseSchema = {
|
||||
properties: {
|
||||
guest: {
|
||||
$ref: "#/components/schemas/GuestRead",
|
||||
},
|
||||
rsvp: {
|
||||
anyOf: [
|
||||
{
|
||||
$ref: "#/components/schemas/RSVPSchema",
|
||||
},
|
||||
{
|
||||
type: "null",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
type: "object",
|
||||
required: ["guest"],
|
||||
title: "GuestWithRSVPResponse",
|
||||
description: `Combined response model that includes both guest and RSVP information.
|
||||
This gives the frontend a complete picture of the guest's response in a single object.`,
|
||||
} as const;
|
||||
|
||||
export const HTTPValidationErrorSchema = {
|
||||
properties: {
|
||||
detail: {
|
||||
|
||||
@@ -55,9 +55,12 @@ import type {
|
||||
UpdateGuestData,
|
||||
UpdateGuestResponse,
|
||||
UpdateGuestError,
|
||||
SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchData,
|
||||
SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchResponse,
|
||||
SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchError,
|
||||
SetGuestStatusData,
|
||||
SetGuestStatusResponse,
|
||||
SetGuestStatusError,
|
||||
CreateGuestRsvpData,
|
||||
CreateGuestRsvpResponse,
|
||||
CreateGuestRsvpError,
|
||||
GetRsvpsData,
|
||||
GetRsvpsResponse,
|
||||
GetRsvpsError,
|
||||
@@ -493,17 +496,12 @@ export const updateGuest = <ThrowOnError extends boolean = false>(
|
||||
/**
|
||||
* Set Guest Status
|
||||
*/
|
||||
export const setGuestStatusApiV1EventsGuestsGuestIdStatusPatch = <
|
||||
ThrowOnError extends boolean = false,
|
||||
>(
|
||||
options: Options<
|
||||
SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchData,
|
||||
ThrowOnError
|
||||
>,
|
||||
export const setGuestStatus = <ThrowOnError extends boolean = false>(
|
||||
options: Options<SetGuestStatusData, ThrowOnError>,
|
||||
) => {
|
||||
return (options.client ?? _heyApiClient).patch<
|
||||
SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchResponse,
|
||||
SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchError,
|
||||
SetGuestStatusResponse,
|
||||
SetGuestStatusError,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/api/v1/events/guests/{guest_id}/status",
|
||||
@@ -511,6 +509,26 @@ export const setGuestStatusApiV1EventsGuestsGuestIdStatusPatch = <
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Process Guest Rsvp
|
||||
*/
|
||||
export const createGuestRsvp = <ThrowOnError extends boolean = false>(
|
||||
options: Options<CreateGuestRsvpData, ThrowOnError>,
|
||||
) => {
|
||||
return (options.client ?? _heyApiClient).post<
|
||||
CreateGuestRsvpResponse,
|
||||
CreateGuestRsvpError,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/api/v1/events/guests/{guest_id}/rsvp",
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...options?.headers,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Read Rsvps
|
||||
*/
|
||||
|
||||
@@ -240,6 +240,15 @@ export type GuestUpdate = {
|
||||
can_bring_guests?: boolean | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Combined response model that includes both guest and RSVP information.
|
||||
* This gives the frontend a complete picture of the guest's response in a single object.
|
||||
*/
|
||||
export type GuestWithRsvpResponse = {
|
||||
guest: GuestRead;
|
||||
rsvp?: RsvpSchema | null;
|
||||
};
|
||||
|
||||
export type HttpValidationError = {
|
||||
detail?: Array<ValidationError>;
|
||||
};
|
||||
@@ -809,7 +818,7 @@ export type UpdateGuestResponses = {
|
||||
export type UpdateGuestResponse =
|
||||
UpdateGuestResponses[keyof UpdateGuestResponses];
|
||||
|
||||
export type SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchData = {
|
||||
export type SetGuestStatusData = {
|
||||
body?: never;
|
||||
path: {
|
||||
guest_id: string;
|
||||
@@ -820,25 +829,54 @@ export type SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchData = {
|
||||
url: "/api/v1/events/guests/{guest_id}/status";
|
||||
};
|
||||
|
||||
export type SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchErrors = {
|
||||
export type SetGuestStatusErrors = {
|
||||
/**
|
||||
* Validation Error
|
||||
*/
|
||||
422: HttpValidationError;
|
||||
};
|
||||
|
||||
export type SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchError =
|
||||
SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchErrors[keyof SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchErrors];
|
||||
export type SetGuestStatusError =
|
||||
SetGuestStatusErrors[keyof SetGuestStatusErrors];
|
||||
|
||||
export type SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchResponses = {
|
||||
export type SetGuestStatusResponses = {
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
200: GuestRead;
|
||||
};
|
||||
|
||||
export type SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchResponse =
|
||||
SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchResponses[keyof SetGuestStatusApiV1EventsGuestsGuestIdStatusPatchResponses];
|
||||
export type SetGuestStatusResponse =
|
||||
SetGuestStatusResponses[keyof SetGuestStatusResponses];
|
||||
|
||||
export type CreateGuestRsvpData = {
|
||||
body: RsvpSchemaCreate;
|
||||
path: {
|
||||
guest_id: string;
|
||||
};
|
||||
query?: never;
|
||||
url: "/api/v1/events/guests/{guest_id}/rsvp";
|
||||
};
|
||||
|
||||
export type CreateGuestRsvpErrors = {
|
||||
/**
|
||||
* Validation Error
|
||||
*/
|
||||
422: HttpValidationError;
|
||||
};
|
||||
|
||||
export type CreateGuestRsvpError =
|
||||
CreateGuestRsvpErrors[keyof CreateGuestRsvpErrors];
|
||||
|
||||
export type CreateGuestRsvpResponses = {
|
||||
/**
|
||||
* Successful Response
|
||||
*/
|
||||
200: GuestWithRsvpResponse;
|
||||
};
|
||||
|
||||
export type CreateGuestRsvpResponse =
|
||||
CreateGuestRsvpResponses[keyof CreateGuestRsvpResponses];
|
||||
|
||||
export type GetRsvpsData = {
|
||||
body?: never;
|
||||
|
||||
Reference in New Issue
Block a user