Skip to content

Commit ab796ab

Browse files
authored
Cloudbeds - new components (#19529)
* new components * pnpm-lock.yaml * updates
1 parent cf8acec commit ab796ab

File tree

14 files changed

+321
-71
lines changed

14 files changed

+321
-71
lines changed

components/browser_use/browser_use.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};
Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,39 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "cloudbeds",
46
propDefinitions: {},
57
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
8+
_baseUrl() {
9+
return "https://api.cloudbeds.com/api/v1.3";
10+
},
11+
_makeRequest({
12+
$ = this, path, headers, ...opts
13+
}) {
14+
return axios($, {
15+
url: `${this._baseUrl()}/${path}`,
16+
headers: {
17+
...headers,
18+
"x-api-key": `${this.$auth.api_key}`,
19+
"accept": "application/json",
20+
},
21+
...opts,
22+
});
23+
},
24+
createWebhook(opts = {}) {
25+
return this._makeRequest({
26+
path: "/postWebhook",
27+
method: "POST",
28+
...opts,
29+
});
30+
},
31+
deleteWebhook(opts = {}) {
32+
return this._makeRequest({
33+
path: "/deleteWebhook",
34+
method: "DELETE",
35+
...opts,
36+
});
937
},
1038
},
1139
};

components/cloudbeds/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/cloudbeds",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Cloudbeds Components",
55
"main": "cloudbeds.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.1"
1417
}
15-
}
18+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import cloudbeds from "../../cloudbeds.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
props: {
6+
cloudbeds,
7+
db: "$.service.db",
8+
http: {
9+
type: "$.interface.http",
10+
customResponse: true,
11+
},
12+
},
13+
hooks: {
14+
async activate() {
15+
const { data: { subscriptionID: id } } = await this.cloudbeds.createWebhook({
16+
data: {
17+
endpointUrl: this.http.endpoint,
18+
object: this.getObject(),
19+
action: this.getAction(),
20+
},
21+
headers: {
22+
"Content-Type": "application/x-www-form-urlencoded",
23+
},
24+
});
25+
this.setWebhookId(id);
26+
},
27+
async deactivate() {
28+
const webhookId = this.getWebhookId();
29+
if (webhookId) {
30+
await this.cloudbeds.deleteWebhook({
31+
params: {
32+
subscriptionID: webhookId,
33+
},
34+
});
35+
}
36+
},
37+
},
38+
methods: {
39+
setWebhookId(value) {
40+
this.db.set("webhookId", value);
41+
},
42+
getWebhookId() {
43+
return this.db.get("webhookId");
44+
},
45+
isRelevant() {
46+
return true;
47+
},
48+
getObject() {
49+
throw new ConfigurationError("getObject is not implemented");
50+
},
51+
getAction() {
52+
throw new ConfigurationError("getAction is not implemented");
53+
},
54+
generateMeta() {
55+
throw new ConfigurationError("generateMeta is not implemented");
56+
},
57+
},
58+
async run({ body }) {
59+
this.http.respond({
60+
status: 200,
61+
});
62+
if (!this.isRelevant(body)) {
63+
return;
64+
}
65+
this.$emit(body, this.generateMeta(body));
66+
},
67+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import common from "../common/base-webhook.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
...common,
6+
key: "cloudbeds-new-guest-created",
7+
name: "New Guest Created (Instant)",
8+
description: "Emit new event when a new guest is created in Cloudbeds. [See the documentation](https://developers.cloudbeds.com/reference/post_postwebhook-2)",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
methods: {
13+
...common.methods,
14+
getObject() {
15+
return "guest";
16+
},
17+
getAction() {
18+
return "created";
19+
},
20+
generateMeta(body) {
21+
return {
22+
id: body.guestId,
23+
summary: `New guest created with ID: ${body.guestId}`,
24+
ts: Math.floor(body.timestamp * 1000),
25+
};
26+
},
27+
},
28+
sampleEmit,
29+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default {
2+
"propertyId": 318267,
3+
"propertyId_str": "318267",
4+
"guestId": 159926682,
5+
"guestId_str": "159926682",
6+
"version": "1.0",
7+
"event": "guest/created",
8+
"timestamp": 1766005021.042568
9+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import common from "../common/base-webhook.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
...common,
6+
key: "cloudbeds-new-reservation-created",
7+
name: "New Reservation Created (Instant)",
8+
description: "Emit new event when a new reservation is created in Cloudbeds. [See the documentation](https://developers.cloudbeds.com/reference/post_postwebhook-2)",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
methods: {
13+
...common.methods,
14+
getObject() {
15+
return "reservation";
16+
},
17+
getAction() {
18+
return "created";
19+
},
20+
generateMeta(body) {
21+
return {
22+
id: body.reservationID,
23+
summary: `New reservation created with ID: ${body.reservationID}`,
24+
ts: Math.floor(body.timestamp * 1000),
25+
};
26+
},
27+
},
28+
sampleEmit,
29+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default {
2+
"reservationID": "7061304407766",
3+
"propertyID": 318267,
4+
"propertyID_str": "318267",
5+
"startDate": "2025-12-17",
6+
"endDate": "2025-12-18",
7+
"version": "1.0",
8+
"event": "reservation/created",
9+
"timestamp": 1766005022.073195
10+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import common from "../common/base-webhook.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
...common,
6+
key: "cloudbeds-new-transaction-created",
7+
name: "New Transaction Created (Instant)",
8+
description: "Emit new event when a new transaction is created in Cloudbeds. [See the documentation](https://developers.cloudbeds.com/reference/post_postwebhook-2)",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
methods: {
13+
...common.methods,
14+
getObject() {
15+
return "accounting";
16+
},
17+
getAction() {
18+
return "transaction";
19+
},
20+
generateMeta(body) {
21+
return {
22+
id: body.transactionId,
23+
summary: `New transaction created with ID: ${body.transactionId}`,
24+
ts: Date.parse(body.transactionDateTime),
25+
};
26+
},
27+
},
28+
sampleEmit,
29+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default {
2+
"version": "1.0",
3+
"propertyId": "12345",
4+
"event": "accounting/transaction",
5+
"internalTransactionCode": "8100",
6+
"serviceDate": "2025-09-24",
7+
"transactionDateTime": "2025-09-24T14:01:17",
8+
"transactionId": "148785457922303",
9+
"parentTransactionId": null,
10+
}

0 commit comments

Comments
 (0)