From 81a26a9192899894a9bfdb815dc5767c9ffe6da6 Mon Sep 17 00:00:00 2001 From: Craig Paul Date: Tue, 10 Nov 2020 15:04:41 -0600 Subject: [PATCH] Fixes improperly config for reschedule call --- src/resources/appointment.test.ts | 34 +++++++++++++++++-------------- src/resources/appointment.ts | 11 +++++----- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/resources/appointment.test.ts b/src/resources/appointment.test.ts index 1b414b6..55f5969 100644 --- a/src/resources/appointment.test.ts +++ b/src/resources/appointment.test.ts @@ -556,15 +556,17 @@ it('can reschedule an appointment with the minimum required parameters', async ( expect(mockAxios.patch).toHaveBeenCalledTimes(1); expect(mockAxios.patch).toHaveBeenCalledWith('appointments/1', { data: { - attributes: { - start, - }, - id: 1, - type: 'appointments', + data: { + attributes: { + start, + }, + id: 1, + type: 'appointments', + } }, params: { code: 'code', - } + }, }); }); @@ -582,19 +584,21 @@ it('can reschedule an appointment with all available parameters', async () => { expect(mockAxios.patch).toHaveBeenCalledWith('appointments/1', { data: { - attributes: { - start, - timezone: 'America/Toronto', + data: { + attributes: { + start, + timezone: 'America/Toronto', + }, + id: 1, + type: 'appointments', + }, + meta: { + notify: notification, }, - id: 1, - type: 'appointments', - }, - meta: { - notify: notification, }, params: { code: 'code', - } + }, }); } diff --git a/src/resources/appointment.ts b/src/resources/appointment.ts index c8efea5..3e5eab7 100644 --- a/src/resources/appointment.ts +++ b/src/resources/appointment.ts @@ -87,9 +87,6 @@ export interface RescheduleParameters { user?: boolean; }; }; - params: { - code: string; - }; } interface AddSingleAttendeeParameter { @@ -285,7 +282,10 @@ export default class Appointment extends Conditional implements AppointmentResou } public async reschedule(appointment: number, code: string): Promise { - return await this.client.patch(`appointments/${appointment}`, this.rescheduleParams(appointment, code)); + return await this.client.patch(`appointments/${appointment}`, { + data: this.rescheduleParams(appointment), + params: { code } + }); } public starting(start: string): this { @@ -438,7 +438,7 @@ export default class Appointment extends Conditional implements AppointmentResou return params; } - protected rescheduleParams(appointment: number, code: string): RescheduleParameters | object { + protected rescheduleParams(appointment: number): RescheduleParameters | object { let params: RescheduleParameters = { data: { attributes: { @@ -447,7 +447,6 @@ export default class Appointment extends Conditional implements AppointmentResou id: appointment, type: 'appointments', }, - params: { code }, }; if (this.filters.timezone) {