-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New Components - acuity_scheduling #17165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
202 changes: 202 additions & 0 deletions
202
components/acuity_scheduling/actions/book-appointment/book-appointment.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
import acuityScheduling from "../../acuity_scheduling.app.mjs"; | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
|
||
export default { | ||
key: "acuity_scheduling-book-appointment", | ||
name: "Book Appointment", | ||
description: "Book an appointment. [See the documentation](https://developers.acuityscheduling.com/reference/post-appointments)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
acuityScheduling, | ||
datetime: { | ||
type: "string", | ||
label: "Datetime", | ||
description: "Date and time of the appointment. E.g. `2016-02-03T14:00:00-0800`", | ||
}, | ||
appointmentTypeId: { | ||
propDefinition: [ | ||
acuityScheduling, | ||
"appointmentTypeId", | ||
], | ||
description: "The type of appointment to book", | ||
}, | ||
firstName: { | ||
type: "string", | ||
label: "First Name", | ||
description: "First name of the client", | ||
}, | ||
lastName: { | ||
type: "string", | ||
label: "Last Name", | ||
description: "Last name of the client", | ||
}, | ||
isAdmin: { | ||
type: "boolean", | ||
label: "Is Admin", | ||
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.", | ||
optional: true, | ||
}, | ||
email: { | ||
type: "string", | ||
label: "Email", | ||
description: "Email address of the client", | ||
optional: true, | ||
}, | ||
calendarId: { | ||
propDefinition: [ | ||
acuityScheduling, | ||
"calendarId", | ||
], | ||
description: "The calendar to book the appointment on. If not provided we'll try to find an available calendar automatically.", | ||
optional: true, | ||
}, | ||
phone: { | ||
type: "string", | ||
label: "Phone", | ||
description: "Phone number of the client", | ||
optional: true, | ||
}, | ||
timezone: { | ||
propDefinition: [ | ||
acuityScheduling, | ||
"timezone", | ||
], | ||
}, | ||
certificate: { | ||
propDefinition: [ | ||
acuityScheduling, | ||
"certificate", | ||
(c) => ({ | ||
appointmentTypeId: c.appointmentTypeId, | ||
}), | ||
], | ||
optional: true, | ||
}, | ||
notes: { | ||
type: "string", | ||
label: "Notes", | ||
description: "Notes to be added to the appointment. Settable when booking as an admin.", | ||
optional: true, | ||
}, | ||
labelId: { | ||
propDefinition: [ | ||
acuityScheduling, | ||
"labelId", | ||
], | ||
optional: true, | ||
}, | ||
smsOptin: { | ||
type: "boolean", | ||
label: "SMS Opt-in", | ||
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).", | ||
optional: true, | ||
}, | ||
formId: { | ||
propDefinition: [ | ||
acuityScheduling, | ||
"formId", | ||
], | ||
optional: true, | ||
reloadProps: true, | ||
}, | ||
}, | ||
async additionalProps() { | ||
const props = {}; | ||
if (!this.formId) { | ||
return props; | ||
} | ||
const forms = await this.acuityScheduling.listForms(); | ||
const form = forms.find((f) => f.id === this.formId); | ||
const { fields } = form; | ||
for (const field of fields) { | ||
props[`${field.id}`] = { | ||
type: "string", | ||
label: field.name, | ||
}; | ||
if (field.options) { | ||
props[`${field.id}`].options = field.options; | ||
} | ||
} | ||
return props; | ||
}, | ||
async run({ $ }) { | ||
const { | ||
acuityScheduling, | ||
datetime, | ||
appointmentTypeId, | ||
firstName, | ||
lastName, | ||
isAdmin, | ||
email, | ||
calendarId, | ||
phone, | ||
timezone, | ||
certificate, | ||
notes, | ||
labelId, | ||
smsOptin, | ||
formId, | ||
...fieldValues | ||
} = this; | ||
|
||
if (isAdmin && !calendarId) { | ||
throw new ConfigurationError("`calendarID` is required when booking as an admin"); | ||
} | ||
|
||
if (!isAdmin && !email) { | ||
throw new ConfigurationError("`email` is required when booking as a client"); | ||
} | ||
|
||
if (!isAdmin && notes) { | ||
throw new ConfigurationError("`notes` is only available when booking as an admin"); | ||
} | ||
|
||
if (formId && !appointmentTypeId) { | ||
throw new ConfigurationError("`formId` is required when booking an appointment with a form"); | ||
} | ||
|
||
const fields = []; | ||
if (Object.keys(fieldValues).length > 0) { | ||
for (const [ | ||
fieldId, | ||
value, | ||
] of Object.entries(fieldValues)) { | ||
fields.push({ | ||
id: fieldId, | ||
value, | ||
}); | ||
} | ||
} | ||
|
||
const response = await acuityScheduling.createAppointment({ | ||
$, | ||
params: { | ||
admin: isAdmin, | ||
}, | ||
data: { | ||
datetime, | ||
appointmentTypeID: appointmentTypeId, | ||
firstName, | ||
lastName, | ||
email, | ||
calendarID: calendarId, | ||
phone, | ||
timezone, | ||
certificate, | ||
notes, | ||
labels: labelId | ||
? [ | ||
{ | ||
id: labelId, | ||
}, | ||
] | ||
: undefined, | ||
smsOptin, | ||
fields, | ||
}, | ||
}); | ||
$.export("$summary", `Successfully booked appointment with ID: ${response.id}`); | ||
return response; | ||
}, | ||
}; |
44 changes: 44 additions & 0 deletions
44
components/acuity_scheduling/actions/check-availability-times/check-availability-times.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import acuityScheduling from "../../acuity_scheduling.app.mjs"; | ||
|
||
export default { | ||
key: "acuity_scheduling-check-availability-times", | ||
name: "Check Availability Times", | ||
description: "Validate available times for an appointment. [See the documentation](https://developers.acuityscheduling.com/reference/availability-check-times)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
acuityScheduling, | ||
date: { | ||
type: "string", | ||
label: "Date", | ||
description: "Date to check availability for. E.g. `2016-02-03T14:00:00-0800`", | ||
}, | ||
appointmentTypeId: { | ||
propDefinition: [ | ||
acuityScheduling, | ||
"appointmentTypeId", | ||
], | ||
description: "Appointment type to check availability time for", | ||
}, | ||
calendarId: { | ||
propDefinition: [ | ||
acuityScheduling, | ||
"calendarId", | ||
], | ||
description: "Calendar to check availability time for", | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.acuityScheduling.checkAvailabilityTimes({ | ||
$, | ||
data: { | ||
datetime: this.date, | ||
appointmentTypeID: this.appointmentTypeId, | ||
calendarID: this.calendarId, | ||
}, | ||
}); | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$.export("$summary", `Successfully checked availability for ${this.date}`); | ||
return response; | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
components/acuity_scheduling/actions/get-appointment-types/get-appointment-types.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import acuityScheduling from "../../acuity_scheduling.app.mjs"; | ||
|
||
export default { | ||
key: "acuity_scheduling-get-appointment-types", | ||
name: "Get Appointment Types", | ||
description: "Return a list ofappointment types. [See the documentation](https://developers.acuityscheduling.com/reference/appointment-types)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
acuityScheduling, | ||
includeDeleted: { | ||
type: "boolean", | ||
label: "Include Deleted", | ||
description: "Include deleted appointment types in the response", | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.acuityScheduling.listAppointmentTypes({ | ||
$, | ||
params: { | ||
includeDeleted: this.includeDeleted, | ||
}, | ||
}); | ||
$.export("$summary", `Successfully retrieved ${response.length} appointment types`); | ||
return response; | ||
}, | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.