2022-10-11 14:25:57 +00:00
|
|
|
import type { NextApiRequest } from "next";
|
|
|
|
|
|
|
|
import { defaultResponder } from "@calcom/lib/server";
|
|
|
|
|
2022-11-25 13:56:58 +00:00
|
|
|
import { schemaBookingReferenceReadPublic } from "~/lib/validations/booking-reference";
|
|
|
|
import { schemaQueryIdParseInt } from "~/lib/validations/shared/queryIdTransformParseInt";
|
2022-10-11 14:25:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @swagger
|
|
|
|
* /booking-references/{id}:
|
|
|
|
* get:
|
|
|
|
* operationId: getBookingReferenceById
|
|
|
|
* summary: Find a booking reference
|
|
|
|
* parameters:
|
|
|
|
* - in: path
|
|
|
|
* name: id
|
|
|
|
* schema:
|
|
|
|
* type: integer
|
|
|
|
* required: true
|
|
|
|
* description: ID of the booking reference to get
|
2023-02-13 12:52:11 +00:00
|
|
|
* - in: query
|
|
|
|
* name: apiKey
|
|
|
|
* required: true
|
|
|
|
* schema:
|
|
|
|
* type: string
|
|
|
|
* description: Your API key
|
2022-10-11 14:25:57 +00:00
|
|
|
* tags:
|
2023-02-13 12:52:11 +00:00
|
|
|
* - booking-references
|
2022-10-11 14:25:57 +00:00
|
|
|
* responses:
|
|
|
|
* 200:
|
|
|
|
* description: OK
|
|
|
|
* 401:
|
|
|
|
* description: Authorization information is missing or invalid.
|
|
|
|
* 404:
|
|
|
|
* description: BookingReference was not found
|
|
|
|
*/
|
|
|
|
export async function getHandler(req: NextApiRequest) {
|
|
|
|
const { prisma, query } = req;
|
|
|
|
const { id } = schemaQueryIdParseInt.parse(query);
|
|
|
|
const booking_reference = await prisma.bookingReference.findUniqueOrThrow({ where: { id } });
|
|
|
|
return { booking_reference: schemaBookingReferenceReadPublic.parse(booking_reference) };
|
|
|
|
}
|
|
|
|
|
|
|
|
export default defaultResponder(getHandler);
|