Skip to content

Commit

Permalink
Adds notifications to add attendee parameters when they are set
Browse files Browse the repository at this point in the history
  • Loading branch information
craigpaul committed Dec 6, 2019
1 parent e849467 commit 901f948
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
31 changes: 31 additions & 0 deletions src/resources/appointment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,37 @@ it('can add the given attendee to the given appointment', async () => {
});
});

it('can add the given attendee to the given appointment with notification meta data', async () => {
const resource = new Appointment(mockAxios);
const attendee = (new Attendee()).named('Jane', 'Doe').reachable({ email: '[email protected]' });

await resource.with(attendee).notify(Notifications.ALL).add(1);

expect(mockAxios.put).toHaveBeenCalledTimes(1);
expect(mockAxios.put).toHaveBeenCalledWith('appointments/1/attendees', {
data: [
{
attributes: {
email: '[email protected]',
first_name: 'Jane',
last_name: 'Doe',
},
type: 'attendees',
}
],
meta: {
notify: {
client: true,
user: true,
},
},
}, {
headers: {
'Content-Type': 'application/json; ext=bulk',
},
});
});

it('can add the given attendee to the given appointment while supplying answers', async () => {
const resource = new Appointment(mockAxios);
const answer = (new Answer()).for(1).is('the value');
Expand Down
23 changes: 17 additions & 6 deletions src/resources/appointment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,21 @@ export interface RescheduleParameters {

interface AddSingleAttendeeParameter {
attributes: {
email: string,
first_name: string,
last_name: string,
},
type: string,
email: string;
first_name: string;
last_name: string;
};
type: string;
}

export interface AddAttendeeParameters {
data: AddSingleAttendeeParameter[],
data: AddSingleAttendeeParameter[];
meta?: {
booker?: number;
notify?: {
client?: boolean;
user?: boolean;
};
}
}

Expand Down Expand Up @@ -285,6 +289,13 @@ export default class Appointment extends Conditional implements AppointmentResou
};
}

if (this.filters.notifications) {
params.meta = {
...params.meta,
notify: this.filters.notifications,
};
}

return params;
}

Expand Down

0 comments on commit 901f948

Please sign in to comment.