Skip to content

Commit

Permalink
Fixes improperly config for reschedule call
Browse files Browse the repository at this point in the history
  • Loading branch information
craigpaul committed Nov 10, 2020
1 parent d24311b commit 81a26a9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
34 changes: 19 additions & 15 deletions src/resources/appointment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
},
});
});

Expand All @@ -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',
}
},
});
}

Expand Down
11 changes: 5 additions & 6 deletions src/resources/appointment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ export interface RescheduleParameters {
user?: boolean;
};
};
params: {
code: string;
};
}

interface AddSingleAttendeeParameter {
Expand Down Expand Up @@ -285,7 +282,10 @@ export default class Appointment extends Conditional implements AppointmentResou
}

public async reschedule(appointment: number, code: string): Promise<any> {
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 {
Expand Down Expand Up @@ -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: {
Expand All @@ -447,7 +447,6 @@ export default class Appointment extends Conditional implements AppointmentResou
id: appointment,
type: 'appointments',
},
params: { code },
};

if (this.filters.timezone) {
Expand Down

0 comments on commit 81a26a9

Please sign in to comment.