Skip to content

Commit 72f817e

Browse files
authored
Hostaway new action (#14825)
* Hostaway new action * Version bumps + ESLint * ESLint
1 parent afa1dd2 commit 72f817e

File tree

10 files changed

+160
-7
lines changed

10 files changed

+160
-7
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import hostaway from "../../hostaway.app.mjs";
2+
3+
export default {
4+
key: "hostaway-create-reservation",
5+
name: "Create Reservation",
6+
description: "Creates a new reservation in Hostaway. [See the documentation](https://api.hostaway.com/documentation#create-a-reservation)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
hostaway,
11+
channelId: {
12+
propDefinition: [
13+
hostaway,
14+
"channelId",
15+
],
16+
},
17+
listingMapId: {
18+
propDefinition: [
19+
hostaway,
20+
"listingId",
21+
],
22+
},
23+
arrivalDate: {
24+
type: "string",
25+
label: "Arrival Date",
26+
description: "Arrival date in `YYYY-MM-DD` format, e.g. `2024-08-15`",
27+
},
28+
departureDate: {
29+
type: "string",
30+
label: "Departure Date",
31+
description: "Departure date in `YYYY-MM-DD` format, e.g. `2024-08-19`",
32+
},
33+
guestName: {
34+
type: "string",
35+
label: "Guest Name",
36+
description: "Name of the guest",
37+
optional: true,
38+
},
39+
guestEmail: {
40+
type: "string",
41+
label: "Guest Email",
42+
description: "Email address of the guest",
43+
optional: true,
44+
},
45+
numberOfGuests: {
46+
type: "integer",
47+
label: "Number of Guests",
48+
description: "Number of guests for the reservation",
49+
optional: true,
50+
},
51+
additionalFields: {
52+
type: "object",
53+
label: "Additional Fields",
54+
description: "Additional fields to set for the reservation. [See the documentation](https://api.hostaway.com/documentation#reservation-object) for all available fields.",
55+
optional: true,
56+
},
57+
},
58+
async run({ $ }) {
59+
const {
60+
hostaway, additionalFields = {}, ...data
61+
} = this;
62+
const { result } = await hostaway.createReservation({
63+
$,
64+
data: {
65+
...data,
66+
...additionalFields,
67+
},
68+
});
69+
70+
if (result?.id) {
71+
$.export("summary", `Successfully created reservation (ID: ${result.id})`);
72+
}
73+
74+
return result;
75+
},
76+
};

components/hostaway/actions/create-task/create-task.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "hostaway-create-task",
66
name: "Create Task",
77
description: "Creates a new task in Hostaway. [See the documentation](https://api.hostaway.com/documentation#create-task)",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
hostaway,

components/hostaway/actions/send-message-to-guest/send-message-to-guest.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "hostaway-send-message-to-guest",
66
name: "Send Message To Guest",
77
description: "Send a conversation message to a guest in Hostaway. [See the documentation](https://api.hostaway.com/documentation#send-conversation-message)",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
hostaway,

components/hostaway/actions/update-task/update-task.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "hostaway-update-task",
77
name: "Update Task",
88
description: "Updates an existing task in Hostaway. [See the documentation](https://api.hostaway.com/documentation#update-task)",
9-
version: "0.0.1",
9+
version: "0.0.2",
1010
type: "action",
1111
props: {
1212
hostaway,

components/hostaway/common/constants.mjs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,73 @@ const COMMUNICATION_TYPES = [
4242
"whatsapp",
4343
];
4444

45+
const CHANNEL_OPTIONS = [
46+
{
47+
value: 2018,
48+
label: "airbnbOfficial",
49+
},
50+
{
51+
value: 2002,
52+
label: "homeaway",
53+
},
54+
{
55+
value: 2005,
56+
label: "bookingcom",
57+
},
58+
{
59+
value: 2007,
60+
label: "expedia",
61+
},
62+
{
63+
value: 2009,
64+
label: "homeawayical",
65+
},
66+
{
67+
value: 2010,
68+
label: "vrboical",
69+
},
70+
{
71+
value: 2000,
72+
label: "direct",
73+
},
74+
{
75+
value: 2013,
76+
label: "bookingengine",
77+
},
78+
{
79+
value: 2015,
80+
label: "customIcal",
81+
},
82+
{
83+
value: 2016,
84+
label: "tripadvisorical",
85+
},
86+
{
87+
value: 2017,
88+
label: "wordpress",
89+
},
90+
{
91+
value: 2019,
92+
label: "marriott",
93+
},
94+
{
95+
value: 2020,
96+
label: "partner",
97+
},
98+
{
99+
value: 2021,
100+
label: "gds",
101+
},
102+
{
103+
value: 2022,
104+
label: "google",
105+
},
106+
];
107+
45108
export default {
46109
DEFAULT_LIMIT,
47110
CATEGORIES,
48111
TASK_STATUS,
49112
COMMUNICATION_TYPES,
113+
CHANNEL_OPTIONS,
50114
};

components/hostaway/hostaway.app.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ export default {
118118
})) || [];
119119
},
120120
},
121+
channelId: {
122+
type: "integer",
123+
label: "Channel",
124+
description: "Identifier of the channel",
125+
options: constants.CHANNEL_OPTIONS,
126+
},
121127
},
122128
methods: {
123129
_baseUrl() {
@@ -211,5 +217,12 @@ export default {
211217
...args,
212218
});
213219
},
220+
createReservation(args = {}) {
221+
return this._makeRequest({
222+
path: "/reservations",
223+
method: "POST",
224+
...args,
225+
});
226+
},
214227
},
215228
};

components/hostaway/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/hostaway",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"description": "Pipedream Hostaway Components",
55
"main": "hostaway.app.mjs",
66
"keywords": [

components/hostaway/sources/new-message-received/new-message-received.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "hostaway-new-message-received",
66
name: "New Message Received",
77
description: "Emit new event when a new message is received in Hostaway.",
8-
version: "0.0.2",
8+
version: "0.0.3",
99
type: "source",
1010
dedupe: "unique",
1111
methods: {

components/hostaway/sources/reservation-created/reservation-created.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "hostaway-reservation-created",
66
name: "New Reservation Created",
77
description: "Emit new event when a new reservation is created in Hostaway.",
8-
version: "0.0.2",
8+
version: "0.0.3",
99
type: "source",
1010
dedupe: "unique",
1111
methods: {

components/hostaway/sources/reservation-updated/reservation-updated.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "hostaway-reservation-updated",
66
name: "New Reservation Updated",
77
description: "Emit new event when a reservation is updated in Hostaway.",
8-
version: "0.0.2",
8+
version: "0.0.3",
99
type: "source",
1010
dedupe: "unique",
1111
methods: {

0 commit comments

Comments
 (0)