Skip to content

Commit

Permalink
Adds ability to provide an actingAs identifier which will later be us…
Browse files Browse the repository at this point in the history
…ed to identify the booker
  • Loading branch information
craigpaul committed Nov 26, 2019
1 parent dd00b59 commit ff40f1f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/resources/appointment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ it('can set multiple attendees for the appointment', async () => {
});
});

it('can set an identifier for who we are acting as when booking the appointment', async () => {
const resource = new Appointment(mockAxios);

expect(resource.actingAs(10)).toHaveProperty('meta', {
booker: 10,
});
});

it('can book an appointment with the minimum required parameters', async () => {
const resource = new Appointment(mockAxios);
const start = '2018-01-01 12:00:00';
Expand Down
14 changes: 14 additions & 0 deletions src/resources/appointment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export interface AddAttendeeParameters {
}

export interface AppointmentResource extends Resource, ConditionalResource {
actingAs(identifier: number): this;

add(appointment: number): Promise<any>;

at(location: number): this;
Expand Down Expand Up @@ -135,9 +137,14 @@ export interface AppointmentRelationship {
attendees: AttendeeModel[] | [];
}

export interface AppointmentMeta {
booker?: number;
}

export default class Appointment extends Conditional implements AppointmentResource, Utm {
protected client: AxiosInstance;
protected filters: AppointmentFilter;
protected meta: AppointmentMeta;
protected relationships: AppointmentRelationship;
protected utm: UtmParameters;

Expand All @@ -146,12 +153,19 @@ export default class Appointment extends Conditional implements AppointmentResou

this.client = client;
this.filters = {};
this.meta = {};
this.relationships = {
attendees: [],
};
this.utm = {};
}

public actingAs(identifier: number): this {
this.meta.booker = identifier;

return this;
}

public async add(appointment: number): Promise<any> {
return await this.client.put(`appointments/${appointment}/attendees`, this.addParams(), {
headers: {
Expand Down

0 comments on commit ff40f1f

Please sign in to comment.