Skip to content

Commit 789d109

Browse files
authored
New Components - fillout (#12690)
* fillout init * [Components] fillout #12553 Sources - New Submission (Instant) * pnpm update
1 parent a654cca commit 789d109

File tree

5 files changed

+184
-7
lines changed

5 files changed

+184
-7
lines changed

components/fillout/fillout.app.mjs

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,58 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "fillout",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
formId: {
8+
type: "string",
9+
label: "Form ID",
10+
description: "The ID of the form",
11+
async options() {
12+
const forms = await this.getForms();
13+
return forms.map((form) => ({
14+
label: form.name,
15+
value: form.formId,
16+
}));
17+
},
18+
},
19+
},
520
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
21+
_baseUrl() {
22+
return "https://api.fillout.com/v1/api";
23+
},
24+
_headers() {
25+
return {
26+
Authorization: `Bearer ${this.$auth.oauth_access_token}`,
27+
};
28+
},
29+
_makeRequest({
30+
$ = this, path, ...opts
31+
}) {
32+
return axios($, {
33+
url: this._baseUrl() + path,
34+
headers: this._headers(),
35+
...opts,
36+
});
37+
},
38+
getForms() {
39+
return this._makeRequest({
40+
path: "/forms",
41+
});
42+
},
43+
createWebhook(opts = {}) {
44+
return this._makeRequest({
45+
method: "POST",
46+
path: "/webhook/create",
47+
...opts,
48+
});
49+
},
50+
deleteWebhook(opts = {}) {
51+
return this._makeRequest({
52+
method: "POST",
53+
path: "/webhook/delete",
54+
...opts,
55+
});
956
},
1057
},
1158
};

components/fillout/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/fillout",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Fillout Components",
55
"main": "fillout.app.mjs",
66
"keywords": [
@@ -11,5 +11,9 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.0"
1417
}
15-
}
18+
}
19+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import fillout from "../../fillout.app.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
key: "fillout-new-submission-instant",
6+
name: "New Submission (Instant)",
7+
description: "Emit new event when a form receives a new submission.",
8+
version: "0.0.1",
9+
type: "source",
10+
dedupe: "unique",
11+
props: {
12+
fillout,
13+
http: {
14+
type: "$.interface.http",
15+
customResponse: false,
16+
},
17+
db: "$.service.db",
18+
formId: {
19+
propDefinition: [
20+
fillout,
21+
"formId",
22+
],
23+
},
24+
},
25+
hooks: {
26+
async activate() {
27+
const data = await this.fillout.createWebhook({
28+
data: {
29+
formId: this.formId,
30+
url: this.http.endpoint,
31+
},
32+
});
33+
this.db.set("webhookId", data.id);
34+
},
35+
async deactivate() {
36+
const webhookId = this.db.get("webhookId");
37+
if (webhookId) {
38+
await this.fillout.deleteWebhook({
39+
data: {
40+
webhookId,
41+
},
42+
});
43+
}
44+
},
45+
},
46+
async run({ body }) {
47+
this.$emit(body, {
48+
id: body.submission.submissionId,
49+
summary: `New submission from form ${body.submission.submissionId}`,
50+
ts: body.submission.submissionTime,
51+
});
52+
},
53+
sampleEmit,
54+
};
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
export default {
2+
"formId": "m5q5df45apus",
3+
"formName": "Form Name",
4+
"submission": {
5+
"submissionId": "abc",
6+
"submissionTime": "2024-05-16T23:20:05.324Z",
7+
"lastUpdatedAt": "2024-05-16T23:20:05.324Z",
8+
"questions": [
9+
{
10+
"id": "abcdef",
11+
"name": "What's your name?",
12+
"type": "ShortAnswer",
13+
"value": "Timmy"
14+
},
15+
],
16+
"calculations": [
17+
{
18+
"id": "calculation1",
19+
"name": "price",
20+
"type": "number",
21+
"value": "12.50"
22+
}
23+
],
24+
"urlParameters": [
25+
{
26+
"id": "email",
27+
"name": "email",
28+
"value": "[email protected]",
29+
}
30+
],
31+
"quiz": {
32+
"score": 5,
33+
"maxScore": 10
34+
},
35+
"scheduling": [
36+
{
37+
"id": "nLJtxBJgPA",
38+
"name": "30 min meeting",
39+
"value": {
40+
"fullName": "John Smith",
41+
"email": "[email protected]",
42+
"timezone": "Europe/London",
43+
"eventStartTime": "2024-05-20T09:00:00.000Z",
44+
"eventEndTime": "2024-05-20T09:30:00.000Z",
45+
"eventId": "du5ckkaeacd5dlj16d7ajepp8g",
46+
"eventUrl": "https://www.google.com/calendar/event?eid=ZHU1Y2trYWVhY2Q1ZGxqMTZkN2FqZXBwOGcgYXJjaGllQGZpbGxvdXQuY29t&authuser=john%40smith.com"
47+
}
48+
}
49+
],
50+
"payments": [
51+
{
52+
"id": "cLJtxCKgdL",
53+
"name": "Complete checkout",
54+
"value": {
55+
"stripeCustomerId": "cus_Ppjz3Z80000000",
56+
"stripeCustomerUrl": "https://dashboard.stripe.com/customers/cus_Ppjz3Z80000000",
57+
"stripePaymentUrl": "https://dashboard.stripe.com/payments/pi_3PRF2cFMP2ckdpfG0s0ZdJqf",
58+
"totalAmount": 1000,
59+
"currency": "USD",
60+
"email": "[email protected]",
61+
"discountCode": "10OFF",
62+
"status": "succeeded",
63+
"paymentId": "pi_3PRF2cFMP2ckdpfG0s0ZdJqf",
64+
"stripeSubscriptionId": "sub_Ppjz3Z80000000"
65+
}
66+
}
67+
],
68+
}
69+
}

pnpm-lock.yaml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)