Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions components/slottable/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/slottable",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Slottable Components",
"main": "slottable.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.5.1"
}
}
}
49 changes: 46 additions & 3 deletions components/slottable/slottable.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,54 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "slottable",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://slottable.app/api/v1";
},
_headers() {
return {
"Authorization": `Bearer ${this.$auth.api_token}`,
"Accept": "application/json",
"Content-Type": "application/json",
};
},
_makeRequest({
$ = this,
path,
...args
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
headers: this._headers(),
...args,
});
},
async getCompanyId() {
const { data: { attributes: { company_id } } } = await this._makeRequest({
path: "/token",
});
return company_id;
},
createWebhook({
companyId, ...args
}) {
return this._makeRequest({
path: `/companies/${companyId}/webhooks`,
method: "POST",
...args,
});
},
deleteWebhook({
companyId, hookId, ...args
}) {
return this._makeRequest({
path: `/companies/${companyId}/webhooks/${hookId}`,
method: "DELETE",
...args,
});
},
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import common from "../common/base.mjs";

export default {
...common,
key: "slottable-booking-contact-updated",
name: "Booking Contact Updated",
version: "0.0.1",
description: "Emit new event when a booking contact is changed (new, updated, or deleted) in Slottable.",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getModel() {
return "BookingContact";
},
generateMeta(contact) {
const ts = Date.parse(contact.updated_at);
return {
id: `${contact.id}-${ts}`,
summary: `Booking Contact Updated with ID ${contact.id}`,
ts,
};
},
},
};
53 changes: 53 additions & 0 deletions components/slottable/sources/common/base.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import slottable from "../../slottable.app.mjs";

export default {
props: {
slottable,
db: "$.service.db",
http: "$.interface.http",
},
hooks: {
async activate() {
const companyId = await this.slottable.getCompanyId();
const { data: { id } } = await this.slottable.createWebhook({
companyId,
data: {
url: this.http.endpoint,
method: "post",
model: this.getModel(),
events: "changed",
},
});
this._setHookId(id);
},
async deactivate() {
const companyId = await this.slottable.getCompanyId();
const hookId = this._getHookId();
if (hookId) {
await this.slottable.deleteWebhook({
companyId,
hookId,
});
}
},
},
methods: {
_getHookId() {
return this.db.get("hookId");
},
_setHookId(hookId) {
this.db.set("hookId", hookId);
},
getModel() {
throw new Error("getModel is not implemented");
},
generateMeta() {
throw new Error("generateMeta is not implemented");
},
},
async run(event) {
const { body } = event;
const meta = this.generateMeta(body.data);
this.$emit(body, meta);
},
};
25 changes: 25 additions & 0 deletions components/slottable/sources/contact-updated/contact-updated.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import common from "../common/base.mjs";

export default {
...common,
key: "slottable-contact-updated",
name: "Contact Updated",
version: "0.0.1",
description: "Emit new event when a contact is changed (new, updated, or deleted) in Slottable.",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getModel() {
return "Contact";
},
generateMeta(contact) {
const ts = Date.parse(contact.updated_at);
return {
id: `${contact.id}-${ts}`,
summary: `Contact Updated with ID ${contact.id}`,
ts,
};
},
},
};
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.