-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Cloudbeds - new components #19529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+321
−71
Merged
Cloudbeds - new components #19529
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,4 +8,4 @@ export default { | |
| console.log(Object.keys(this.$auth)); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,39 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "cloudbeds", | ||
| propDefinitions: {}, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://api.cloudbeds.com/api/v1.3"; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, path, headers, ...opts | ||
| }) { | ||
| return axios($, { | ||
| url: `${this._baseUrl()}/${path}`, | ||
| headers: { | ||
| ...headers, | ||
| "x-api-key": `${this.$auth.api_key}`, | ||
| "accept": "application/json", | ||
| }, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| createWebhook(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/postWebhook", | ||
| method: "POST", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| deleteWebhook(opts = {}) { | ||
| return this._makeRequest({ | ||
| path: "/deleteWebhook", | ||
| method: "DELETE", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import cloudbeds from "../../cloudbeds.app.mjs"; | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| props: { | ||
| cloudbeds, | ||
| db: "$.service.db", | ||
| http: { | ||
| type: "$.interface.http", | ||
| customResponse: true, | ||
| }, | ||
| }, | ||
| hooks: { | ||
| async activate() { | ||
| const { data: { subscriptionID: id } } = await this.cloudbeds.createWebhook({ | ||
| data: { | ||
| endpointUrl: this.http.endpoint, | ||
| object: this.getObject(), | ||
| action: this.getAction(), | ||
| }, | ||
| headers: { | ||
| "Content-Type": "application/x-www-form-urlencoded", | ||
| }, | ||
| }); | ||
| this.setWebhookId(id); | ||
| }, | ||
| async deactivate() { | ||
| const webhookId = this.getWebhookId(); | ||
| if (webhookId) { | ||
| await this.cloudbeds.deleteWebhook({ | ||
| params: { | ||
| subscriptionID: webhookId, | ||
| }, | ||
| }); | ||
| } | ||
| }, | ||
| }, | ||
| methods: { | ||
| setWebhookId(value) { | ||
| this.db.set("webhookId", value); | ||
| }, | ||
| getWebhookId() { | ||
| return this.db.get("webhookId"); | ||
| }, | ||
| isRelevant() { | ||
| return true; | ||
| }, | ||
| getObject() { | ||
| throw new ConfigurationError("getObject is not implemented"); | ||
| }, | ||
| getAction() { | ||
| throw new ConfigurationError("getAction is not implemented"); | ||
| }, | ||
| generateMeta() { | ||
| throw new ConfigurationError("generateMeta is not implemented"); | ||
| }, | ||
| }, | ||
| async run({ body }) { | ||
| this.http.respond({ | ||
| status: 200, | ||
| }); | ||
| if (!this.isRelevant(body)) { | ||
| return; | ||
| } | ||
| this.$emit(body, this.generateMeta(body)); | ||
| }, | ||
| }; | ||
29 changes: 29 additions & 0 deletions
29
components/cloudbeds/sources/new-guest-created/new-guest-created.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import common from "../common/base-webhook.mjs"; | ||
| import sampleEmit from "./test-event.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "cloudbeds-new-guest-created", | ||
| name: "New Guest Created (Instant)", | ||
| description: "Emit new event when a new guest is created in Cloudbeds. [See the documentation](https://developers.cloudbeds.com/reference/post_postwebhook-2)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getObject() { | ||
| return "guest"; | ||
| }, | ||
| getAction() { | ||
| return "created"; | ||
| }, | ||
| generateMeta(body) { | ||
| return { | ||
| id: body.guestId, | ||
| summary: `New guest created with ID: ${body.guestId}`, | ||
| ts: Math.floor(body.timestamp * 1000), | ||
| }; | ||
| }, | ||
| }, | ||
| sampleEmit, | ||
| }; |
9 changes: 9 additions & 0 deletions
9
components/cloudbeds/sources/new-guest-created/test-event.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| export default { | ||
| "propertyId": 318267, | ||
| "propertyId_str": "318267", | ||
| "guestId": 159926682, | ||
| "guestId_str": "159926682", | ||
| "version": "1.0", | ||
| "event": "guest/created", | ||
| "timestamp": 1766005021.042568 | ||
| } |
29 changes: 29 additions & 0 deletions
29
components/cloudbeds/sources/new-reservation-created/new-reservation-created.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import common from "../common/base-webhook.mjs"; | ||
| import sampleEmit from "./test-event.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "cloudbeds-new-reservation-created", | ||
| name: "New Reservation Created (Instant)", | ||
| description: "Emit new event when a new reservation is created in Cloudbeds. [See the documentation](https://developers.cloudbeds.com/reference/post_postwebhook-2)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getObject() { | ||
| return "reservation"; | ||
| }, | ||
| getAction() { | ||
| return "created"; | ||
| }, | ||
| generateMeta(body) { | ||
| return { | ||
| id: body.reservationID, | ||
| summary: `New reservation created with ID: ${body.reservationID}`, | ||
| ts: Math.floor(body.timestamp * 1000), | ||
| }; | ||
| }, | ||
| }, | ||
| sampleEmit, | ||
| }; |
10 changes: 10 additions & 0 deletions
10
components/cloudbeds/sources/new-reservation-created/test-event.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| export default { | ||
| "reservationID": "7061304407766", | ||
| "propertyID": 318267, | ||
| "propertyID_str": "318267", | ||
| "startDate": "2025-12-17", | ||
| "endDate": "2025-12-18", | ||
| "version": "1.0", | ||
| "event": "reservation/created", | ||
| "timestamp": 1766005022.073195 | ||
| } |
29 changes: 29 additions & 0 deletions
29
components/cloudbeds/sources/new-transaction-created/new-transaction-created.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import common from "../common/base-webhook.mjs"; | ||
| import sampleEmit from "./test-event.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "cloudbeds-new-transaction-created", | ||
| name: "New Transaction Created (Instant)", | ||
| description: "Emit new event when a new transaction is created in Cloudbeds. [See the documentation](https://developers.cloudbeds.com/reference/post_postwebhook-2)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getObject() { | ||
| return "accounting"; | ||
| }, | ||
| getAction() { | ||
| return "transaction"; | ||
| }, | ||
| generateMeta(body) { | ||
| return { | ||
| id: body.transactionId, | ||
| summary: `New transaction created with ID: ${body.transactionId}`, | ||
| ts: Date.parse(body.transactionDateTime), | ||
| }; | ||
| }, | ||
| }, | ||
| sampleEmit, | ||
| }; |
10 changes: 10 additions & 0 deletions
10
components/cloudbeds/sources/new-transaction-created/test-event.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| export default { | ||
| "version": "1.0", | ||
| "propertyId": "12345", | ||
| "event": "accounting/transaction", | ||
| "internalTransactionCode": "8100", | ||
| "serviceDate": "2025-09-24", | ||
| "transactionDateTime": "2025-09-24T14:01:17", | ||
| "transactionId": "148785457922303", | ||
| "parentTransactionId": null, | ||
| } | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
50 changes: 50 additions & 0 deletions
50
components/cloudbeds/sources/reservation-status-changed/reservation-status-changed.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import common from "../common/base-webhook.mjs"; | ||
| import sampleEmit from "./test-event.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "cloudbeds-reservation-status-changed", | ||
| name: "Reservation Status Changed (Instant)", | ||
| description: "Emit new event when a reservation status is changed in Cloudbeds. [See the documentation](https://developers.cloudbeds.com/reference/post_postwebhook-2)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| props: { | ||
| ...common.props, | ||
| statuses: { | ||
| type: "string[]", | ||
| label: "Statuses", | ||
| description: "Watch for reservations that have been updated to the selected statuses", | ||
| options: [ | ||
| "in_progress", | ||
| "confirmed", | ||
| "not_confirmed", | ||
| "canceled", | ||
| "checked_in", | ||
| "checked_out", | ||
| "no_show", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| }, | ||
| methods: { | ||
| ...common.methods, | ||
| getObject() { | ||
| return "reservation"; | ||
| }, | ||
| getAction() { | ||
| return "status_changed"; | ||
| }, | ||
| isRelevant(body) { | ||
| return !this.statuses?.length || this.statuses.includes(body.status); | ||
| }, | ||
| generateMeta(body) { | ||
| return { | ||
| id: `${body.reservationID}-${body.timestamp}`, | ||
| summary: `Reservation status changed to ${body.status}`, | ||
| ts: Math.floor(body.timestamp * 1000), | ||
| }; | ||
| }, | ||
| }, | ||
| sampleEmit, | ||
| }; | ||
13 changes: 13 additions & 0 deletions
13
components/cloudbeds/sources/reservation-status-changed/test-event.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| export default { | ||
| "reservationID": "7061304407766", | ||
| "propertyID": 318267, | ||
| "propertyID_str": "318267", | ||
| "status": "canceled", | ||
| "actor": { | ||
| "type": "user", | ||
| "id": "568158" | ||
| }, | ||
| "version": "1.0", | ||
| "event": "reservation/status_changed", | ||
| "timestamp": 1766005381.816514 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,4 +8,4 @@ export default { | |
| console.log(Object.keys(this.$auth)); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.