Skip to content

Commit

Permalink
Adds required code parameter to reschedule an appointment
Browse files Browse the repository at this point in the history
  • Loading branch information
craigpaul committed Nov 10, 2020
1 parent 82762be commit a4935ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/resources/appointment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ it('can reschedule an appointment with the minimum required parameters', async (

await resource
.starting(start)
.reschedule(1);
.reschedule(1, 'code');

expect(mockAxios.patch).toHaveBeenCalledTimes(1);
expect(mockAxios.patch).toHaveBeenCalledWith('appointments/1', {
Expand All @@ -562,6 +562,9 @@ it('can reschedule an appointment with the minimum required parameters', async (
id: 1,
type: 'appointments',
},
params: {
code: 'code',
}
});
});

Expand All @@ -575,7 +578,7 @@ it('can reschedule an appointment with all available parameters', async () => {
.starting(start)
.in('America/Toronto')
.notify(notification)
.reschedule(1);
.reschedule(1, 'code');

expect(mockAxios.patch).toHaveBeenCalledWith('appointments/1', {
data: {
Expand All @@ -589,6 +592,9 @@ it('can reschedule an appointment with all available parameters', async () => {
meta: {
notify: notification,
},
params: {
code: 'code',
}
});
}

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

interface AddSingleAttendeeParameter {
Expand Down Expand Up @@ -134,7 +137,7 @@ export interface AppointmentResource extends Resource, ConditionalResource {

notify(notifications: AppointmentNotificationParameters): this;

reschedule(appointment: number): Promise<any>;
reschedule(appointment: number, code: string): Promise<any>;

starting(start: string): this;

Expand Down Expand Up @@ -281,8 +284,8 @@ export default class Appointment extends Conditional implements AppointmentResou
return this;
}

public async reschedule(appointment: number): Promise<any> {
return await this.client.patch(`appointments/${appointment}`, this.rescheduleParams(appointment));
public async reschedule(appointment: number, code: string): Promise<any> {
return await this.client.patch(`appointments/${appointment}`, this.rescheduleParams(appointment, code));
}

public starting(start: string): this {
Expand Down Expand Up @@ -435,7 +438,7 @@ export default class Appointment extends Conditional implements AppointmentResou
return params;
}

protected rescheduleParams(appointment: number): RescheduleParameters | object {
protected rescheduleParams(appointment: number, code: string): RescheduleParameters | object {
let params: RescheduleParameters = {
data: {
attributes: {
Expand All @@ -444,6 +447,7 @@ export default class Appointment extends Conditional implements AppointmentResou
id: appointment,
type: 'appointments',
},
params: { code },
};

if (this.filters.timezone) {
Expand Down

0 comments on commit a4935ab

Please sign in to comment.