Skip to content

Commit

Permalink
refactor: use exclude all for response
Browse files Browse the repository at this point in the history
  • Loading branch information
supalarry committed Jan 21, 2025
1 parent ca180f5 commit 4865c63
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ import {
ApiResponse as DocsResponse,
ApiQuery,
} from "@nestjs/swagger";
import { plainToClass } from "class-transformer";

import { SUCCESS_STATUS } from "@calcom/platform-constants";
import {
GetSlotsInput_2024_09_04,
GetSlotsInputPipe,
ReserveSlotInput_2024_09_04,
ReserveSlotOutput_2024_09_04 as ReserveSlotOutputType_2024_09_04,
GetReservedSlotOutput_2024_09_04 as GetReservedSlotOutputType_2024_09_04,
} from "@calcom/platform-types";
import { ApiResponse } from "@calcom/platform-types";

Expand Down Expand Up @@ -185,7 +188,9 @@ export class SlotsController_2024_09_04 {

return {
status: SUCCESS_STATUS,
data: reservedSlot,
data: plainToClass(ReserveSlotOutputType_2024_09_04, reservedSlot, {
strategy: "excludeAll",
}),
};
}

Expand All @@ -198,7 +203,9 @@ export class SlotsController_2024_09_04 {

return {
status: SUCCESS_STATUS,
data: reservedSlot,
data: plainToClass(GetReservedSlotOutputType_2024_09_04, reservedSlot, {
strategy: "excludeAll",
}),
};
}

Expand All @@ -215,7 +222,9 @@ export class SlotsController_2024_09_04 {

return {
status: SUCCESS_STATUS,
data: reservedSlot,
data: plainToClass(ReserveSlotOutputType_2024_09_04, reservedSlot, {
strategy: "excludeAll",
}),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IsInt, IsDateString, IsOptional } from "class-validator";

export class ReserveSlotInput_2024_09_04 {
@IsInt()
@ApiProperty({ example: 1, description: "The ID of the event type for which booking should be reserved." })
@ApiProperty({ example: 1, description: "The ID of the event type for which slot should be reserved." })
eventTypeId!: number;

@IsDateString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,38 @@ export class GetReservedSlotOutput_2024_09_04 {

@IsInt()
@ApiProperty({ example: 1, description: "The ID of the event type for which booking should be reserved." })
@Expose()
eventTypeId!: number;

@IsDateString()
@ApiProperty({
example: "2024-09-04T09:00:00Z",
description: "ISO 8601 datestring in UTC timezone representing available slot.",
})
@Expose()
slotStart!: string;

@IsDateString()
@ApiProperty({
example: "2024-09-04T10:00:00Z",
description: "ISO 8601 datestring in UTC timezone representing slot end.",
})
@Expose()
slotEnd!: string;

@IsInt()
@ApiProperty({
example: "30",
description: "Difference in minutes between slotStart and slotEnd.",
})
@Expose()
slotDuration!: number;

@IsDateString()
@ApiProperty({
example: "2023-09-04T10:00:00Z",
description: "ISO 8601 datestring in UTC timezone representing time until which the slot is reserved.",
})
@Expose()
reservationUntil!: string;
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,62 @@
import { ApiProperty } from "@nestjs/swagger";
import { Expose } from "class-transformer";
import { IsDateString, IsString } from "class-validator";
import { IsDateString, IsInt, IsString } from "class-validator";

import { ReserveSlotInput_2024_09_04 } from "../inputs";

export class ReserveSlotOutput_2024_09_04 extends ReserveSlotInput_2024_09_04 {
@IsString()
@IsInt()
@ApiProperty({ example: 1, description: "The ID of the event type for which slot was reserved." })
@Expose()
eventTypeId!: number;

@IsDateString()
@ApiProperty({
example: "e84be5a3-4696-49e3-acc7-b2f3999c3b94",
description: "The unique identifier of the reservation.",
example: "2024-09-04T09:00:00Z",
description: "ISO 8601 datestring in UTC timezone representing available slot.",
})
@Expose()
reservationUid!: string;
slotStart!: string;

@IsDateString()
@ApiProperty({
example: "2024-09-04T10:00:00Z",
description: "ISO 8601 datestring in UTC timezone representing slot end.",
})
@Expose()
slotEnd!: string;

@IsInt()
@ApiProperty({
example: "30",
description:
"By default slot duration is equal to event type length, but if you want to reserve a slot for an event type that has a variable length you can specify it here. If you don't have this set explicitly that event type can have one of many lengths you can omit this.",
})
@Expose()
slotDuration!: number;

@IsString()
@ApiProperty({
example: "e84be5a3-4696-49e3-acc7-b2f3999c3b94",
description: "The unique identifier of the reservation. Use it to update, get or delete the reservation.",
})
@Expose()
reservationUid!: string;

@IsInt()
@ApiProperty({
example: 5,
description:
"For how many minutes the slot is reserved - for this long time noone else can book this event type at `start` time.",
})
@Expose()
reservationDuration!: number;

@IsDateString()
@ApiProperty({
example: "2023-09-04T10:00:00Z",
description: "ISO 8601 datestring in UTC timezone representing time until which the slot is reserved.",
})
@Expose()
reservationUntil!: string;
}

0 comments on commit 4865c63

Please sign in to comment.