From dc5b4372445dffa322fd47b3cb1a56688d64f88b Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 4 Dec 2024 02:29:09 -0300 Subject: [PATCH 1/3] Hostaway new action --- .../create-reservation/create-reservation.mjs | 74 +++++++++++++++++++ components/hostaway/common/constants.mjs | 19 +++++ components/hostaway/hostaway.app.mjs | 13 ++++ 3 files changed, 106 insertions(+) create mode 100644 components/hostaway/actions/create-reservation/create-reservation.mjs 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..c2b49f2e93750 --- /dev/null +++ b/components/hostaway/actions/create-reservation/create-reservation.mjs @@ -0,0 +1,74 @@ +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/common/constants.mjs b/components/hostaway/common/constants.mjs index f65b47bc874dc..5273c991cbb0c 100644 --- a/components/hostaway/common/constants.mjs +++ b/components/hostaway/common/constants.mjs @@ -42,9 +42,28 @@ 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..64181fc4ebd7d 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, + }); + } }, }; From ae020975d5b86130335eae75d0d3eb4ebc01304e Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 4 Dec 2024 02:30:29 -0300 Subject: [PATCH 2/3] Version bumps + ESLint --- components/hostaway/actions/create-task/create-task.mjs | 2 +- .../actions/send-message-to-guest/send-message-to-guest.mjs | 2 +- components/hostaway/actions/update-task/update-task.mjs | 2 +- components/hostaway/package.json | 2 +- .../sources/new-message-received/new-message-received.mjs | 2 +- .../sources/reservation-created/reservation-created.mjs | 2 +- .../sources/reservation-updated/reservation-updated.mjs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) 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/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: { From fbdca846ed859ca5d451ec8b844ac7b14a171a13 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 4 Dec 2024 02:31:23 -0300 Subject: [PATCH 3/3] ESLint --- .../create-reservation/create-reservation.mjs | 8 +- components/hostaway/common/constants.mjs | 77 +++++++++++++++---- components/hostaway/hostaway.app.mjs | 4 +- 3 files changed, 68 insertions(+), 21 deletions(-) diff --git a/components/hostaway/actions/create-reservation/create-reservation.mjs b/components/hostaway/actions/create-reservation/create-reservation.mjs index c2b49f2e93750..8d87be3427ef2 100644 --- a/components/hostaway/actions/create-reservation/create-reservation.mjs +++ b/components/hostaway/actions/create-reservation/create-reservation.mjs @@ -53,15 +53,17 @@ export default { 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 { + hostaway, additionalFields = {}, ...data + } = this; const { result } = await hostaway.createReservation({ $, data: { ...data, - ...additionalFields + ...additionalFields, }, }); diff --git a/components/hostaway/common/constants.mjs b/components/hostaway/common/constants.mjs index 5273c991cbb0c..a2aa0082bf9b8 100644 --- a/components/hostaway/common/constants.mjs +++ b/components/hostaway/common/constants.mjs @@ -43,22 +43,67 @@ const COMMUNICATION_TYPES = [ ]; 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", }, -] + { + 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, diff --git a/components/hostaway/hostaway.app.mjs b/components/hostaway/hostaway.app.mjs index 64181fc4ebd7d..53c9d56ba16df 100644 --- a/components/hostaway/hostaway.app.mjs +++ b/components/hostaway/hostaway.app.mjs @@ -122,7 +122,7 @@ export default { type: "integer", label: "Channel", description: "Identifier of the channel", - options: constants.CHANNEL_OPTIONS + options: constants.CHANNEL_OPTIONS, }, }, methods: { @@ -223,6 +223,6 @@ export default { method: "POST", ...args, }); - } + }, }, };