Skip to content

Commit 256f928

Browse files
authored
New Components - acuity_scheduling (#17165)
* new components * pnpm-lock.yaml
1 parent aa872c8 commit 256f928

File tree

13 files changed

+579
-10
lines changed

13 files changed

+579
-10
lines changed

components/acuity_scheduling/actions/add-blocked-off-time/add-blocked-off-time.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "acuity_scheduling-add-blocked-off-time",
55
name: "Add Blocked Off Time",
66
description: "Blocks a specific time slot on your schedule to prevent the scheduling of any appointments during this particular time range. [See the documentation](https://developers.acuityscheduling.com/reference/post-blocks)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
acuityScheduling,
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
import acuityScheduling from "../../acuity_scheduling.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
key: "acuity_scheduling-book-appointment",
6+
name: "Book Appointment",
7+
description: "Book an appointment. [See the documentation](https://developers.acuityscheduling.com/reference/post-appointments)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
acuityScheduling,
12+
datetime: {
13+
type: "string",
14+
label: "Datetime",
15+
description: "Date and time of the appointment. E.g. `2016-02-03T14:00:00-0800`",
16+
},
17+
appointmentTypeId: {
18+
propDefinition: [
19+
acuityScheduling,
20+
"appointmentTypeId",
21+
],
22+
description: "The type of appointment to book",
23+
},
24+
firstName: {
25+
type: "string",
26+
label: "First Name",
27+
description: "First name of the client",
28+
},
29+
lastName: {
30+
type: "string",
31+
label: "Last Name",
32+
description: "Last name of the client",
33+
},
34+
isAdmin: {
35+
type: "boolean",
36+
label: "Is Admin",
37+
description: "By default appointments are created as if they are being booked by a client. Booking as an admin disables availability and attribute validations, and allows setting the notes attribute. This also requires a valid `calendarID` to be included in the request.",
38+
optional: true,
39+
},
40+
email: {
41+
type: "string",
42+
label: "Email",
43+
description: "Email address of the client",
44+
optional: true,
45+
},
46+
calendarId: {
47+
propDefinition: [
48+
acuityScheduling,
49+
"calendarId",
50+
],
51+
description: "The calendar to book the appointment on. If not provided we'll try to find an available calendar automatically.",
52+
optional: true,
53+
},
54+
phone: {
55+
type: "string",
56+
label: "Phone",
57+
description: "Phone number of the client",
58+
optional: true,
59+
},
60+
timezone: {
61+
propDefinition: [
62+
acuityScheduling,
63+
"timezone",
64+
],
65+
},
66+
certificate: {
67+
propDefinition: [
68+
acuityScheduling,
69+
"certificate",
70+
(c) => ({
71+
appointmentTypeId: c.appointmentTypeId,
72+
}),
73+
],
74+
optional: true,
75+
},
76+
notes: {
77+
type: "string",
78+
label: "Notes",
79+
description: "Notes to be added to the appointment. Settable when booking as an admin.",
80+
optional: true,
81+
},
82+
labelId: {
83+
propDefinition: [
84+
acuityScheduling,
85+
"labelId",
86+
],
87+
optional: true,
88+
},
89+
smsOptin: {
90+
type: "boolean",
91+
label: "SMS Opt-in",
92+
description: "Indicates whether the client has explicitly given their permission to receive SMS messages. This parameter is only applicable to Appointments with an Appointment Type that requires Opt In and can be omitted (and will be ignored) for all other Appointments. If omitted or set to false on an applicable Appointment, an SMS reminder will not be sent. For more information on SMS Opt In settings for Appointment Types, see the article in our [Knowledge Base](https://support.squarespace.com/hc/en-us/articles/360040093611).",
93+
optional: true,
94+
},
95+
formId: {
96+
propDefinition: [
97+
acuityScheduling,
98+
"formId",
99+
],
100+
optional: true,
101+
reloadProps: true,
102+
},
103+
},
104+
async additionalProps() {
105+
const props = {};
106+
if (!this.formId) {
107+
return props;
108+
}
109+
const forms = await this.acuityScheduling.listForms();
110+
const form = forms.find((f) => f.id === this.formId);
111+
const { fields } = form;
112+
for (const field of fields) {
113+
props[`${field.id}`] = {
114+
type: "string",
115+
label: field.name,
116+
};
117+
if (field.options) {
118+
props[`${field.id}`].options = field.options;
119+
}
120+
}
121+
return props;
122+
},
123+
async run({ $ }) {
124+
const {
125+
acuityScheduling,
126+
datetime,
127+
appointmentTypeId,
128+
firstName,
129+
lastName,
130+
isAdmin,
131+
email,
132+
calendarId,
133+
phone,
134+
timezone,
135+
certificate,
136+
notes,
137+
labelId,
138+
smsOptin,
139+
formId,
140+
...fieldValues
141+
} = this;
142+
143+
if (isAdmin && !calendarId) {
144+
throw new ConfigurationError("`calendarID` is required when booking as an admin");
145+
}
146+
147+
if (!isAdmin && !email) {
148+
throw new ConfigurationError("`email` is required when booking as a client");
149+
}
150+
151+
if (!isAdmin && notes) {
152+
throw new ConfigurationError("`notes` is only available when booking as an admin");
153+
}
154+
155+
if (formId && !appointmentTypeId) {
156+
throw new ConfigurationError("`formId` is required when booking an appointment with a form");
157+
}
158+
159+
const fields = [];
160+
if (Object.keys(fieldValues).length > 0) {
161+
for (const [
162+
fieldId,
163+
value,
164+
] of Object.entries(fieldValues)) {
165+
fields.push({
166+
id: fieldId,
167+
value,
168+
});
169+
}
170+
}
171+
172+
const response = await acuityScheduling.createAppointment({
173+
$,
174+
params: {
175+
admin: isAdmin,
176+
},
177+
data: {
178+
datetime,
179+
appointmentTypeID: appointmentTypeId,
180+
firstName,
181+
lastName,
182+
email,
183+
calendarID: calendarId,
184+
phone,
185+
timezone,
186+
certificate,
187+
notes,
188+
labels: labelId
189+
? [
190+
{
191+
id: labelId,
192+
},
193+
]
194+
: undefined,
195+
smsOptin,
196+
fields,
197+
},
198+
});
199+
$.export("$summary", `Successfully booked appointment with ID: ${response.id}`);
200+
return response;
201+
},
202+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import acuityScheduling from "../../acuity_scheduling.app.mjs";
2+
3+
export default {
4+
key: "acuity_scheduling-check-availability-times",
5+
name: "Check Availability Times",
6+
description: "Validate available times for an appointment. [See the documentation](https://developers.acuityscheduling.com/reference/availability-check-times)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
acuityScheduling,
11+
date: {
12+
type: "string",
13+
label: "Date",
14+
description: "Date to check availability for. E.g. `2016-02-03T14:00:00-0800`",
15+
},
16+
appointmentTypeId: {
17+
propDefinition: [
18+
acuityScheduling,
19+
"appointmentTypeId",
20+
],
21+
description: "Appointment type to check availability time for",
22+
},
23+
calendarId: {
24+
propDefinition: [
25+
acuityScheduling,
26+
"calendarId",
27+
],
28+
description: "Calendar to check availability time for",
29+
optional: true,
30+
},
31+
},
32+
async run({ $ }) {
33+
const response = await this.acuityScheduling.checkAvailabilityTimes({
34+
$,
35+
data: {
36+
datetime: this.date,
37+
appointmentTypeID: this.appointmentTypeId,
38+
calendarID: this.calendarId,
39+
},
40+
});
41+
$.export("$summary", `Successfully checked availability for ${this.date}`);
42+
return response;
43+
},
44+
};

components/acuity_scheduling/actions/find-appointments-by-client-info/find-appointments-by-client-info.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "acuity_scheduling-find-appointments-by-client-info",
66
name: "Find Appointments by Client Info",
77
description: "Retrieves existing appointments using the client's information, allowing you to track all the appointments associated with a specific client. [See the documentation](https://developers.acuityscheduling.com/reference/get-appointments)",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
acuityScheduling,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import acuityScheduling from "../../acuity_scheduling.app.mjs";
2+
3+
export default {
4+
key: "acuity_scheduling-get-appointment-types",
5+
name: "Get Appointment Types",
6+
description: "Return a list ofappointment types. [See the documentation](https://developers.acuityscheduling.com/reference/appointment-types)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
acuityScheduling,
11+
includeDeleted: {
12+
type: "boolean",
13+
label: "Include Deleted",
14+
description: "Include deleted appointment types in the response",
15+
optional: true,
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.acuityScheduling.listAppointmentTypes({
20+
$,
21+
params: {
22+
includeDeleted: this.includeDeleted,
23+
},
24+
});
25+
$.export("$summary", `Successfully retrieved ${response.length} appointment types`);
26+
return response;
27+
},
28+
};

0 commit comments

Comments
 (0)