Skip to content

Commit

Permalink
Adds ability to send a booked through origin when adding an attendee …
Browse files Browse the repository at this point in the history
…to an appointment
  • Loading branch information
craigpaul committed Nov 26, 2020
1 parent 5d564ac commit 297efe5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/resources/appointment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,34 @@ it('can add the given attendee to the given appointment with notification meta d
});
});

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

await resource.with(attendee).through(Origins.MODERN_CLIENT_VIEW).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: {
origin: Origins.MODERN_CLIENT_VIEW,
},
}, {
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
8 changes: 8 additions & 0 deletions src/resources/appointment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export interface AddAttendeeParameters {
client?: boolean;
user?: boolean;
};
origin?: number;
}
}

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

if (this.filters.through) {
params.meta = {
...params.meta,
origin: this.filters.through,
}
}

if (this.filters.notifications) {
params.meta = {
...params.meta,
Expand Down

0 comments on commit 297efe5

Please sign in to comment.