Skip to content

Commit

Permalink
Adds ability to supply booking shortcut id to a booking
Browse files Browse the repository at this point in the history
  • Loading branch information
craigpaul committed Jun 1, 2021
1 parent 4d03256 commit d5cd4c9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "coconut-open-api-js",
"version": "0.12.3",
"version": "0.12.4",
"description": "Coconut Calendar JS Open API SDK",
"main": "dist/index.js",
"files": [
Expand Down
10 changes: 10 additions & 0 deletions src/resources/appointment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ it('can set the starting time property', async () => {
});
});

it('can set a booking shortcut property', async () => {
const resource = new Appointment(mockAxios);

expect(resource.shortcut(1)).toHaveProperty('filters', {
shortcut: 1,
});
});

it('can set a single attendee for the appointment', async () => {
const resource = new Appointment(mockAxios);
const attendee = new Attendee();
Expand Down Expand Up @@ -243,6 +251,7 @@ it('can book an appointment with all available parameters', async () => {
.for([2, 3])
.by(4)
.via(5)
.shortcut(6)
.starting(start)
.method(PHONE_CALL)
.in('America/Toronto')
Expand Down Expand Up @@ -285,6 +294,7 @@ it('can book an appointment with all available parameters', async () => {
attributes: {
additional_staff_id: [1, 2],
booked_through: Origins.MODERN_CLIENT_VIEW,
booking_shortcut_id: 6,
invitation_id: 5,
location_id: 1,
meeting_method: PHONE_CALL,
Expand Down
17 changes: 16 additions & 1 deletion src/resources/appointment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface AppointmentFilter {
method?: number;
notifications?: AppointmentNotificationParameters;
services?: number | number[];
shortcut?: number;
start?: string;
through?: number;
timezone?: string;
Expand Down Expand Up @@ -40,7 +41,9 @@ export interface AppointmentNotificationParameters {
export interface AppointmentParameters {
data: {
attributes?: {
additional_staff_id?: number | number[],
booked_through?: number;
booking_shortcut_id?: number;
invitation_id: number | null;
location_id: number | undefined;
meeting_method?: number;
Expand All @@ -49,7 +52,6 @@ export interface AppointmentParameters {
start: string | undefined;
supported_locale: string | null;
timezone?: string;
additional_staff_id?: number | number[],
};
relationships: {
attendees: {
Expand Down Expand Up @@ -139,6 +141,8 @@ export interface AppointmentResource extends Resource, ConditionalResource {

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

shortcut(shortcut: number): this;

starting(start: string): this;

supporting(locale: string | null): this;
Expand Down Expand Up @@ -290,6 +294,12 @@ export default class Appointment extends Conditional implements AppointmentResou
return await this.client.patch(`appointments/${appointment}?code=${code}`, this.rescheduleParams(appointment));
}

public shortcut(shortcut: number): this {
this.filters.shortcut = shortcut;

return this;
}

public starting(start: string): this {
this.filters.start = start;

Expand Down Expand Up @@ -417,8 +427,13 @@ export default class Appointment extends Conditional implements AppointmentResou
if (this.filters.timezone) {
params.data.attributes.timezone = this.filters.timezone;
}

if (this.filters.shortcut) {
params.data.attributes.booking_shortcut_id = this.filters.shortcut;
}
}


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

0 comments on commit d5cd4c9

Please sign in to comment.