Skip to content

Commit c17ac67

Browse files
feat: add CSAT to V2 bookings return (#19278)
* init * test: v2 bookings returns rating --------- Co-authored-by: supalarry <laurisskraucis@gmail.com> Co-authored-by: Lauris Skraucis <lauris.skraucis@gmail.com>
1 parent b2763a6 commit c17ac67

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/user-bookings.e2e-spec.ts

+25
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ describe("Bookings Endpoints 2024-08-13", () => {
167167
timeZone: "Europe/Rome",
168168
},
169169
},
170+
rating: 10,
170171
});
171172

172173
app = moduleRef.createNestApplication();
@@ -552,6 +553,30 @@ describe("Bookings Endpoints 2024-08-13", () => {
552553
});
553554
});
554555

556+
it("should should get a booking with rating", async () => {
557+
return request(app.getHttpServer())
558+
.get(`/v2/bookings/${bookingInThePast.uid}`)
559+
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
560+
.expect(200)
561+
.then(async (response) => {
562+
const responseBody: GetBookingOutput_2024_08_13 = response.body;
563+
expect(responseBody.status).toEqual(SUCCESS_STATUS);
564+
expect(responseBody.data).toBeDefined();
565+
expect(responseDataIsBooking(responseBody.data)).toBe(true);
566+
567+
if (responseDataIsBooking(responseBody.data)) {
568+
const data: BookingOutput_2024_08_13 = responseBody.data;
569+
expect(data.id).toEqual(bookingInThePast.id);
570+
expect(data.uid).toEqual(bookingInThePast.uid);
571+
expect(data.rating).toEqual(bookingInThePast.rating);
572+
} else {
573+
throw new Error(
574+
"Invalid response data - expected booking but received array of possibily recurring bookings"
575+
);
576+
}
577+
});
578+
});
579+
555580
it("should should get 1 recurrence of a recurring booking", async () => {
556581
const recurrenceUid = createdRecurringBooking[0].uid;
557582
return request(app.getHttpServer())

apps/api/v2/src/ee/bookings/2024-08-13/services/output.service.ts

+4
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export class OutputBookingsService_2024_08_13 {
133133
absentHost: !!databaseBooking.noShowHost,
134134
createdAt: databaseBooking.createdAt,
135135
updatedAt: databaseBooking.updatedAt,
136+
rating: databaseBooking.rating,
136137
};
137138

138139
const bookingTransformed = plainToClass(BookingOutput_2024_08_13, booking, { strategy: "excludeAll" });
@@ -227,6 +228,7 @@ export class OutputBookingsService_2024_08_13 {
227228
bookingFieldsResponses: databaseBooking.responses,
228229
createdAt: databaseBooking.createdAt,
229230
updatedAt: databaseBooking.updatedAt,
231+
rating: databaseBooking.rating,
230232
};
231233

232234
const bookingTransformed = plainToClass(RecurringBookingOutput_2024_08_13, booking, {
@@ -274,6 +276,7 @@ export class OutputBookingsService_2024_08_13 {
274276
absentHost: !!databaseBooking.noShowHost,
275277
createdAt: databaseBooking.createdAt,
276278
updatedAt: databaseBooking.updatedAt,
279+
rating: databaseBooking.rating,
277280
};
278281

279282
const parsed = plainToClass(GetSeatedBookingOutput_2024_08_13, booking, { strategy: "excludeAll" });
@@ -380,6 +383,7 @@ export class OutputBookingsService_2024_08_13 {
380383
absentHost: !!databaseBooking.noShowHost,
381384
createdAt: databaseBooking.createdAt,
382385
updatedAt: databaseBooking.updatedAt,
386+
rating: databaseBooking.rating,
383387
};
384388

385389
const parsed = plainToClass(GetRecurringSeatedBookingOutput_2024_08_13, booking, {

apps/api/v2/swagger/documentation.json

+24
Original file line numberDiff line numberDiff line change
@@ -15376,6 +15376,10 @@
1537615376
"key": "value"
1537715377
}
1537815378
},
15379+
"rating": {
15380+
"type": "number",
15381+
"example": 4
15382+
},
1537915383
"attendees": {
1538015384
"type": "array",
1538115385
"items": {
@@ -15524,6 +15528,10 @@
1552415528
"key": "value"
1552515529
}
1552615530
},
15531+
"rating": {
15532+
"type": "number",
15533+
"example": 4
15534+
},
1552715535
"attendees": {
1552815536
"type": "array",
1552915537
"items": {
@@ -15775,6 +15783,10 @@
1577515783
"key": "value"
1577615784
}
1577715785
},
15786+
"rating": {
15787+
"type": "number",
15788+
"example": 4
15789+
},
1577815790
"seatUid": {
1577915791
"type": "string",
1578015792
"example": "3be561a9-31f1-4b8e-aefc-9d9a085f0dd1"
@@ -15910,6 +15922,10 @@
1591015922
"key": "value"
1591115923
}
1591215924
},
15925+
"rating": {
15926+
"type": "number",
15927+
"example": 4
15928+
},
1591315929
"seatUid": {
1591415930
"type": "string",
1591515931
"example": "3be561a9-31f1-4b8e-aefc-9d9a085f0dd1"
@@ -16090,6 +16106,10 @@
1609016106
"key": "value"
1609116107
}
1609216108
},
16109+
"rating": {
16110+
"type": "number",
16111+
"example": 4
16112+
},
1609316113
"attendees": {
1609416114
"type": "array",
1609516115
"items": {
@@ -16220,6 +16240,10 @@
1622016240
"key": "value"
1622116241
}
1622216242
},
16243+
"rating": {
16244+
"type": "number",
16245+
"example": 4
16246+
},
1622316247
"attendees": {
1622416248
"type": "array",
1622516249
"items": {

packages/platform/types/bookings/2024-08-13/outputs/booking.output.ts

+6
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@ class BaseBookingOutput_2024_08_13 {
249249
@IsOptional()
250250
@Expose()
251251
metadata?: Record<string, string>;
252+
253+
@ApiPropertyOptional({ type: Number, example: 4 })
254+
@IsInt()
255+
@IsOptional()
256+
@Expose()
257+
rating?: number;
252258
}
253259

254260
export class BookingOutput_2024_08_13 extends BaseBookingOutput_2024_08_13 {

0 commit comments

Comments
 (0)