feat: booker atom custom location (#14635)

* frontend: handle booking locationUrl

* backend: pass booking locationUrl to handleNewBooking

* examples app: display booking location if provided

* fix: v2 not starting: contains -> includes

* backend: pass booking locationUrl to handleNewBooking

* swagger docs update

* examples app: dont display where of booking if does not start with http

---------

Co-authored-by: Keith Williams <[email protected]>
Co-authored-by: Morgan <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-04-18 08:26:36 +00:00
1 parent 0aa1628925
commit be128181e2
9 files changed
+53 -14

No files matched your search

@@ -57,6 +57,7 @@ type OAuthRequestParams = {
platformRescheduleUrl: string;
platformCancelUrl: string;
platformBookingUrl: string;
platformBookingLocation?: string;
};
const DEFAULT_PLATFORM_PARAMS = {
@@ -65,6 +66,7 @@ const DEFAULT_PLATFORM_PARAMS = {
platformRescheduleUrl: "",
platformBookingUrl: "",
areEmailsEnabled: true,
platformBookingLocation: undefined,
};
@Controller({
@@ -141,12 +143,15 @@ export class BookingsController {
@Post("/")
async createBooking(
@Req() req: BookingRequest,
@Body() _: CreateBookingInput,
@Body() body: CreateBookingInput,
@Headers(X_CAL_CLIENT_ID) clientId?: string
): Promise<ApiResponse<unknown>> {
const oAuthClientId = clientId?.toString();
const locationUrl = body.locationUrl;
try {
const booking = await handleNewBooking(await this.createNextApiBookingRequest(req, oAuthClientId));
const booking = await handleNewBooking(
await this.createNextApiBookingRequest(req, oAuthClientId, locationUrl)
);
return {
status: SUCCESS_STATUS,
data: booking,
@@ -258,13 +263,14 @@ export class BookingsController {
async createNextApiBookingRequest(
req: BookingRequest,
oAuthClientId?: string
oAuthClientId?: string,
platformBookingLocation?: string
): Promise<NextApiRequest & { userId?: number } & OAuthRequestParams> {
const userId = (await this.getOwnerId(req)) ?? -1;
const oAuthParams = oAuthClientId
? await this.getOAuthClientsParams(req, oAuthClientId)
: DEFAULT_PLATFORM_PARAMS;
Object.assign(req, { userId, ...oAuthParams });
Object.assign(req, { userId, ...oAuthParams, platformBookingLocation });
req.body = { ...req.body, areEmailsEnabled: oAuthParams.areEmailsEnabled };
return req as unknown as NextApiRequest & { userId?: number } & OAuthRequestParams;
}
@@ -98,4 +98,8 @@ export class CreateBookingInput {
@Type(() => Response)
responses!: Response;
@IsString()
@IsOptional()
locationUrl?: string;
}
+4 -1
View File
@@ -4225,6 +4225,9 @@
},
"responses": {
"$ref": "#/components/schemas/Response"
},
"locationUrl": {
"type": "string"
}
},
"required": [
@@ -4270,4 +4273,4 @@
}
}
}
}
}