diff --git a/components/hostaway/actions/create-reservation/create-reservation.mjs b/components/hostaway/actions/create-reservation/create-reservation.mjs new file mode 100644 index 0000000000000..8d87be3427ef2 --- /dev/null +++ b/components/hostaway/actions/create-reservation/create-reservation.mjs @@ -0,0 +1,76 @@ +import hostaway from "../../hostaway.app.mjs"; + +export default { + key: "hostaway-create-reservation", + name: "Create Reservation", + description: "Creates a new reservation in Hostaway. [See the documentation](https://api.hostaway.com/documentation#create-a-reservation)", + version: "0.0.1", + type: "action", + props: { + hostaway, + channelId: { + propDefinition: [ + hostaway, + "channelId", + ], + }, + listingMapId: { + propDefinition: [ + hostaway, + "listingId", + ], + }, + arrivalDate: { + type: "string", + label: "Arrival Date", + description: "Arrival date in `YYYY-MM-DD` format, e.g. `2024-08-15`", + }, + departureDate: { + type: "string", + label: "Departure Date", + description: "Departure date in `YYYY-MM-DD` format, e.g. `2024-08-19`", + }, + guestName: { + type: "string", + label: "Guest Name", + description: "Name of the guest", + optional: true, + }, + guestEmail: { + type: "string", + label: "Guest Email", + description: "Email address of the guest", + optional: true, + }, + numberOfGuests: { + type: "integer", + label: "Number of Guests", + description: "Number of guests for the reservation", + optional: true, + }, + additionalFields: { + type: "object", + label: "Additional Fields", + description: "Additional fields to set for the reservation. [See the documentation](https://api.hostaway.com/documentation#reservation-object) for all available fields.", + optional: true, + }, + }, + async run({ $ }) { + const { + hostaway, additionalFields = {}, ...data + } = this; + const { result } = await hostaway.createReservation({ + $, + data: { + ...data, + ...additionalFields, + }, + }); + + if (result?.id) { + $.export("summary", `Successfully created reservation (ID: ${result.id})`); + } + + return result; + }, +}; diff --git a/components/hostaway/actions/create-task/create-task.mjs b/components/hostaway/actions/create-task/create-task.mjs index f00ff2a62ae4a..c9a99b8fbb1e2 100644 --- a/components/hostaway/actions/create-task/create-task.mjs +++ b/components/hostaway/actions/create-task/create-task.mjs @@ -5,7 +5,7 @@ export default { key: "hostaway-create-task", name: "Create Task", description: "Creates a new task in Hostaway. [See the documentation](https://api.hostaway.com/documentation#create-task)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { hostaway, diff --git a/components/hostaway/actions/send-message-to-guest/send-message-to-guest.mjs b/components/hostaway/actions/send-message-to-guest/send-message-to-guest.mjs index c8c96c88eefe1..7d6f625e59849 100644 --- a/components/hostaway/actions/send-message-to-guest/send-message-to-guest.mjs +++ b/components/hostaway/actions/send-message-to-guest/send-message-to-guest.mjs @@ -5,7 +5,7 @@ export default { key: "hostaway-send-message-to-guest", name: "Send Message To Guest", description: "Send a conversation message to a guest in Hostaway. [See the documentation](https://api.hostaway.com/documentation#send-conversation-message)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { hostaway, diff --git a/components/hostaway/actions/update-task/update-task.mjs b/components/hostaway/actions/update-task/update-task.mjs index b215df2bb03a2..87ef60ad2c62d 100644 --- a/components/hostaway/actions/update-task/update-task.mjs +++ b/components/hostaway/actions/update-task/update-task.mjs @@ -6,7 +6,7 @@ export default { key: "hostaway-update-task", name: "Update Task", description: "Updates an existing task in Hostaway. [See the documentation](https://api.hostaway.com/documentation#update-task)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { hostaway, diff --git a/components/hostaway/common/constants.mjs b/components/hostaway/common/constants.mjs index f65b47bc874dc..a2aa0082bf9b8 100644 --- a/components/hostaway/common/constants.mjs +++ b/components/hostaway/common/constants.mjs @@ -42,9 +42,73 @@ const COMMUNICATION_TYPES = [ "whatsapp", ]; +const CHANNEL_OPTIONS = [ + { + value: 2018, + label: "airbnbOfficial", + }, + { + value: 2002, + label: "homeaway", + }, + { + value: 2005, + label: "bookingcom", + }, + { + value: 2007, + label: "expedia", + }, + { + value: 2009, + label: "homeawayical", + }, + { + value: 2010, + label: "vrboical", + }, + { + value: 2000, + label: "direct", + }, + { + value: 2013, + label: "bookingengine", + }, + { + value: 2015, + label: "customIcal", + }, + { + value: 2016, + label: "tripadvisorical", + }, + { + value: 2017, + label: "wordpress", + }, + { + value: 2019, + label: "marriott", + }, + { + value: 2020, + label: "partner", + }, + { + value: 2021, + label: "gds", + }, + { + value: 2022, + label: "google", + }, +]; + export default { DEFAULT_LIMIT, CATEGORIES, TASK_STATUS, COMMUNICATION_TYPES, + CHANNEL_OPTIONS, }; diff --git a/components/hostaway/hostaway.app.mjs b/components/hostaway/hostaway.app.mjs index 67d5440ab9e05..53c9d56ba16df 100644 --- a/components/hostaway/hostaway.app.mjs +++ b/components/hostaway/hostaway.app.mjs @@ -118,6 +118,12 @@ export default { })) || []; }, }, + channelId: { + type: "integer", + label: "Channel", + description: "Identifier of the channel", + options: constants.CHANNEL_OPTIONS, + }, }, methods: { _baseUrl() { @@ -211,5 +217,12 @@ export default { ...args, }); }, + createReservation(args = {}) { + return this._makeRequest({ + path: "/reservations", + method: "POST", + ...args, + }); + }, }, }; diff --git a/components/hostaway/package.json b/components/hostaway/package.json index 5004a581b1c50..cb4bda8897403 100644 --- a/components/hostaway/package.json +++ b/components/hostaway/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/hostaway", - "version": "0.1.1", + "version": "0.2.0", "description": "Pipedream Hostaway Components", "main": "hostaway.app.mjs", "keywords": [ diff --git a/components/hostaway/sources/new-message-received/new-message-received.mjs b/components/hostaway/sources/new-message-received/new-message-received.mjs index 0cebcdc499996..819e3c3417af2 100644 --- a/components/hostaway/sources/new-message-received/new-message-received.mjs +++ b/components/hostaway/sources/new-message-received/new-message-received.mjs @@ -5,7 +5,7 @@ export default { key: "hostaway-new-message-received", name: "New Message Received", description: "Emit new event when a new message is received in Hostaway.", - version: "0.0.2", + version: "0.0.3", type: "source", dedupe: "unique", methods: { diff --git a/components/hostaway/sources/reservation-created/reservation-created.mjs b/components/hostaway/sources/reservation-created/reservation-created.mjs index fe60ffdd638e6..28cc0d4fa4f77 100644 --- a/components/hostaway/sources/reservation-created/reservation-created.mjs +++ b/components/hostaway/sources/reservation-created/reservation-created.mjs @@ -5,7 +5,7 @@ export default { key: "hostaway-reservation-created", name: "New Reservation Created", description: "Emit new event when a new reservation is created in Hostaway.", - version: "0.0.2", + version: "0.0.3", type: "source", dedupe: "unique", methods: { diff --git a/components/hostaway/sources/reservation-updated/reservation-updated.mjs b/components/hostaway/sources/reservation-updated/reservation-updated.mjs index 211ff73c45c6e..14d34647fa9ee 100644 --- a/components/hostaway/sources/reservation-updated/reservation-updated.mjs +++ b/components/hostaway/sources/reservation-updated/reservation-updated.mjs @@ -5,7 +5,7 @@ export default { key: "hostaway-reservation-updated", name: "New Reservation Updated", description: "Emit new event when a reservation is updated in Hostaway.", - version: "0.0.2", + version: "0.0.3", type: "source", dedupe: "unique", methods: {