From 10aa641d218415dce66e4fd52e12760237190242 Mon Sep 17 00:00:00 2001 From: CodyAntcliffeCoconut <108283666+CodyAntcliffeCoconut@users.noreply.github.com> Date: Thu, 7 Jul 2022 11:02:31 -0400 Subject: [PATCH] PS-536: Added recaptcha token as an optional parameter (#48) * PS-536: Added recaptcha token as an optional parameter * Fix * sfds * dsfsd * dfh * Formatting changes --- src/models/attendee.ts | 1 + src/resources/appointment.test.ts | 2 ++ src/resources/appointment.ts | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/models/attendee.ts b/src/models/attendee.ts index f74b99b..eafb7ce 100644 --- a/src/models/attendee.ts +++ b/src/models/attendee.ts @@ -47,6 +47,7 @@ export interface AttendeeParameters { notes?: string; phone?: string; postcode?: string; + recaptcha_token?: string | null; region?: string; responses?: ResponseModel[] | []; timezone?: string; diff --git a/src/resources/appointment.test.ts b/src/resources/appointment.test.ts index 1f9e823..a24ae33 100644 --- a/src/resources/appointment.test.ts +++ b/src/resources/appointment.test.ts @@ -311,6 +311,7 @@ it('can book an appointment with all available parameters', async () => { .source('test source') .term('test term') .actingAs(10) + .recaptcha('foo') .withInviteOnly() .withinUserCategory(1) .withoutMeetingLink() @@ -350,6 +351,7 @@ it('can book an appointment with all available parameters', async () => { invite_only_resources: 1, location_id: 1, meeting_method: PHONE_CALL, + recaptcha_token: 'foo', service_id: [2, 3], staff_category_id: 1, staff_id: 4, diff --git a/src/resources/appointment.ts b/src/resources/appointment.ts index 74e11c2..2630dde 100644 --- a/src/resources/appointment.ts +++ b/src/resources/appointment.ts @@ -12,6 +12,7 @@ export interface AppointmentFilter { matchers?: AppointmentMatcherParameters; method?: number; notifications?: AppointmentNotificationParameters; + recaptcha_token?: string | null; services?: number | number[]; shortcut?: number; skip_meeting_link_generation?: boolean; @@ -52,6 +53,7 @@ export interface AppointmentParameters { invite_only_resources?: number; location_id: number | undefined; meeting_method?: number; + recaptcha_token?: string; service_id: number | number[] | undefined; staff_category_id?: number; staff_id: number | null; @@ -148,6 +150,8 @@ export interface AppointmentResource extends Resource, ConditionalResource { notify(notifications: AppointmentNotificationParameters): this; + recaptcha(recaptchaToken: string): this; + reschedule(appointment: number, code: string): Promise; shortcut(shortcut: number): this; @@ -276,7 +280,6 @@ export default class Appointment extends Conditional implements AppointmentResou return await this.client.post('appointments', formData); } - return await this.client.post('appointments', this.params()); } @@ -347,6 +350,12 @@ export default class Appointment extends Conditional implements AppointmentResou return this; } + public recaptcha(recaptchaToken: string): this { + this.filters.recaptcha_token = recaptchaToken; + + return this; + } + public async reschedule(appointment: number, code: string): Promise { return await this.client.patch(`appointments/${appointment}?code=${code}`, this.rescheduleParams(appointment)); } @@ -491,6 +500,10 @@ export default class Appointment extends Conditional implements AppointmentResou supported_locale: this.filters.locale || null, }; + if (this.filters.recaptcha_token) { + params.data.attributes.recaptcha_token = this.filters.recaptcha_token; + } + if (this.filters.user) { params.data.attributes.staff_id = this.filters.user; }