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 9751e77343de1..495244c1573d1 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 @@ -4,7 +4,7 @@ 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.4", + version: "0.0.5", 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 6f17330c1c03a..dbf8049d97157 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.4", + version: "0.0.5", 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 2befe74e1ad9e..31f90079a95bc 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.2", + version: "0.0.3", annotations: { destructiveHint: true, openWorldHint: true, diff --git a/components/booking_experts/actions/get-booking/get-booking.mjs b/components/booking_experts/actions/get-booking/get-booking.mjs index b96de0a21e6e2..cb75773ab3a0b 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.2", + version: "0.0.3", 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 6cbe93a630e1a..392ffbd6242d4 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.4", + version: "0.0.5", 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 bd33d33213cb1..1162b5d337caf 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.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: false, diff --git a/components/booking_experts/actions/list-availabilities/list-availabilities.mjs b/components/booking_experts/actions/list-availabilities/list-availabilities.mjs index 44bc6b7bfb362..add1a958b35aa 100644 --- a/components/booking_experts/actions/list-availabilities/list-availabilities.mjs +++ b/components/booking_experts/actions/list-availabilities/list-availabilities.mjs @@ -1,10 +1,16 @@ import bookingExperts from "../../booking_experts.app.mjs"; +import { + LIMITERS_OPTIONS, + SORTERS_OPTIONS, + WEEKDAY_OPTIONS, +} from "../../common/constants.mjs"; +import { parseObject } from "../../common/utils.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.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, @@ -18,10 +24,523 @@ export default { alertType: "warning", content: "**You must have at least one channel created through the Booking Experts API.**", }, + fields: { + type: "string[]", + label: "Fields", + description: "Fieldset of attributes to return. [See the documentation](https://developers.bookingexperts.com/reference/availabilities-index)", + optional: true, + }, + include: { + type: "string[]", + label: "Include", + description: "Includes list of resources to include. [See the documentation](https://developers.bookingexperts.com/reference/availabilities-index)", + optional: true, + }, + channelIds: { + propDefinition: [ + bookingExperts, + "channelId", + ], + type: "string[]", + label: "Channel IDs", + description: "Specify a list of channel IDs to be used for searching availability. By default, all accessible channels associated to your app will be used. Overriding this may be useful when you have access to multiple channels of the same administration.", + optional: true, + }, + includeSemanticSegmentCounts: { + type: "boolean", + label: "Include Semantic Segment Counts", + description: "When `true`, the amount of results per semantic segment will be added to the metadata", + optional: true, + }, + includeAmenityCounts: { + type: "boolean", + label: "Include Amenity Counts", + description: "When `true`, the amount of results per amenity will be added to the metadata", + optional: true, + }, + referrer: { + type: "string", + label: "Referrer", + description: "Referrer name.", + optional: true, + }, + startDate: { + type: "string", + label: "Start Date", + description: "Filter on start date. Expects a date range. Note: date ranges have an exclusive end date. Format: `YYYY-MM-DD..YYYY-MM-DD`", + optional: true, + }, + overlapsDate: { + type: "string", + label: "Overlaps Date", + description: "Filter availabilities that (partially) overlap these dates. Format: `YYYY-MM-DD..YYYY-MM-DD`", + optional: true, + }, + includesDate: { + type: "string", + label: "Includes Date", + description: "Filter availabilities that contain the specified date range. Format: `YYYY-MM-DD..YYYY-MM-DD`", + optional: true, + }, + arrangement: { + type: "string", + label: "Arrangement", + description: "Filter on availabilities that exactly match the supplied date range. Format: `YYYY-MM-DD..YYYY-MM-DD`", + optional: true, + }, + los: { + type: "string", + label: "Los", + description: "Filter on length of stay. Format: `1..21`", + optional: true, + }, + wday: { + type: "string", + label: "Wday", + description: "Filter on a particular week day", + options: WEEKDAY_OPTIONS, + optional: true, + }, + administrationIds: { + propDefinition: [ + bookingExperts, + "administrationId", + ], + type: "string[]", + label: "Administration IDs", + description: "Filter on administrations", + optional: true, + }, + rentableTypeIds: { + type: "string[]", + label: "Rentable Type IDs", + description: "Filter on rentable types", + optional: true, + }, + excludeRentableTypeIds: { + type: "string[]", + label: "Exclude Rentable Type IDs", + description: "Exclude rentable types", + optional: true, + }, + rentableSegmentIds: { + propDefinition: [ + bookingExperts, + "rentableSegmentId", + ], + type: "string[]", + label: "Rentable Segment IDs", + description: "Filter on rentable segments.", + optional: true, + }, + excludeRentableSegmentIds: { + propDefinition: [ + bookingExperts, + "rentableSegmentId", + ], + type: "string[]", + label: "Exclude Rentable Segment IDs", + description: "Exclude rentable segments.", + optional: true, + }, + amenityIds: { + propDefinition: [ + bookingExperts, + "amenityId", + ], + type: "string[]", + label: "Amenity IDs", + description: "Filter on amenities.", + optional: true, + }, + discountCampaignId: { + propDefinition: [ + bookingExperts, + "discountCampaignId", + (c) => ({ + administrationId: c.administrationId, + }), + ], + description: "Filter on discount campaign ID.", + optional: true, + }, + inventoryObjectId: { + propDefinition: [ + bookingExperts, + "inventoryObjectId", + (c) => ({ + administrationId: c.administrationId, + }), + ], + description: "Filter on inventory object ID.", + optional: true, + }, + promotionToken: { + type: "string", + label: "Promotion Token", + description: "Filter on owner promotion token.", + optional: true, + }, + countryCodes: { + type: "string[]", + label: "Country Codes", + description: "Filter on country codes. Specify a comma separated list of ISO 3166-1 alpha-2 country codes. For example: NL,EN,DE.", + optional: true, + }, + excludeCountryCodes: { + type: "string[]", + label: "Exclude Country Codes", + description: "Exclude country codes. Specify a comma separated list of ISO 3166-1 alpha-2 country codes. For example: NL,EN,DE.", + optional: true, + }, + seniors: { + type: "integer", + label: "Seniors", + description: "Filter on number of seniors.", + optional: true, + }, + adults: { + type: "integer", + label: "Adults", + description: "Filter on number of adults.", + optional: true, + }, + adolescents: { + type: "integer", + label: "Adolescents", + description: "Filter on number of adolescents.", + optional: true, + }, + children: { + type: "integer", + label: "Children", + description: "Filter on number of children.", + optional: true, + }, + babies: { + type: "integer", + label: "Babies", + description: "Filter on number of babies.", + optional: true, + }, + pets: { + type: "integer", + label: "Pets", + description: "Filter on number of pets.", + optional: true, + }, + price: { + type: "string", + label: "Price", + description: "Filter on a price range. Format: `100..200`", + optional: true, + }, + currency: { + type: "string", + label: "Currency", + description: "Filter on a specific ISO 4217 currency code. By default the prices are returned in the administration's native currency. Results can differ per currency", + optional: true, + }, + numberOfBedrooms: { + type: "integer", + label: "Number of Bedrooms", + description: "Filter on type number of bedrooms.", + optional: true, + }, + numberOfBeds: { + type: "integer", + label: "Number of Beds", + description: "Filter on type number of beds.", + optional: true, + }, + numberOfShowers: { + type: "integer", + label: "Number of Showers", + description: "Filter on type number of showers.", + optional: true, + }, + numberOfToilets: { + type: "integer", + label: "Number of Toilets", + description: "Filter on type number of toilets.", + optional: true, + }, + numberOfBathrooms: { + type: "integer", + label: "Number of Bathrooms", + description: "Filter on type number of bathrooms.", + optional: true, + }, + numberOfParkingSpots: { + type: "integer", + label: "Number of Parking Spots", + description: "Filter on type number of parking spots.", + optional: true, + }, + numberOfChildBeds: { + type: "integer", + label: "Number of Child Beds", + description: "Filter on type number of beds.", + optional: true, + }, + numberOfChildChairs: { + type: "integer", + label: "Number of Child Chairs", + description: "Filter on type number of child chairs.", + optional: true, + }, + sorters: { + type: "string[]", + label: "Sorters", + description: "Specify a comma separated list of sorters to apply", + options: SORTERS_OPTIONS, + optional: true, + }, + losDesc: { + type: "boolean", + label: "Los Desc", + description: "Boolean specifying the sort direction for the `los` sorter. When unspecified, ascending order is implied.", + optional: true, + }, + losDistanceDesc: { + type: "boolean", + label: "Los Distance Desc", + description: "Boolean specifying the sort direction for the `los_distance` sorter. When unspecified, ascending order is implied.", + optional: true, + }, + losDistanceLos: { + type: "integer", + label: "Los Distance Los", + description: "Length of stay for the `los_distance` sorter.", + optional: true, + }, + startDateDesc: { + type: "boolean", + label: "Start Date Desc", + description: "Boolean specifying the sort direction for the `start_date` sorter. When unspecified, ascending order is implied.", + optional: true, + }, + startDateDistanceDesc: { + type: "boolean", + label: "Start Date Distance Desc", + description: "Boolean specifying the sort direction for the `start_date_distance` sorter. When unspecified, ascending order is implied.", + optional: true, + }, + startDateDistanceStartDate: { + type: "string", + label: "Start Date Distance Start Date", + description: "Start date for the `start_date_distance` sorter. Format: `YYYY-MM-DD`", + optional: true, + }, + arrangementDistanceDesc: { + type: "boolean", + label: "Arrangement Distance Desc", + description: "Boolean specifying the sort direction for the `arrangement_distance` sorter. When unspecified, ascending order is implied.", + optional: true, + }, + arrangementDistanceArrangement: { + type: "string", + label: "Arrangement Distance Arrangement", + description: "Arrangement for the `arrangement_distance` sorter. Format: `YYYY-MM-DD..YYYY-MM-DD`", + optional: true, + }, + maxGuestsDesc: { + type: "boolean", + label: "Max Guests Desc", + description: "Boolean specifying the sort direction for the `max_guests` sorter. When unspecified, ascending order is implied.", + optional: true, + }, + highlightedDesc: { + type: "boolean", + label: "Highlighted Desc", + description: "Boolean specifying the sort direction for the `highlighted` sorter. When unspecified, ascending order is implied.", + optional: true, + }, + allInAmountDesc: { + type: "boolean", + label: "All In Amount Desc", + description: "Boolean specifying the sort direction for the `all_in_amount` sorter. When unspecified, ascending order is implied.", + optional: true, + }, + amenityIdsMatchScoreDesc: { + type: "boolean", + label: "Amenity Ids Match Score Desc", + description: "Boolean specifying the sort direction for the `amenity_ids_match_score` sorter. When unspecified, ascending order is implied.", + optional: true, + }, + amenityIdsMatchScoreAmenityIds: { + type: "string[]", + label: "Amenity Ids Match Score Amenity Ids", + description: "Amenity IDs for the `amenity_ids_match_score` sorter.", + optional: true, + }, + avgScoreDesc: { + type: "boolean", + label: "Avg Score Desc", + description: "Boolean specifying the sort direction for the `avg_score` sorter. When unspecified, ascending order is implied.", + optional: true, + }, + limit: { + type: "string", + label: "Limit", + description: "Specify a limiter here.", + options: LIMITERS_OPTIONS, + optional: true, + }, + availabilitiesLimit: { + type: "integer", + label: "Availabilities Limit", + description: "Return `limit` availabilities.", + optional: true, + }, + startDatesLimit: { + type: "integer", + label: "Start Dates Limit", + description: "Limit to the `limit` best arrival dates.", + optional: true, + }, + startDatesAvailabilities: { + type: "integer", + label: "Start Dates Availabilities", + description: "Number of availabilities to return.", + optional: true, + }, + losLimit: { + type: "integer", + label: "Los Limit", + description: "Limit to the `limit` best Length of stay (LOS) values.", + optional: true, + }, + losAvailabilities: { + type: "integer", + label: "Los Availabilities", + description: "Number of availabilities to return.", + optional: true, + }, + categoriesOffset: { + type: "integer", + label: "Categories Offset", + description: "Result offset for the `categories` limiter, useful for pagination.", + optional: true, + }, + categoriesAvailabilities: { + type: "integer", + label: "Categories Availabilities", + description: "Number of availabilities to return.", + optional: true, + }, + rentableTypesLimit: { + type: "integer", + label: "Rentable Types Limit", + description: "Limit to the `limit` best types.", + optional: true, + }, + rentableTypesOffset: { + type: "integer", + label: "Rentable Types Offset", + description: "Result offset for the `rentable_types` limiter, useful for pagination.", + optional: true, + }, + rentableTypesAvailabilities: { + type: "integer", + label: "Rentable Types Availabilities", + description: "Number of availabilities to return.", + optional: true, + }, + administrationsLimit: { + type: "integer", + label: "Administrations Limit", + description: "Limit to the `limit` best administrations.", + optional: true, + }, + administrationsRentableTypes: { + type: "integer", + label: "Administrations Rentable Types", + description: "Limit to the `limit` best types.", + optional: true, + }, + administrationsAvailabilities: { + type: "integer", + label: "Administrations Availabilities", + description: "Number of availabilities to return.", + optional: true, + }, }, async run({ $ }) { const { data } = await this.bookingExperts.listAvailabilities({ $, + params: { + "fields[availability]": parseObject(this.fields)?.join(","), + "include": parseObject(this.include)?.join(","), + "channelIds": parseObject(this.channelIds)?.join(","), + "include_semantic_segment_counts": this.includeSemanticSegmentCounts, + "include_amenity_counts": this.includeAmenityCounts, + "referrer": this.referrer, + "filter[start_date]": this.startDate, + "filter[overlaps_date]": this.overlapsDate, + "filter[includes_date]": this.includesDate, + "filter[arrangement]": this.arrangement, + "filter[los]": this.los, + "filter[wday]": this.wday + ? parseInt(this.wday) + : undefined, + "filter[administration_ids]": parseObject(this.administrationIds)?.join(","), + "filter[rentable_type_ids]": parseObject(this.rentableTypeIds)?.join(","), + "filter[-rentable_type_ids]": parseObject(this.excludeRentableTypeIds)?.join(","), + "filter[rentable_segment_ids]": parseObject(this.rentableSegmentIds)?.join(","), + "filter[-rentable_segment_ids]": parseObject(this.excludeRentableSegmentIds)?.join(","), + "filter[amenity_ids]": parseObject(this.amenityIds)?.join(","), + "filter[discount_campaign_id]": this.discountCampaignId, + "filter[inventory_object_id]": this.inventoryObjectId, + "filter[promotion_token]": this.promotionToken, + "filter[country_codes]": parseObject(this.countryCodes)?.join(","), + "filter[-country_codes]": parseObject(this.excludeCountryCodes)?.join(","), + "filter[guest_group][seniors]": this.seniors, + "filter[guest_group][adults]": this.adults, + "filter[guest_group][adolescents]": this.adolescents, + "filter[guest_group][children]": this.children, + "filter[guest_group][babies]": this.babies, + "filter[guest_group][pets]": this.pets, + "filter[price]": this.price, + "filter[currency]": this.currency, + "filter[number_of_bedrooms]": this.numberOfBedrooms, + "filter[number_of_beds]": this.numberOfBeds, + "filter[number_of_showers]": this.numberOfShowers, + "filter[number_of_toilets]": this.numberOfToilets, + "filter[number_of_bathrooms]": this.numberOfBathrooms, + "filter[number_of_parking_spots]": this.numberOfParkingSpots, + "filter[number_of_child_beds]": this.numberOfChildBeds, + "filter[number_of_child_chairs]": this.numberOfChildChairs, + "sorters": parseObject(this.sorters)?.join(","), + "sorter[los][desc]": this.losDesc, + "sorter[los_distance][desc]": this.losDistanceDesc, + "sorter[los_distance][los]": this.losDistanceLos, + "sorter[start_date][desc]": this.startDateDesc, + "sorter[start_date_distance][desc]": this.startDateDistanceDesc, + "sorter[start_date_distance][start_date]": this.startDateDistanceStartDate, + "sorter[arrangement_distance][desc]": this.arrangementDistanceDesc, + "sorter[arrangement_distance][arrangement]": this.arrangementDistanceArrangement, + "sorter[max_guests][desc]": this.maxGuestsDesc, + "sorter[highlighted][desc]": this.highlightedDesc, + "sorter[all_in_amount][desc]": this.allInAmountDesc, + "sorter[amenity_ids_match_score][desc]": this.amenityIdsMatchScoreDesc, + "sorter[amenity_ids_match_score][amenity_ids]": parseObject(this.amenityIdsMatchScoreAmenityIds)?.join(","), + "sorter[avg_score][desc]": this.avgScoreDesc, + "limit": this.limit, + "limiter[availabilities][limit]": this.availabilitiesLimit, + "limiter[start_dates][limit]": this.startDatesLimit, + "limiter[start_dates][availabilities]": this.startDatesAvailabilities, + "limiter[los][limit]": this.losLimit, + "limiter[los][availabilities]": this.losAvailabilities, + "limiter[categories][offset]": this.categoriesOffset, + "limiter[categories][availabilities]": this.categoriesAvailabilities, + "limiter[rentable_types][limit]": this.rentableTypesLimit, + "limiter[rentable_types][offset]": this.rentableTypesOffset, + "limiter[rentable_types][availabilities]": this.rentableTypesAvailabilities, + "limiter[administrations][limit]": this.administrationsLimit, + "limiter[administrations][rentable_types]": this.administrationsRentableTypes, + "limiter[administrations][availabilities]": this.administrationsAvailabilities, + }, }); $.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 efb5d4ec06cc3..0b6e5c59ee9d8 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.4", + version: "0.0.5", 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 b7db750a79d41..08f7180cbfd26 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.4", + version: "0.0.5", annotations: { destructiveHint: false, openWorldHint: true, 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 64c7a44c6241e..34abdacd331b4 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 @@ -1,11 +1,13 @@ import { ConfigurationError } from "@pipedream/platform"; import bookingExperts from "../../booking_experts.app.mjs"; +import { FIELDS_OPTIONS } from "../../common/constants.mjs"; +import { parseObject } from "../../common/utils.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.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, @@ -47,6 +49,25 @@ export default { 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, }, + fields: { + type: "string[]", + label: "Fields", + description: "Fieldset. A list of attributes to return. [See the documentation](https://developers.bookingexperts.com/reference/channel-rentabletype-availabilities-index)", + options: FIELDS_OPTIONS, + optional: true, + }, + include: { + type: "string[]", + label: "Include", + description: "Includes list. A list of resources to include. [See the documentation](https://developers.bookingexperts.com/reference/channel-rentabletype-availabilities-index)", + optional: true, + }, + multibookSafetyMargin: { + type: "integer", + label: "Multi-book Safety Margin", + description: "Specifies a custom multibook safety margin (must be a positive number). A common problem that occurs when dealing with accommodations instead of hotelrooms is that a single accommodation must be available for all consecutive days for a given start date and LOS. The safety margin helps to prevent overbookings by transforming the available stock. When specified, the safety margin is subtracted from the actual stock. It is only applied to RentableType availabilities with capacity of 3 or more, as this issue cannot occur otherwise.", + optional: true, + }, }, async run({ $ }) { if ((!this.startDate && this.endDate) || (this.startDate && !this.endDate)) { @@ -61,6 +82,9 @@ export default { && { "date_range": `${this.startDate}..${this.endDate}`, }), + "fields[rentable_type_availability]": parseObject(this.fields)?.join(","), + "include": parseObject(this.include)?.join(","), + "multibook_safety_margin": this.multibookSafetyMargin, }, }); $.export("$summary", `Found ${data.length} rentable type availabilities`); diff --git a/components/booking_experts/actions/list-reservations/list-reservations.mjs b/components/booking_experts/actions/list-reservations/list-reservations.mjs index fb4167dade403..88c7b14664a72 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.1", + version: "0.0.2", 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 7a37cd4521a3f..d13e4ceb478ec 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.4", + version: "0.0.5", 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 e57451d95cd58..f8d034f23083b 100644 --- a/components/booking_experts/actions/update-guest/update-guest.mjs +++ b/components/booking_experts/actions/update-guest/update-guest.mjs @@ -4,7 +4,7 @@ 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.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/booking_experts/booking_experts.app.mjs b/components/booking_experts/booking_experts.app.mjs index 092318b1a2906..704ad891f8cc2 100644 --- a/components/booking_experts/booking_experts.app.mjs +++ b/components/booking_experts/booking_experts.app.mjs @@ -243,6 +243,64 @@ export default { })) || []; }, }, + rentableSegmentId: { + type: "string", + label: "Rentable Segment ID", + description: "The ID of a rentable segment", + async options({ page }) { + const { data } = await this.listRentableSegments({ + params: { + "page[number]": page + 1, + }, + }); + return data?.map(({ + id, attributes, + }) => ({ + label: attributes.name.en, + value: id, + })) || []; + }, + }, + amenityId: { + type: "string", + label: "Amenity ID", + description: "The ID of an amenity", + async options({ page }) { + const { data } = await this.listAmenities({ + params: { + "page[number]": page + 1, + }, + }); + return data?.map(({ + id, attributes, + }) => ({ + label: attributes.name.en, + value: id, + })) || []; + }, + }, + discountCampaignId: { + type: "string", + label: "Discount Campaign ID", + description: "The ID of a discount campaign", + async options({ + administrationId, page, + }) { + const { data } = await this.listDiscountCampaigns({ + administrationId, + params: { + "page[number]": page + 1, + }, + }); + + return data?.map(({ + id, attributes, + }) => ({ + label: attributes.name.en, + value: id, + })) || []; + }, + }, page: { type: "integer", label: "Page", @@ -401,6 +459,26 @@ export default { ...opts, }); }, + listDiscountCampaigns({ + administrationId, ...opts + }) { + return this._makeRequest({ + path: `/administrations/${administrationId}/discount_campaigns`, + ...opts, + }); + }, + listRentableSegments(opts = {}) { + return this._makeRequest({ + path: "/rentable_segments", + ...opts, + }); + }, + listAmenities(opts = {}) { + return this._makeRequest({ + path: "/amenities", + ...opts, + }); + }, searchContacts(opts = {}) { return this._makeRequest({ path: "/contacts/search/first", diff --git a/components/booking_experts/common/constants.mjs b/components/booking_experts/common/constants.mjs new file mode 100644 index 0000000000000..9deb6be1b8876 --- /dev/null +++ b/components/booking_experts/common/constants.mjs @@ -0,0 +1,109 @@ +export const FIELDS_OPTIONS = [ + "date", + "stock", + "capacity", + "closed_to_arrival", + "closed_to_departure", + "max_length_of_stay", + "min_length_of_stay", + "unavailable_cluster_objects", + "out_of_order", + "out_of_inventory", +]; + +export const LIMITERS_OPTIONS = [ + { + label: "Return `limit` availabilities", + value: "availabilities", + }, + { + label: "Limit to the `limit` best arrival dates", + value: "start_dates", + }, + { + label: "Limit to the `limit` best Length of stay (LOS) values", + value: "los", + }, + { + label: "Limit to the `limit` best rentable types", + value: "rentable_types", + }, + { + label: "Limit to the `limit` best administrations", + value: "administrations", + }, +]; + +export const SORTERS_OPTIONS = [ + { + label: "Order by length of stay", + value: "los", + }, + { + label: "Order by the distance of a particular length of stay", + value: "los_distance", + }, + { + label: "Order by start dates", + value: "start_date", + }, + { + label: "Order by the distance of a particular start date", + value: "start_date_distance", + }, + { + label: "Order by the distance of a particular arrangement", + value: "arrangement_distance", + }, + { + label: "Order by maximum guests of the type", + value: "max_guests", + }, + { + label: "Order by availabilities that have a type that is highlighted", + value: "highlighted", + }, + { + label: "Order by price", + value: "all_in_amount", + }, + { + label: "Order by whether the amenities match", + value: "amenity_ids_match_score", + }, + { + label: "Order by average score", + value: "avg_score", + }, +]; + +export const WEEKDAY_OPTIONS = [ + { + label: "Sunday", + value: "0", + }, + { + label: "Monday", + value: "1", + }, + { + label: "Tuesday", + value: "2", + }, + { + label: "Wednesday", + value: "3", + }, + { + label: "Thursday", + value: "4", + }, + { + label: "Friday", + value: "5", + }, + { + label: "Saturday", + value: "6", + }, +]; diff --git a/components/booking_experts/common/utils.mjs b/components/booking_experts/common/utils.mjs new file mode 100644 index 0000000000000..dcc9cc61f6f41 --- /dev/null +++ b/components/booking_experts/common/utils.mjs @@ -0,0 +1,24 @@ +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); + } catch (e) { + return obj; + } + } + return obj; +}; diff --git a/components/booking_experts/package.json b/components/booking_experts/package.json index 6b8723427cd51..52ade66eaadb7 100644 --- a/components/booking_experts/package.json +++ b/components/booking_experts/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/booking_experts", - "version": "0.3.0", + "version": "0.4.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 06ff11b2acf39..d6ea517821298 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.3", + version: "0.0.4", 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 7dfb7d060b45f..aa36834b12d6a 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.3", + version: "0.0.4", 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 933b050e934ab..dc29fa6e30a3e 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.3", + version: "0.0.4", 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 0bbc971e952ac..41bd1810002c6 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.3", + version: "0.0.4", type: "source", dedupe: "unique", props: {