Skip to content

Commit

Permalink
New Components - fillout (#12690)
Browse files Browse the repository at this point in the history
* fillout init

* [Components] fillout #12553
Sources
 - New Submission (Instant)

* pnpm update
  • Loading branch information
luancazarine committed Jul 4, 2024
1 parent a654cca commit 789d109
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 7 deletions.
55 changes: 51 additions & 4 deletions components/fillout/fillout.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,58 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "fillout",
propDefinitions: {},
propDefinitions: {
formId: {
type: "string",
label: "Form ID",
description: "The ID of the form",
async options() {
const forms = await this.getForms();
return forms.map((form) => ({
label: form.name,
value: form.formId,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.fillout.com/v1/api";
},
_headers() {
return {
Authorization: `Bearer ${this.$auth.oauth_access_token}`,
};
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: this._baseUrl() + path,
headers: this._headers(),
...opts,
});
},
getForms() {
return this._makeRequest({
path: "/forms",
});
},
createWebhook(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/webhook/create",
...opts,
});
},
deleteWebhook(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/webhook/delete",
...opts,
});
},
},
};
8 changes: 6 additions & 2 deletions components/fillout/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/fillout",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Fillout Components",
"main": "fillout.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,9 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.0"
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import fillout from "../../fillout.app.mjs";
import sampleEmit from "./test-event.mjs";

export default {
key: "fillout-new-submission-instant",
name: "New Submission (Instant)",
description: "Emit new event when a form receives a new submission.",
version: "0.0.1",
type: "source",
dedupe: "unique",
props: {
fillout,
http: {
type: "$.interface.http",
customResponse: false,
},
db: "$.service.db",
formId: {
propDefinition: [
fillout,
"formId",
],
},
},
hooks: {
async activate() {
const data = await this.fillout.createWebhook({
data: {
formId: this.formId,
url: this.http.endpoint,
},
});
this.db.set("webhookId", data.id);
},
async deactivate() {
const webhookId = this.db.get("webhookId");
if (webhookId) {
await this.fillout.deleteWebhook({
data: {
webhookId,
},
});
}
},
},
async run({ body }) {
this.$emit(body, {
id: body.submission.submissionId,
summary: `New submission from form ${body.submission.submissionId}`,
ts: body.submission.submissionTime,
});
},
sampleEmit,
};
69 changes: 69 additions & 0 deletions components/fillout/sources/new-submission-instant/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
export default {
"formId": "m5q5df45apus",
"formName": "Form Name",
"submission": {
"submissionId": "abc",
"submissionTime": "2024-05-16T23:20:05.324Z",
"lastUpdatedAt": "2024-05-16T23:20:05.324Z",
"questions": [
{
"id": "abcdef",
"name": "What's your name?",
"type": "ShortAnswer",
"value": "Timmy"
},
],
"calculations": [
{
"id": "calculation1",
"name": "price",
"type": "number",
"value": "12.50"
}
],
"urlParameters": [
{
"id": "email",
"name": "email",
"value": "example@example.com",
}
],
"quiz": {
"score": 5,
"maxScore": 10
},
"scheduling": [
{
"id": "nLJtxBJgPA",
"name": "30 min meeting",
"value": {
"fullName": "John Smith",
"email": "john@smith.com",
"timezone": "Europe/London",
"eventStartTime": "2024-05-20T09:00:00.000Z",
"eventEndTime": "2024-05-20T09:30:00.000Z",
"eventId": "du5ckkaeacd5dlj16d7ajepp8g",
"eventUrl": "https://www.google.com/calendar/event?eid=ZHU1Y2trYWVhY2Q1ZGxqMTZkN2FqZXBwOGcgYXJjaGllQGZpbGxvdXQuY29t&authuser=john%40smith.com"
}
}
],
"payments": [
{
"id": "cLJtxCKgdL",
"name": "Complete checkout",
"value": {
"stripeCustomerId": "cus_Ppjz3Z80000000",
"stripeCustomerUrl": "https://dashboard.stripe.com/customers/cus_Ppjz3Z80000000",
"stripePaymentUrl": "https://dashboard.stripe.com/payments/pi_3PRF2cFMP2ckdpfG0s0ZdJqf",
"totalAmount": 1000,
"currency": "USD",
"email": "john@doe.com",
"discountCode": "10OFF",
"status": "succeeded",
"paymentId": "pi_3PRF2cFMP2ckdpfG0s0ZdJqf",
"stripeSubscriptionId": "sub_Ppjz3Z80000000"
}
}
],
}
}
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.

0 comments on commit 789d109

Please sign in to comment.