-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fillout init * [Components] fillout #12553 Sources - New Submission (Instant) * pnpm update
- Loading branch information
1 parent
a654cca
commit 789d109
Showing
5 changed files
with
184 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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,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, | ||
}); | ||
}, | ||
}, | ||
}; |
This file contains 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,6 +1,6 @@ | ||
{ | ||
"name": "@pipedream/fillout", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Pipedream Fillout Components", | ||
"main": "fillout.app.mjs", | ||
"keywords": [ | ||
|
@@ -11,5 +11,9 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.0.0" | ||
} | ||
} | ||
} | ||
|
54 changes: 54 additions & 0 deletions
54
components/fillout/sources/new-submission-instant/new-submission-instant.mjs
This file contains 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,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
69
components/fillout/sources/new-submission-instant/test-event.mjs
This file contains 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,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": "[email protected]", | ||
} | ||
], | ||
"quiz": { | ||
"score": 5, | ||
"maxScore": 10 | ||
}, | ||
"scheduling": [ | ||
{ | ||
"id": "nLJtxBJgPA", | ||
"name": "30 min meeting", | ||
"value": { | ||
"fullName": "John Smith", | ||
"email": "[email protected]", | ||
"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": "[email protected]", | ||
"discountCode": "10OFF", | ||
"status": "succeeded", | ||
"paymentId": "pi_3PRF2cFMP2ckdpfG0s0ZdJqf", | ||
"stripeSubscriptionId": "sub_Ppjz3Z80000000" | ||
} | ||
} | ||
], | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.