From a997edd8dbf77cd4ec5b61f9fe1ce34aaa291c2a Mon Sep 17 00:00:00 2001 From: Rajiv Sahal Date: Thu, 25 Jul 2024 10:49:18 +0200 Subject: [PATCH] chore: update dtos for v2 calendars endpoint (#15904) * init calendars input * update request body input type * fix incorrect naming * update imprts * fixup! update imprts * fixup! fixup! update imprts --------- Co-authored-by: Morgan Vernay --- .../controllers/calendars.controller.ts | 3 +- .../delete-calendar-credentials.input.ts | 15 + apps/api/v2/swagger/documentation.json | 453 ++++++++++-------- 3 files changed, 263 insertions(+), 208 deletions(-) create mode 100644 apps/api/v2/src/ee/calendars/input/delete-calendar-credentials.input.ts 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 a456677c73..0401fc54a9 100644 --- a/apps/api/v2/src/ee/calendars/controllers/calendars.controller.ts +++ b/apps/api/v2/src/ee/calendars/controllers/calendars.controller.ts @@ -1,4 +1,5 @@ import { CalendarsRepository } from "@/ee/calendars/calendars.repository"; +import { DeleteCalendarCredentialsInputBodyDto } from "@/ee/calendars/input/delete-calendar-credentials.input"; import { GetBusyTimesOutput } from "@/ee/calendars/outputs/busy-times.output"; import { ConnectedCalendarsOutput } from "@/ee/calendars/outputs/connected-calendars.output"; import { @@ -196,7 +197,7 @@ export class CalendarsController { @HttpCode(HttpStatus.OK) async deleteCalendarCredentials( @Param("calendar") calendar: string, - @Body() body: { id: number }, + @Body() body: DeleteCalendarCredentialsInputBodyDto, @GetUser() user: UserWithProfile ): Promise { const { id: credentialId } = body; diff --git a/apps/api/v2/src/ee/calendars/input/delete-calendar-credentials.input.ts b/apps/api/v2/src/ee/calendars/input/delete-calendar-credentials.input.ts new file mode 100644 index 0000000000..31e4aa2b63 --- /dev/null +++ b/apps/api/v2/src/ee/calendars/input/delete-calendar-credentials.input.ts @@ -0,0 +1,15 @@ +import { ApiProperty } from "@nestjs/swagger"; +import { Expose } from "class-transformer"; +import { IsInt } from "class-validator"; + +export class DeleteCalendarCredentialsInputBodyDto { + @IsInt() + @Expose() + @ApiProperty({ + example: 10, + description: "Credential ID of the calendar to delete, as returned by the /calendars endpoint", + type: "integer", + required: true, + }) + readonly id!: number; +} diff --git a/apps/api/v2/swagger/documentation.json b/apps/api/v2/swagger/documentation.json index 69152aa8a8..8d73215751 100644 --- a/apps/api/v2/swagger/documentation.json +++ b/apps/api/v2/swagger/documentation.json @@ -741,6 +741,81 @@ ] } }, + "/v2/selected-calendars": { + "post": { + "operationId": "SelectedCalendarsController_addSelectedCalendar", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SelectedCalendarsInputDto" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SelectedCalendarOutputResponseDto" + } + } + } + } + }, + "tags": [ + "Selected-Calendars" + ] + }, + "delete": { + "operationId": "SelectedCalendarsController_removeSelectedCalendar", + "parameters": [ + { + "name": "integration", + "required": true, + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "externalId", + "required": true, + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "credentialId", + "required": true, + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SelectedCalendarOutputResponseDto" + } + } + } + } + }, + "tags": [ + "Selected-Calendars" + ] + } + }, "/v2/event-types/{username}/{eventSlug}/public": { "get": { "operationId": "EventTypesController_2024_04_15_getPublicEventType", @@ -1085,16 +1160,6 @@ } } ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CreateScheduleInput_2024_06_11" - } - } - } - }, "responses": { "201": { "description": "", @@ -1197,16 +1262,6 @@ } } ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UpdateScheduleInput_2024_06_11" - } - } - } - }, "responses": { "200": { "description": "", @@ -2246,16 +2301,6 @@ } } ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UpdateScheduleInput_2024_04_15" - } - } - } - }, "responses": { "200": { "description": "", @@ -2672,6 +2717,46 @@ ] } }, + "/v2/calendars/{calendar}/disconnect": { + "post": { + "operationId": "CalendarsController_deleteCalendarCredentials", + "parameters": [ + { + "name": "calendar", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeleteCalendarCredentialsInputBodyDto" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeletedCalendarCredentialsOutputResponseDto" + } + } + } + } + }, + "tags": [ + "Calendars" + ] + } + }, "/v2/bookings": { "get": { "operationId": "BookingsController_getBookings", @@ -3880,6 +3965,69 @@ "data" ] }, + "SelectedCalendarsInputDto": { + "type": "object", + "properties": { + "integration": { + "type": "string" + }, + "externalId": { + "type": "string" + }, + "credentialId": { + "type": "number" + } + }, + "required": [ + "integration", + "externalId", + "credentialId" + ] + }, + "SelectedCalendarOutputDto": { + "type": "object", + "properties": { + "userId": { + "type": "number" + }, + "integration": { + "type": "string" + }, + "externalId": { + "type": "string" + }, + "credentialId": { + "type": "number", + "nullable": true + } + }, + "required": [ + "userId", + "integration", + "externalId", + "credentialId" + ] + }, + "SelectedCalendarOutputResponseDto": { + "type": "object", + "properties": { + "status": { + "type": "string", + "example": "success", + "enum": [ + "success", + "error" + ] + }, + "data": { + "$ref": "#/components/schemas/SelectedCalendarOutputDto" + } + }, + "required": [ + "status", + "data" + ] + }, "EventTypeLocation_2024_04_15": { "type": "object", "properties": { @@ -5181,57 +5329,6 @@ "data" ] }, - "CreateScheduleInput_2024_06_11": { - "type": "object", - "properties": { - "name": { - "type": "string", - "example": "One-on-one coaching" - }, - "timeZone": { - "type": "string", - "example": "Europe/Rome" - }, - "availability": { - "example": [ - { - "days": [ - "Monday", - "Tuesday" - ], - "startTime": "09:00", - "endTime": "10:00" - } - ], - "type": "array", - "items": { - "$ref": "#/components/schemas/ScheduleAvailabilityInput_2024_06_11" - } - }, - "isDefault": { - "type": "boolean", - "example": true - }, - "overrides": { - "example": [ - { - "date": "2024-05-20", - "startTime": "12:00", - "endTime": "14:00" - } - ], - "type": "array", - "items": { - "$ref": "#/components/schemas/ScheduleOverrideInput_2024_06_11" - } - } - }, - "required": [ - "name", - "timeZone", - "isDefault" - ] - }, "CreateScheduleOutput_2024_06_11": { "type": "object", "properties": { @@ -5280,52 +5377,6 @@ "data" ] }, - "UpdateScheduleInput_2024_06_11": { - "type": "object", - "properties": { - "name": { - "type": "string", - "example": "One-on-one coaching" - }, - "timeZone": { - "type": "string", - "example": "Europe/Rome" - }, - "availability": { - "example": [ - { - "days": [ - "Monday", - "Tuesday" - ], - "startTime": "09:00", - "endTime": "10:00" - } - ], - "type": "array", - "items": { - "$ref": "#/components/schemas/ScheduleAvailabilityInput_2024_06_11" - } - }, - "isDefault": { - "type": "boolean", - "example": true - }, - "overrides": { - "example": [ - { - "date": "2024-05-20", - "startTime": "12:00", - "endTime": "14:00" - } - ], - "type": "array", - "items": { - "$ref": "#/components/schemas/ScheduleOverrideInput_2024_06_11" - } - } - } - }, "UpdateScheduleOutput_2024_06_11": { "type": "object", "properties": { @@ -6416,26 +6467,6 @@ "userId" ] }, - "GetDefaultScheduleOutput_2024_06_11": { - "type": "object", - "properties": { - "status": { - "type": "string", - "example": "success", - "enum": [ - "success", - "error" - ] - }, - "data": { - "$ref": "#/components/schemas/ScheduleOutput_2024_06_11" - } - }, - "required": [ - "status", - "data" - ] - }, "CreateAvailabilityInput_2024_04_15": { "type": "object", "properties": { @@ -6733,66 +6764,6 @@ "data" ] }, - "UpdateScheduleInput_2024_04_15": { - "type": "object", - "properties": { - "timeZone": { - "type": "string" - }, - "name": { - "type": "string" - }, - "isDefault": { - "type": "boolean" - }, - "schedule": { - "example": [ - [], - [ - { - "start": "2022-01-01T00:00:00.000Z", - "end": "2022-01-02T00:00:00.000Z" - } - ], - [], - [], - [], - [], - [] - ], - "items": { - "type": "array" - }, - "type": "array" - }, - "dateOverrides": { - "example": [ - [], - [ - { - "start": "2022-01-01T00:00:00.000Z", - "end": "2022-01-02T00:00:00.000Z" - } - ], - [], - [], - [], - [], - [] - ], - "items": { - "type": "array" - }, - "type": "array" - } - }, - "required": [ - "timeZone", - "name", - "isDefault", - "schedule" - ] - }, "EventTypeModel_2024_04_15": { "type": "object", "properties": { @@ -7422,6 +7393,74 @@ "data" ] }, + "DeleteCalendarCredentialsInputBodyDto": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 10, + "description": "Credential ID of the calendar to delete, as returned by the /calendars endpoint" + } + }, + "required": [ + "id" + ] + }, + "DeletedCalendarCredentialsOutputDto": { + "type": "object", + "properties": { + "id": { + "type": "number" + }, + "type": { + "type": "string" + }, + "userId": { + "type": "number", + "nullable": true + }, + "teamId": { + "type": "number", + "nullable": true + }, + "appId": { + "type": "string", + "nullable": true + }, + "invalid": { + "type": "boolean", + "nullable": true + } + }, + "required": [ + "id", + "type", + "userId", + "teamId", + "appId", + "invalid" + ] + }, + "DeletedCalendarCredentialsOutputResponseDto": { + "type": "object", + "properties": { + "status": { + "type": "string", + "example": "success", + "enum": [ + "success", + "error" + ] + }, + "data": { + "$ref": "#/components/schemas/DeletedCalendarCredentialsOutputDto" + } + }, + "required": [ + "status", + "data" + ] + }, "Attendee": { "type": "object", "properties": {