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
80 changes: 76 additions & 4 deletions components/opnform/opnform.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,83 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "opnform",
propDefinitions: {},
propDefinitions: {
workspaceId: {
type: "string",
label: "Workspace ID",
description: "The ID of the workspace containing the forms.",
async options() {
const worspaces = await this.listWorkspaces();
return worspaces.map(({
id: value, name: label,
}) => ({
label,
value,
}));
},
},
formId: {
type: "string",
label: "Form",
description: "Select the form to monitor for new submissions.",
async options({ workspaceId }) {
const forms = await this.listForms({
params: {
workspace_id: workspaceId,
},
});
return forms.map((form) => ({
label: form.name,
value: form.id,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.opnform.com/external/zapier";
},
_headers() {
return {
Authorization: `Bearer ${this.$auth.api_key}`,
};
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: this._baseUrl() + path,
headers: this._headers(),
...opts,
});
},
listForms(opts = {}) {
return this._makeRequest({
path: "/forms",
...opts,
});
},
listWorkspaces(opts = {}) {
return this._makeRequest({
path: "/workspaces",
...opts,
});
},
createWebhook(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/webhook",
...opts,
});
},
deleteWebhook(opts = {}) {
return this._makeRequest({
method: "DELETE",
path: "/webhook",
...opts,
});
},
},
};
5 changes: 4 additions & 1 deletion components/opnform/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/opnform",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream OpnForm Components",
"main": "opnform.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import opnform from "../../opnform.app.mjs";
import sampleEmit from "./test-event.mjs";

export default {
key: "opnform-new-submission-instant",
name: "New Submission Instant",
description: "Emit new event when a form receives a submission.",
version: "0.0.1",
type: "source",
dedupe: "unique",
props: {
opnform,
http: "$.interface.http",
db: "$.service.db",
workspaceId: {
propDefinition: [
opnform,
"workspaceId",
],
},
formId: {
propDefinition: [
opnform,
"formId",
({ workspaceId }) => ({
workspaceId,
}),
],
},
},
hooks: {
async activate() {
await this.opnform.createWebhook({
data: {
hookUrl: this.http.endpoint,
form_id: this.formId,
},
});
},
async deactivate() {
await this.opnform.deleteWebhook({
data: {
hookUrl: this.http.endpoint,
form_id: this.formId,
},
});
},
},
async run({ body }) {
const ts = Date.now();
this.$emit(body, {
id: `${body.form_slug}-${ts}`,
summary: `New submission for "${body.form_title}"`,
ts,
});
},
sampleEmit,
};
24 changes: 24 additions & 0 deletions components/opnform/sources/new-submission-instant/test-event.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export default {
"form_title": "My Form",
"form_slug": "my-form-dtewbq",
"submission": {
"Name": "User Name",
"Email": "[email protected]",
"Message": "User Message"
},
"data": {
"3cc8fbba-1234-1234-979d-0e81d8f6845c": {
"value": "USer Name",
"name": "Name"
},
"9a1778ff-1234-1234-a62c-197dae1ed3c0": {
"value": "[email protected]",
"name": "Email"
},
"ddd28630-1234-1234-bbe5-4f58c485d470": {
"value": "USer Message",
"name": "Message"
}
},
"message": "Please do not use the `submission` field. It is deprecated and will be removed in the future."
}
15 changes: 8 additions & 7 deletions pnpm-lock.yaml

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

Loading