diff --git a/.github/oasdiff-err-ignore.txt b/.github/oasdiff-err-ignore.txt index 634506501bf3c2..dd6794a550adee 100644 --- a/.github/oasdiff-err-ignore.txt +++ b/.github/oasdiff-err-ignore.txt @@ -15,3 +15,8 @@ GET /v2/oauth-clients/{clientId}/webhooks/{webhookId} added the new path request DELETE /v2/teams/{teamId}/event-types/{eventTypeId}/webhooks/{webhookId} added the new path request parameter 'webhookId' GET /v2/teams/{teamId}/event-types/{eventTypeId}/webhooks/{webhookId} added the new path request parameter 'webhookId' GET /v2/webhooks/{webhookId} added the new path request parameter 'webhookId' +GET /v2/calendars/busy-times added the new required 'query' request parameter 'calendarsToLoad' +GET /v2/calendars/busy-times the 'query' request parameter 'dateFrom' became required +GET /v2/calendars/busy-times the 'query' request parameter 'dateTo' became required +GET /v2/calendars/busy-times deleted the 'query' request parameter 'credentialId' +GET /v2/calendars/busy-times deleted the 'query' request parameter 'externalId' diff --git a/apps/api/v2/src/ee/calendars/controllers/calendars.controller.ts b/apps/api/v2/src/ee/calendars/controllers/calendars.controller.ts index 5e32ebf5335be6..827ac9f230918c 100644 --- a/apps/api/v2/src/ee/calendars/controllers/calendars.controller.ts +++ b/apps/api/v2/src/ee/calendars/controllers/calendars.controller.ts @@ -116,6 +116,23 @@ export class CalendarsController { description: "Get busy times from a calendar. Example request URL is `https://api.cal.com/v2/calendars/busy-times?timeZone=Europe%2FMadrid&dateFrom=2024-12-18&dateTo=2024-12-18&calendarsToLoad[0][credentialId]=135&calendarsToLoad[0][externalId]=skrauciz%40gmail.com`. Note: loggedInUsersTz is deprecated, use timeZone instead.", }) + @ApiQuery({ + name: "calendarsToLoad", + required: true, + description: + "An array of Calendar objects representing the calendars to be loaded. Use bracket notation in the URL, e.g.: calendarsToLoad[0][credentialId]=135&calendarsToLoad[0][externalId]=email@example.com", + schema: { + type: "array", + items: { + type: "object", + properties: { + credentialId: { type: "number", example: 135 }, + externalId: { type: "string", example: "email@example.com" }, + }, + required: ["credentialId", "externalId"], + }, + }, + }) async getBusyTimes( @Query() queryParams: CalendarBusyTimesInput, @GetUser() user: UserWithProfile diff --git a/docs/api-reference/v2/openapi.json b/docs/api-reference/v2/openapi.json index 007be244f68aa1..47722df504ae27 100644 --- a/docs/api-reference/v2/openapi.json +++ b/docs/api-reference/v2/openapi.json @@ -10499,7 +10499,7 @@ }, { "name": "dateFrom", - "required": false, + "required": true, "in": "query", "description": "The starting date for the busy times query", "schema": { @@ -10509,7 +10509,7 @@ }, { "name": "dateTo", - "required": false, + "required": true, "in": "query", "description": "The ending date for the busy times query", "schema": { @@ -10518,19 +10518,26 @@ } }, { - "name": "credentialId", - "in": "query", + "name": "calendarsToLoad", "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "externalId", "in": "query", - "required": true, + "description": "An array of Calendar objects representing the calendars to be loaded. Use bracket notation in the URL, e.g.: calendarsToLoad[0][credentialId]=135&calendarsToLoad[0][externalId]=email@example.com", "schema": { - "type": "string" + "type": "array", + "items": { + "type": "object", + "properties": { + "credentialId": { + "type": "number", + "example": 135 + }, + "externalId": { + "type": "string", + "example": "email@example.com" + } + }, + "required": ["credentialId", "externalId"] + } } }, { diff --git a/packages/platform/types/calendars/inputs/busy-times.input.ts b/packages/platform/types/calendars/inputs/busy-times.input.ts index d25b05da21f5ca..68417278082b2b 100644 --- a/packages/platform/types/calendars/inputs/busy-times.input.ts +++ b/packages/platform/types/calendars/inputs/busy-times.input.ts @@ -1,4 +1,4 @@ -import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger"; +import { ApiHideProperty, ApiProperty, ApiPropertyOptional } from "@nestjs/swagger"; import { Transform, Type } from "class-transformer"; import { IsArray, @@ -41,11 +41,11 @@ function ValidateTimezoneRequired( export class Calendar { @Transform(({ value }: { value: string }) => value && parseInt(value, 10)) @IsNumber() - @ApiProperty() + @ApiHideProperty() credentialId!: number; @IsString() - @ApiProperty() + @ApiHideProperty() externalId!: string; } @@ -73,7 +73,6 @@ export class CalendarBusyTimesInput { timeZone?: string; @ApiProperty({ - required: false, description: "The starting date for the busy times query", example: "2023-10-01", }) @@ -82,7 +81,6 @@ export class CalendarBusyTimesInput { dateFrom!: string; @ApiProperty({ - required: false, description: "The ending date for the busy times query", example: "2023-10-31", }) @@ -90,12 +88,7 @@ export class CalendarBusyTimesInput { @IsDateString() dateTo!: string; - @ApiProperty({ - type: [Calendar], - required: true, - description: "An array of Calendar objects representing the calendars to be loaded", - example: `[{ credentialId: "1", externalId: "AQgtJE7RnHEeyisVq2ENs2gAAAgEGAAAACgtJE7RnHEeyisVq2ENs2gAAAhSDAAAA" }, { credentialId: "2", externalId: "AQM7RnHEeyisVq2ENs2gAAAhFDBBBBB" }]`, - }) + @ApiHideProperty() @IsArray() @ValidateNested({ each: true }) @Type(() => Calendar)