diff --git a/components/booking_experts/actions/add-guest-to-reservation/add-guest-to-reservation.mjs b/components/booking_experts/actions/add-guest-to-reservation/add-guest-to-reservation.mjs index a02d93442f7a6..e4b14404f43be 100644 --- a/components/booking_experts/actions/add-guest-to-reservation/add-guest-to-reservation.mjs +++ b/components/booking_experts/actions/add-guest-to-reservation/add-guest-to-reservation.mjs @@ -3,8 +3,8 @@ import bookingExperts from "../../booking_experts.app.mjs"; export default { key: "booking_experts-add-guest-to-reservation", name: "Add Guest to Reservation", - description: "Add a guest to a reservation.. [See the documentation](https://developers.bookingexperts.com/reference/administration-reservation-guests-create)", - version: "0.0.2", + description: "Add a guest to a reservation. [See the documentation](https://developers.bookingexperts.com/reference/administration-reservation-guests-create)", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, @@ -77,6 +77,7 @@ export default { }, async run({ $ }) { const { data } = await this.bookingExperts.addGuestToReservation({ + $, administrationId: this.administrationId, reservationId: this.reservationId, data: { diff --git a/components/booking_experts/actions/create-agenda-period/create-agenda-period.mjs b/components/booking_experts/actions/create-agenda-period/create-agenda-period.mjs index 9a75220c44586..51008e23216a3 100644 --- a/components/booking_experts/actions/create-agenda-period/create-agenda-period.mjs +++ b/components/booking_experts/actions/create-agenda-period/create-agenda-period.mjs @@ -4,7 +4,7 @@ export default { key: "booking_experts-create-agenda-period", name: "Create Agenda Period", description: "Creates a new agenda period. [See the documentation](https://developers.bookingexperts.com/reference/administration-maintenance-agenda-periods-create)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/booking_experts/actions/delete-guest/delete-guest.mjs b/components/booking_experts/actions/delete-guest/delete-guest.mjs new file mode 100644 index 0000000000000..78edb7f3b0b8a --- /dev/null +++ b/components/booking_experts/actions/delete-guest/delete-guest.mjs @@ -0,0 +1,60 @@ +import bookingExperts from "../../booking_experts.app.mjs"; + +export default { + key: "booking_experts-delete-guest", + name: "Delete Guest", + description: "Delete a guest for a reservation. [See the documentation](https://developers.bookingexperts.com/reference/administration-reservation-guests-delete)", + version: "0.0.1", + annotations: { + destructiveHint: true, + openWorldHint: true, + readOnlyHint: false, + }, + type: "action", + props: { + bookingExperts, + administrationId: { + propDefinition: [ + bookingExperts, + "administrationId", + ], + }, + reservationId: { + propDefinition: [ + bookingExperts, + "reservationId", + ({ administrationId }) => ({ + administrationId, + }), + ], + }, + info: { + type: "alert", + alertType: "warning", + content: "**The API will only list guests created through the Booking Experts API.**", + }, + guestId: { + propDefinition: [ + bookingExperts, + "guestId", + ({ + administrationId, reservationId, + }) => ({ + administrationId, + reservationId, + }), + ], + }, + }, + async run({ $ }) { + const response = await this.bookingExperts.deleteGuest({ + $, + administrationId: this.administrationId, + reservationId: this.reservationId, + guestId: this.guestId, + }); + + $.export("$summary", `Successfully deleted guest with ID ${this.guestId}`); + return response; + }, +}; diff --git a/components/booking_experts/actions/get-booking/get-booking.mjs b/components/booking_experts/actions/get-booking/get-booking.mjs new file mode 100644 index 0000000000000..a393cdce7cbbf --- /dev/null +++ b/components/booking_experts/actions/get-booking/get-booking.mjs @@ -0,0 +1,41 @@ +import bookingExperts from "../../booking_experts.app.mjs"; + +export default { + key: "booking_experts-get-booking", + name: "Get Booking", + description: "Returns a booking. [See the documentation](https://developers.bookingexperts.com/reference/administration-bookings-show)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: false, + }, + type: "action", + props: { + bookingExperts, + administrationId: { + propDefinition: [ + bookingExperts, + "administrationId", + ], + }, + bookingId: { + propDefinition: [ + bookingExperts, + "bookingId", + ({ administrationId }) => ({ + administrationId, + }), + ], + }, + }, + async run({ $ }) { + const { data } = await this.bookingExperts.getBooking({ + $, + administrationId: this.administrationId, + bookingId: this.bookingId, + }); + $.export("$summary", `Successfully retrieved booking with ID ${this.bookingId}`); + return data; + }, +}; diff --git a/components/booking_experts/actions/get-complex-prices/get-complex-prices.mjs b/components/booking_experts/actions/get-complex-prices/get-complex-prices.mjs index 7ccd8883d8e38..135cfd368ab9a 100644 --- a/components/booking_experts/actions/get-complex-prices/get-complex-prices.mjs +++ b/components/booking_experts/actions/get-complex-prices/get-complex-prices.mjs @@ -4,7 +4,7 @@ export default { key: "booking_experts-get-complex-prices", name: "Get Complex Prices", description: "Returns all complex prices of a master price list. [See the documentation](https://developers.bookingexperts.com/reference/administration-masterpricelist-complexprices-index)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/booking_experts/actions/list-availabilities/list-availabilities.mjs b/components/booking_experts/actions/list-availabilities/list-availabilities.mjs new file mode 100644 index 0000000000000..234fbdd0376e7 --- /dev/null +++ b/components/booking_experts/actions/list-availabilities/list-availabilities.mjs @@ -0,0 +1,29 @@ +import bookingExperts from "../../booking_experts.app.mjs"; + +export default { + key: "booking_experts-list-availabilities", + name: "List Availabilities", + description: "List availabilities of a channel you have access to. [See the documentation](https://developers.bookingexperts.com/reference/availabilities-index)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + bookingExperts, + info: { + type: "alert", + alertType: "warning", + content: "**You must have at least one channel created through the Booking Experts API.**", + }, + }, + async run({ $ }) { + const { data } = await this.bookingExperts.listAvailabilities({ + $, + }); + $.export("$summary", `Found ${data.length} availabilities`); + return data; + }, +}; diff --git a/components/booking_experts/actions/list-bookings/list-bookings.mjs b/components/booking_experts/actions/list-bookings/list-bookings.mjs index 7b928cf2ebedc..f812f01d24982 100644 --- a/components/booking_experts/actions/list-bookings/list-bookings.mjs +++ b/components/booking_experts/actions/list-bookings/list-bookings.mjs @@ -4,7 +4,7 @@ export default { key: "booking_experts-list-bookings", name: "List Bookings", description: "Returns a list of bookings for an administration. [See the documentation](https://developers.bookingexperts.com/reference/administration-bookings-index)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, @@ -29,10 +29,10 @@ export default { ], description: "Filter by owner", }, - channelId: { + administrationChannelId: { propDefinition: [ bookingExperts, - "channelId", + "administrationChannelId", (c) => ({ administrationId: c.administrationId, }), @@ -69,7 +69,7 @@ export default { administrationId: this.administrationId, params: { "filter[owner]": this.ownerId, - "filter[channel]": this.channelId, + "filter[channel]": this.listAdministrationChannels, "filter[reservations]": this.reservationId, "filter[created_at]": this.createdAt, "filter[updated_at]": this.updatedAt, diff --git a/components/booking_experts/actions/list-inventory-objects/list-inventory-objects.mjs b/components/booking_experts/actions/list-inventory-objects/list-inventory-objects.mjs index 88db8d769abda..593228c3960dd 100644 --- a/components/booking_experts/actions/list-inventory-objects/list-inventory-objects.mjs +++ b/components/booking_experts/actions/list-inventory-objects/list-inventory-objects.mjs @@ -4,7 +4,7 @@ export default { key: "booking_experts-list-inventory-objects", name: "List Inventory Objects", description: "Returns inventory objects of the administration. [See the documentation](https://developers.bookingexperts.com/reference/administration-inventoryobjects-index)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, @@ -46,6 +46,7 @@ export default { }, async run({ $ }) { const { data } = await this.bookingExperts.listInventoryObjects({ + $, administrationId: this.administrationId, params: { "filter[name]": this.name, diff --git a/components/booking_experts/actions/list-rentabletype-availabilities/list-rentabletype-availabilities.mjs b/components/booking_experts/actions/list-rentabletype-availabilities/list-rentabletype-availabilities.mjs new file mode 100644 index 0000000000000..3888249cf33fd --- /dev/null +++ b/components/booking_experts/actions/list-rentabletype-availabilities/list-rentabletype-availabilities.mjs @@ -0,0 +1,69 @@ +import { ConfigurationError } from "@pipedream/platform"; +import bookingExperts from "../../booking_experts.app.mjs"; + +export default { + key: "booking_experts-list-rentabletype-availabilities", + name: "List RentableType Availabilities", + description: "List availabilities of a RentableType you have access to. [See the documentation](https://developers.bookingexperts.com/reference/channel-rentabletype-availabilities-index)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + bookingExperts, + info: { + type: "alert", + alertType: "warning", + content: "**The API will only list channels created through the Booking Experts API.**", + }, + channelId: { + propDefinition: [ + bookingExperts, + "channelId", + ], + optional: false, + }, + rentableTypeId: { + propDefinition: [ + bookingExperts, + "rentableTypeId", + ({ channelId }) => ({ + channelId, + }), + ], + }, + startDate: { + type: "string", + label: "Start Date", + description: "The start date of the availability. Yields availability for the given date range. Format: `YYYY-MM-DD`", + optional: true, + }, + endDate: { + type: "string", + label: "End Date", + description: "The end date of the availability. Will be capped to 2 years in the future. Max LOS is capped to 30. Format: `YYYY-MM-DD`", + optional: true, + }, + }, + async run({ $ }) { + if ((!this.startDate && this.endDate) || (this.startDate && !this.endDate)) { + throw new ConfigurationError("You should provide both the start and end date parameters."); + } + const { data } = await this.bookingExperts.listRentableTypeAvailabilities({ + $, + channelId: this.channelId, + rentableTypeId: this.rentableTypeId, + params: { + ...(this.startDate && this.endDate + && { + "date_range": `${this.startDate}..${this.endDate}`, + }), + }, + }); + $.export("$summary", `Found ${data.length} rentable type availabilities`); + return data; + }, +}; diff --git a/components/booking_experts/actions/search-contacts/search-contacts.mjs b/components/booking_experts/actions/search-contacts/search-contacts.mjs index 5fc871896a8a1..5f5da5593d547 100644 --- a/components/booking_experts/actions/search-contacts/search-contacts.mjs +++ b/components/booking_experts/actions/search-contacts/search-contacts.mjs @@ -1,11 +1,11 @@ -import bookingExperts from "../../booking_experts.app.mjs"; import { ConfigurationError } from "@pipedream/platform"; +import bookingExperts from "../../booking_experts.app.mjs"; export default { key: "booking_experts-search-contacts", name: "Search Contacts", description: "Search for contacts by email or phone. [See the documentation](https://developers.bookingexperts.com/reference/contact-search-first)", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, @@ -34,6 +34,7 @@ export default { try { const { data } = await this.bookingExperts.searchContacts({ + $, params: { email: this.email, phone: this.phone, diff --git a/components/booking_experts/actions/update-guest/update-guest.mjs b/components/booking_experts/actions/update-guest/update-guest.mjs new file mode 100644 index 0000000000000..b3b24908f19c6 --- /dev/null +++ b/components/booking_experts/actions/update-guest/update-guest.mjs @@ -0,0 +1,123 @@ +import bookingExperts from "../../booking_experts.app.mjs"; + +export default { + key: "booking_experts-update-guest", + name: "Update Guest", + description: "Update a guest for a reservation. [See the documentation](https://developers.bookingexperts.com/reference/administration-reservation-guests-update)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: false, + }, + type: "action", + props: { + bookingExperts, + administrationId: { + propDefinition: [ + bookingExperts, + "administrationId", + ], + }, + reservationId: { + propDefinition: [ + bookingExperts, + "reservationId", + ({ administrationId }) => ({ + administrationId, + }), + ], + }, + info: { + type: "alert", + alertType: "warning", + content: "**The API will only list guests created through the Booking Experts API.**", + }, + guestId: { + propDefinition: [ + bookingExperts, + "guestId", + ({ + administrationId, reservationId, + }) => ({ + administrationId, + reservationId, + }), + ], + }, + firstName: { + type: "string", + label: "First Name", + description: "The first name of the guest", + optional: true, + }, + lastName: { + type: "string", + label: "Last Name", + description: "The last name of the guest", + optional: true, + }, + email: { + type: "string", + label: "Email", + description: "The email of the guest", + optional: true, + }, + phone: { + type: "string", + label: "Phone", + description: "The phone number of the guest", + optional: true, + }, + address: { + type: "string", + label: "Address", + description: "The street address of the guest", + optional: true, + }, + city: { + type: "string", + label: "City", + description: "The city of the guest", + optional: true, + }, + postalCode: { + type: "string", + label: "Postal Code", + description: "The postal code of the guest", + optional: true, + }, + countryCode: { + type: "string", + label: "Country Code", + description: "The country code of the guest", + optional: true, + }, + }, + async run({ $ }) { + const { data } = await this.bookingExperts.updateGuest({ + $, + administrationId: this.administrationId, + reservationId: this.reservationId, + guestId: this.guestId, + data: { + data: { + id: this.guestId, + type: "guest", + attributes: { + first_name: this.firstName, + last_name: this.lastName, + email: this.email, + phone: this.phone, + address: this.address, + city: this.city, + postal_code: this.postalCode, + country_code: this.countryCode, + }, + }, + }, + }); + $.export("$summary", "Guest updated"); + return data; + }, +}; diff --git a/components/booking_experts/booking_experts.app.mjs b/components/booking_experts/booking_experts.app.mjs index 8ac750fa35e20..d46bc8593b00a 100644 --- a/components/booking_experts/booking_experts.app.mjs +++ b/components/booking_experts/booking_experts.app.mjs @@ -44,15 +44,15 @@ export default { })) || []; }, }, - channelId: { + administrationChannelId: { type: "string", - label: "Channel ID", - description: "The ID of a channel", + label: "Administration Channel ID", + description: "The ID of a channel in the administration", optional: true, async options({ page, administrationId, }) { - const { data } = await this.listChannels({ + const { data } = await this.listAdministrationChannels({ administrationId, params: { "page[number]": page + 1, @@ -66,6 +66,66 @@ export default { })) || []; }, }, + bookingId: { + type: "string", + label: "Booking ID", + description: "The ID of a booking", + async options({ + page, administrationId, + }) { + const { data } = await this.listBookings({ + administrationId, + params: { + "page[number]": page + 1, + }, + }); + return data?.map(({ + id, attributes, + }) => ({ + label: attributes.booking_nr, + value: id, + })) || []; + }, + }, + channelId: { + type: "string", + label: "Channel ID", + description: "The ID of a channel", + async options({ page }) { + const { data } = await this.listChannels({ + params: { + "page[number]": page + 1, + }, + }); + return data?.map(({ + id, attributes, + }) => ({ + label: attributes.name, + value: id, + })) || []; + }, + }, + rentableTypeId: { + type: "string", + label: "Rentable Type ID", + description: "The ID of a rentable type", + async options({ + page, channelId, + }) { + const { data } = await this.listRentableTypes({ + channelId, + params: { + "page[number]": page + 1, + }, + }); + return data?.map(({ + id, attributes, + }) => ({ + label: attributes.name, + value: id, + })) || []; + }, + }, reservationId: { type: "string", label: "Reservation ID", @@ -82,7 +142,33 @@ export default { return data?.map(({ id, attributes, }) => ({ - label: `${attributes.start_date} - ${attributes.end_date}`, + label: `(${attributes.booking_nr}) ${attributes.start_date} - ${attributes.end_date}`, + value: id, + })) || []; + }, + }, + guestId: { + type: "string", + label: "Guest ID", + description: "The ID of a guest", + async options({ + page, administrationId, reservationId, + }) { + const { data } = await this.listGuests({ + administrationId, + reservationId, + params: { + "page[number]": page + 1, + }, + }); + return data?.map(({ + id, attributes: { + first_name, last_name, email, + }, + }) => ({ + label: `${first_name} ${last_name}${email + ? ` (${email})` + : ""}`, value: id, })) || []; }, @@ -196,6 +282,14 @@ export default { ...opts, }); }, + getBooking({ + administrationId, bookingId, ...opts + }) { + return this._makeRequest({ + path: `/administrations/${administrationId}/bookings/${bookingId}`, + ...opts, + }); + }, listBookings({ administrationId, ...opts }) { @@ -212,7 +306,7 @@ export default { ...opts, }); }, - listChannels({ + listAdministrationChannels({ administrationId, ...opts }) { return this._makeRequest({ @@ -220,6 +314,42 @@ export default { ...opts, }); }, + listAvailabilities(opts = {}) { + return this._makeRequest({ + path: "/availabilities", + ...opts, + }); + }, + listChannels(opts = {}) { + return this._makeRequest({ + path: "/channels", + ...opts, + }); + }, + listGuests({ + administrationId, reservationId, ...opts + }) { + return this._makeRequest({ + path: `/administrations/${administrationId}/reservations/${reservationId}/guests`, + ...opts, + }); + }, + listRentableTypes({ + channelId, ...opts + }) { + return this._makeRequest({ + path: `/channels/${channelId}/rentable_types`, + ...opts, + }); + }, + listRentableTypeAvailabilities({ + channelId, rentableTypeId, ...opts + }) { + return this._makeRequest({ + path: `/channels/${channelId}/rentable_types/${rentableTypeId}/availabilities`, + ...opts, + }); + }, listReservations({ administrationId, ...opts }) { @@ -276,5 +406,23 @@ export default { ...opts, }); }, + updateGuest({ + administrationId, reservationId, guestId, ...opts + }) { + return this._makeRequest({ + path: `/administrations/${administrationId}/reservations/${reservationId}/guests/${guestId}`, + method: "PATCH", + ...opts, + }); + }, + deleteGuest({ + administrationId, reservationId, guestId, ...opts + }) { + return this._makeRequest({ + path: `/administrations/${administrationId}/reservations/${reservationId}/guests/${guestId}`, + method: "DELETE", + ...opts, + }); + }, }, }; diff --git a/components/booking_experts/package.json b/components/booking_experts/package.json index f636fb6f1ef6e..446bb0d1b60ae 100644 --- a/components/booking_experts/package.json +++ b/components/booking_experts/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/booking_experts", - "version": "0.1.0", + "version": "0.2.0", "description": "Pipedream Booking Experts Components", "main": "booking_experts.app.mjs", "keywords": [ diff --git a/components/booking_experts/sources/booking-updated/booking-updated.mjs b/components/booking_experts/sources/booking-updated/booking-updated.mjs index 0fe880729c969..73a0f3610bdb3 100644 --- a/components/booking_experts/sources/booking-updated/booking-updated.mjs +++ b/components/booking_experts/sources/booking-updated/booking-updated.mjs @@ -5,7 +5,7 @@ export default { key: "booking_experts-booking-updated", name: "Booking Updated", description: "Emit new event for each booking updated. [See the documentation](https://developers.bookingexperts.com/reference/administration-bookings-index)", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", props: { diff --git a/components/booking_experts/sources/inventory-object-updated/inventory-object-updated.mjs b/components/booking_experts/sources/inventory-object-updated/inventory-object-updated.mjs index 27f12221f6a62..6485be1e1d0f6 100644 --- a/components/booking_experts/sources/inventory-object-updated/inventory-object-updated.mjs +++ b/components/booking_experts/sources/inventory-object-updated/inventory-object-updated.mjs @@ -5,7 +5,7 @@ export default { key: "booking_experts-inventory-object-updated", name: "Inventory Object Updated", description: "Emit new event when an inventory object is updated. [See the documentation](https://developers.bookingexperts.com/reference/administration-inventoryobjects-index)", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", props: { diff --git a/components/booking_experts/sources/new-booking-created/new-booking-created.mjs b/components/booking_experts/sources/new-booking-created/new-booking-created.mjs index 41b124bfbf2a7..a0bd7d7378f50 100644 --- a/components/booking_experts/sources/new-booking-created/new-booking-created.mjs +++ b/components/booking_experts/sources/new-booking-created/new-booking-created.mjs @@ -5,7 +5,7 @@ export default { key: "booking_experts-new-booking-created", name: "New Booking Created", description: "Emit new event for each new booking created. [See the documentation](https://developers.bookingexperts.com/reference/administration-bookings-index)", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", props: { diff --git a/components/booking_experts/sources/new-inventory-object-created/new-inventory-object-created.mjs b/components/booking_experts/sources/new-inventory-object-created/new-inventory-object-created.mjs index 32f2690021052..e829c6ed9a664 100644 --- a/components/booking_experts/sources/new-inventory-object-created/new-inventory-object-created.mjs +++ b/components/booking_experts/sources/new-inventory-object-created/new-inventory-object-created.mjs @@ -5,7 +5,7 @@ export default { key: "booking_experts-new-inventory-object-created", name: "New Inventory Object Created", description: "Emit new event when a new inventory object is created. [See the documentation](https://developers.bookingexperts.com/reference/administration-inventoryobjects-index)", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", props: {