feat: Add slotFormat query parameter to slots API V2 endpoint to return start and end time of a slot (#17873)
* feat: Add formatAsStartAndEndTime query parameter to slots API V2 endpoint to return start and end time of a slot * Update apps/api/v2/src/modules/slots/controllers/slots.controller.ts Co-authored-by: Praash <[email protected]> * Fix duration was allowed to be any number * Refactor code * Show slotFormat property as optional in swagger doc --------- Co-authored-by: Praash <[email protected]>
This commit is contained in:
1 parent
3290ae526a
commit
ae4474cd42
8 files changed
+221
-31
No files matched your search
@@ -7,3 +7,4 @@ export * from "./event-types/scheduling-type";
|
||||
export * from "./event-types/frequency";
|
||||
export * from "./event-types/booker-layouts.enum";
|
||||
export * from "./event-types/confirmation-policy.enum";
|
||||
export * from "./slot-format.enum";
|
||||
@@ -0,0 +1,4 @@
|
||||
export enum SlotFormat {
|
||||
Range = "range",
|
||||
Time = "time",
|
||||
}
|
||||
@@ -1,6 +1,18 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
||||
import { Transform } from "class-transformer";
|
||||
import { IsArray, IsBoolean, IsDateString, IsInt, IsNumber, IsOptional, IsString } from "class-validator";
|
||||
import {
|
||||
IsArray,
|
||||
IsBoolean,
|
||||
IsDateString,
|
||||
IsInt,
|
||||
IsNumber,
|
||||
IsOptional,
|
||||
IsString,
|
||||
Min,
|
||||
IsEnum,
|
||||
} from "class-validator";
|
||||
|
||||
import { SlotFormat } from "@calcom/platform-enums";
|
||||
|
||||
export class GetAvailableSlotsInput {
|
||||
@IsDateString()
|
||||
@@ -43,6 +55,7 @@ export class GetAvailableSlotsInput {
|
||||
@Transform(({ value }: { value: string }) => value && parseInt(value))
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
@Min(1, { message: "Duration must be a positive number" })
|
||||
@ApiProperty({ description: "Only for dynamic events - length of returned slots." })
|
||||
duration?: number;
|
||||
|
||||
@@ -57,6 +70,22 @@ export class GetAvailableSlotsInput {
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
orgSlug?: string;
|
||||
|
||||
@IsString()
|
||||
@IsEnum(SlotFormat, {
|
||||
message: "slotFormat must be either 'range' or 'time'",
|
||||
})
|
||||
@Transform(({ value }) => {
|
||||
if (!value) return undefined;
|
||||
return value.toLowerCase();
|
||||
})
|
||||
@IsOptional()
|
||||
@ApiPropertyOptional({
|
||||
description: "Format of slot times in response. Use 'range' to get start and end times.",
|
||||
example: "range",
|
||||
enum: SlotFormat,
|
||||
})
|
||||
slotFormat?: SlotFormat;
|
||||
}
|
||||
|
||||
export class RemoveSelectedSlotInput {
|
||||
|
||||
Reference in new issue
Block a user