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 dd09800c83741..5787dca0cb3c1 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 @@ -5,7 +5,7 @@ export default { 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.7", + version: "0.0.8", annotations: { destructiveHint: false, openWorldHint: true, 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 9009c48c71e73..a9c9a9ce15719 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.6", + version: "0.0.7", 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 index 261d8298d0122..e0deda9c57d33 100644 --- a/components/booking_experts/actions/delete-guest/delete-guest.mjs +++ b/components/booking_experts/actions/delete-guest/delete-guest.mjs @@ -4,7 +4,7 @@ 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.4", + version: "0.0.5", annotations: { destructiveHint: true, openWorldHint: true, diff --git a/components/booking_experts/actions/get-amenity/get-amenity.mjs b/components/booking_experts/actions/get-amenity/get-amenity.mjs new file mode 100644 index 0000000000000..d24a3d59b7ad3 --- /dev/null +++ b/components/booking_experts/actions/get-amenity/get-amenity.mjs @@ -0,0 +1,32 @@ +import bookingExperts from "../../booking_experts.app.mjs"; + +export default { + key: "booking_experts-get-amenity", + name: "Get Amenity", + description: "Retrieve a single amenity by ID. [See the documentation](https://developers.bookingexperts.com/reference/amenities-show)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + bookingExperts, + amenityId: { + propDefinition: [ + bookingExperts, + "amenityId", + ], + }, + }, + async run({ $ }) { + const { data } = await this.bookingExperts.getAmenity({ + $, + amenityId: this.amenityId, + }); + + $.export("$summary", `Successfully retrieved amenity ${this.amenityId}`); + return data; + }, +}; diff --git a/components/booking_experts/actions/get-booking/get-booking.mjs b/components/booking_experts/actions/get-booking/get-booking.mjs index 866da7eb4bfa7..5d109a72332ed 100644 --- a/components/booking_experts/actions/get-booking/get-booking.mjs +++ b/components/booking_experts/actions/get-booking/get-booking.mjs @@ -4,7 +4,7 @@ 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.4", + version: "0.0.5", annotations: { destructiveHint: false, openWorldHint: true, 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 a61b0a951f36e..65e1bf5bdd147 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.6", + version: "0.0.7", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/booking_experts/actions/get-reservation/get-reservation.mjs b/components/booking_experts/actions/get-reservation/get-reservation.mjs index 58f0ede2bc1fe..47ee671f30680 100644 --- a/components/booking_experts/actions/get-reservation/get-reservation.mjs +++ b/components/booking_experts/actions/get-reservation/get-reservation.mjs @@ -4,7 +4,7 @@ export default { name: "Get Reservation", description: "Fetches a reservation by ID from Booking Experts. [See the documentation](https://developers.bookingexperts.com/reference/reservations-show)", key: "booking_experts-get-reservation", - version: "0.0.3", + version: "0.0.4", type: "action", annotations: { destructiveHint: false, diff --git a/components/booking_experts/actions/list-amenities/list-amenities.mjs b/components/booking_experts/actions/list-amenities/list-amenities.mjs new file mode 100644 index 0000000000000..bf81b88ad6d58 --- /dev/null +++ b/components/booking_experts/actions/list-amenities/list-amenities.mjs @@ -0,0 +1,108 @@ +import bookingExperts from "../../booking_experts.app.mjs"; + +export default { + key: "booking_experts-list-amenities", + name: "List Amenities", + description: "List amenities from BookingExperts. [See the documentation](https://developers.bookingexperts.com/reference/amenities-index)", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + type: "action", + props: { + bookingExperts, + page: { + propDefinition: [ + bookingExperts, + "page", + ], + }, + perPage: { + propDefinition: [ + bookingExperts, + "perPage", + ], + }, + sort: { + propDefinition: [ + bookingExperts, + "sort", + ], + }, + fields: { + propDefinition: [ + bookingExperts, + "fields", + ], + }, + include: { + propDefinition: [ + bookingExperts, + "include", + ], + }, + name: { + type: "string", + label: "Name", + description: "Filter by name", + optional: true, + }, + type: { + type: "string", + label: "Type", + description: "Filter by type", + optional: true, + }, + position: { + type: "string", + label: "Position", + description: "Filter by position", + optional: true, + }, + semanticAmenityType: { + type: "string", + label: "Semantic Amenity Type", + description: "Filter by semantic amenity type", + optional: true, + }, + amenityGroup: { + propDefinition: [ + bookingExperts, + "amenityGroupId", + ], + optional: true, + }, + amenityOptions: { + type: "string", + label: "Amenity Options", + description: "Filter on amenity_options. Specify a comma separated list of IDs to filter on.", + optional: true, + }, + }, + async run({ $ }) { + const params = { + "page[number]": this.page, + "page[size]": this.perPage, + "sort": this.sort, + "fields[amenity]": this.fields, + "include": this.include, + "filter[name]": this.name, + "filter[type]": this.type, + "filter[position]": this.position, + "filter[semantic_amenity_type]": this.semanticAmenityType, + "filter[amenity_group]": this.amenityGroup, + "filter[amenity_options]": this.amenityOptions, + }; + + const { data } = await this.bookingExperts.listAmenities({ + $, + params, + }); + + $.export("$summary", `Successfully retrieved ${data?.length ?? 0} amenities`); + + return data; + }, +}; diff --git a/components/booking_experts/actions/list-availabilities/list-availabilities.mjs b/components/booking_experts/actions/list-availabilities/list-availabilities.mjs index cd6b2f6c8de6f..10ede3ff78d1c 100644 --- a/components/booking_experts/actions/list-availabilities/list-availabilities.mjs +++ b/components/booking_experts/actions/list-availabilities/list-availabilities.mjs @@ -10,7 +10,7 @@ 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.4", + version: "0.0.5", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/booking_experts/actions/list-bookings/list-bookings.mjs b/components/booking_experts/actions/list-bookings/list-bookings.mjs index 4548afa8dad05..a9f91f55a71e4 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.6", + version: "0.0.7", annotations: { destructiveHint: false, openWorldHint: true, 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 b7e1abe159252..c4c471be149c9 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.6", + version: "0.0.7", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/booking_experts/actions/list-rentable-types/list-rentable-types.mjs b/components/booking_experts/actions/list-rentable-types/list-rentable-types.mjs new file mode 100644 index 0000000000000..be61153e9bd78 --- /dev/null +++ b/components/booking_experts/actions/list-rentable-types/list-rentable-types.mjs @@ -0,0 +1,78 @@ +import bookingExperts from "../../booking_experts.app.mjs"; +import { parseObject } from "../../common/utils.mjs"; + +export default { + key: "booking_experts-list-rentable-types", + name: "List Rentable Types", + description: "List all rentable types for a given administration. [See the documentation](https://developers.bookingexperts.com/reference/administration-rentabletypes-index)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + bookingExperts, + administrationId: { + propDefinition: [ + bookingExperts, + "administrationId", + ], + }, + page: { + propDefinition: [ + bookingExperts, + "page", + ], + }, + perPage: { + propDefinition: [ + bookingExperts, + "perPage", + ], + }, + sort: { + propDefinition: [ + bookingExperts, + "sort", + ], + }, + fields: { + propDefinition: [ + bookingExperts, + "fields", + ], + }, + include: { + propDefinition: [ + bookingExperts, + "include", + ], + }, + filters: { + type: "object", + label: "Filters", + description: "Additional query params to filter rentable types. Example: `filter[name]=My Rentable Type` [See the documentation](https://developers.bookingexperts.com/reference/administration-rentabletypes-index) for available filters.", + optional: true, + }, + }, + async run({ $ }) { + const { data } = await this.bookingExperts.listRentableTypesForAdmin({ + $, + administrationId: this.administrationId, + params: { + "page[number]": this.page, + "page[size]": this.perPage, + "sort": this.sort, + "fields[rentable_type]": this.fields, + "include": this.include, + ...parseObject(this.filters), + }, + }); + + $.export("$summary", `Successfully retrieved ${data?.length ?? 0} rentable types for Administration ${this.administrationId}`); + + return data; + }, +}; 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 index 597934c4c3f5f..b4ea134892688 100644 --- a/components/booking_experts/actions/list-rentabletype-availabilities/list-rentabletype-availabilities.mjs +++ b/components/booking_experts/actions/list-rentabletype-availabilities/list-rentabletype-availabilities.mjs @@ -7,7 +7,7 @@ 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.4", + version: "0.0.5", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/booking_experts/actions/list-reservations/list-reservations.mjs b/components/booking_experts/actions/list-reservations/list-reservations.mjs index 0d8c5d7a5d0e7..922a227cc8341 100644 --- a/components/booking_experts/actions/list-reservations/list-reservations.mjs +++ b/components/booking_experts/actions/list-reservations/list-reservations.mjs @@ -4,7 +4,7 @@ export default { name: "List Reservations", description: "Lists all reservations for the current organization from Booking Experts. [See the documentation](https://developers.bookingexperts.com/reference/reservations-index)", key: "booking_experts-list-reservations", - version: "0.0.3", + version: "0.0.4", type: "action", annotations: { destructiveHint: false, diff --git a/components/booking_experts/actions/search-contacts/search-contacts.mjs b/components/booking_experts/actions/search-contacts/search-contacts.mjs index f80059bfc18da..ffb7985875cc9 100644 --- a/components/booking_experts/actions/search-contacts/search-contacts.mjs +++ b/components/booking_experts/actions/search-contacts/search-contacts.mjs @@ -5,7 +5,7 @@ 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.6", + version: "0.0.7", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/booking_experts/actions/update-guest/update-guest.mjs b/components/booking_experts/actions/update-guest/update-guest.mjs index 8e04999bd4bab..0236579ac2284 100644 --- a/components/booking_experts/actions/update-guest/update-guest.mjs +++ b/components/booking_experts/actions/update-guest/update-guest.mjs @@ -5,7 +5,7 @@ export default { 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.5", + version: "0.0.6", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/booking_experts/booking_experts.app.mjs b/components/booking_experts/booking_experts.app.mjs index 6c2872e0d2dad..c911a73de6ebe 100644 --- a/components/booking_experts/booking_experts.app.mjs +++ b/components/booking_experts/booking_experts.app.mjs @@ -318,6 +318,24 @@ export default { max: 100, optional: true, }, + sort: { + type: "string", + label: "Sort", + description: "Specify a comma separated list of attributes to sort on. Prefix attribute with a - to sort in descending order", + optional: true, + }, + fields: { + type: "string", + label: "Fields", + description: "Specify a comma separated list of attributes to return", + optional: true, + }, + include: { + type: "string", + label: "Include", + description: "Specify a comma separated list of resources to include", + optional: true, + }, customerId: { type: "string", label: "Customer ID", @@ -347,6 +365,24 @@ export default { })) || []; }, }, + amenityGroupId: { + type: "string", + label: "Amenity Group ID", + description: "Filter by amenity group", + async options({ page }) { + const { data } = await this.listAmenityGroups({ + params: { + "page[number]": page + 1, + }, + }); + return data?.map(({ + id, attributes, + }) => ({ + label: attributes.name.en || id, + value: id, + })) || []; + }, + }, }, methods: { _baseUrl() { @@ -562,5 +598,27 @@ export default { ...opts, }); }, + getAmenity({ + amenityId, ...opts + }) { + return this._makeRequest({ + path: `/amenities/${amenityId}`, + ...opts, + }); + }, + listRentableTypesForAdmin({ + administrationId, ...opts + }) { + return this._makeRequest({ + path: `/administrations/${administrationId}/rentable_types`, + ...opts, + }); + }, + listAmenityGroups(opts = {}) { + return this._makeRequest({ + path: "/amenity_groups", + ...opts, + }); + }, }, }; diff --git a/components/booking_experts/common/utils.mjs b/components/booking_experts/common/utils.mjs index dcc9cc61f6f41..aa89b93b74762 100644 --- a/components/booking_experts/common/utils.mjs +++ b/components/booking_experts/common/utils.mjs @@ -1,18 +1,6 @@ export const parseObject = (obj) => { if (!obj) return undefined; - if (Array.isArray(obj)) { - return obj.map((item) => { - if (typeof item === "string") { - try { - return JSON.parse(item); - } catch (e) { - return item; - } - } - return item; - }); - } if (typeof obj === "string") { try { return JSON.parse(obj); @@ -20,5 +8,20 @@ export const parseObject = (obj) => { return obj; } } + + if (Array.isArray(obj)) { + return obj.map((item) => parseObject(item)); + } + + if (typeof obj === "object") { + return Object.fromEntries(Object.entries(obj).map(([ + key, + value, + ]) => [ + key, + parseObject(value), + ])); + } + return obj; }; diff --git a/components/booking_experts/package.json b/components/booking_experts/package.json index 52ade66eaadb7..ab6d3b958d985 100644 --- a/components/booking_experts/package.json +++ b/components/booking_experts/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/booking_experts", - "version": "0.4.0", + "version": "0.5.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 c81b57448f2f4..0913f7df4d708 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.5", + version: "0.0.6", 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 9ac7b7449dd4e..cf8ac8578fb80 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.5", + version: "0.0.6", 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 55842bcf5d70c..df28a585955ad 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.5", + version: "0.0.6", 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 3af0f7f1044e7..51ece5eb0fe4c 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.5", + version: "0.0.6", type: "source", dedupe: "unique", props: {