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
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import app from "../../webinarfuel.app.mjs";

export default {
key: "webinarfuel-add-new-registrant",
name: "Add New Registrant",
description: "Creates a new registrant for a selected webinar. [See the documentation](https://webinarfuel.docs.apiary.io/#/reference/registrant/registrants-collection/create-registrant/200?mc=reference%2Fregistrant%2Fregistrants-collection%2Fcreate-registrant%2F200)",
version: "0.0.1",
type: "action",
props: {
app,
webinarId: {
propDefinition: [
app,
"webinarId",
],
},
email: {
propDefinition: [
app,
"email",
],
},
firstName: {
propDefinition: [
app,
"firstName",
],
},
tags: {
optional: true,
propDefinition: [
app,
"tags",
],
},
webinarSessionId: {
propDefinition: [
app,
"webinarSessionId",
({ webinarId }) => ({
webinarId,
}),
],
},
timeZone: {
optional: true,
propDefinition: [
app,
"timeZone",
],
},
},
methods: {
createRegistrant(args = {}) {
return this.app.post({
path: "/registrants",
...args,
});
},
},
async run({ $: step }) {
const {
createRegistrant,
webinarId,
email,
firstName,
tags,
webinarSessionId,
timeZone,
} = this;

return createRegistrant({
step,
data: {
webinar_id: webinarId,
registrant: {
email,
first_name: firstName,
tags,
},
session: {
webinar_session_id: webinarSessionId,
timezone: timeZone,
},
},
summary: (response) => `Successfully added new registrant with email: ${response.email}`,
});
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import app from "../../webinarfuel.app.mjs";

export default {
key: "webinarfuel-add-tags-to-registrant",
name: "Add Tags To Registrant",
description: "Adds tags to an existing registrant. [See the documentation](https://webinarfuel.docs.apiary.io/#/reference/registrant/add-tags)",
version: "0.0.1",
type: "action",
props: {
app,
email: {
propDefinition: [
app,
"email",
],
},
tags: {
propDefinition: [
app,
"tags",
],
},
},
methods: {
addTags(args = {}) {
return this.app.post({
path: "/registrants/add_tags",
...args,
});
},
},
async run({ $: step }) {
const {
addTags,
email,
tags,
} = this;

return addTags({
step,
data: {
email,
tags,
},
summary: (response) => `Successfully added tags to registrant email ${response.registrant.email}.`,
});
},
};
7 changes: 7 additions & 0 deletions components/webinarfuel/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const SUMMARY_LABEL = "$summary";
const BASE_URL = "https://api.webinarfuel.com";

export default {
SUMMARY_LABEL,
BASE_URL,
};
4 changes: 2 additions & 2 deletions components/webinarfuel/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/webinarfuel",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream WebinarFuel Components",
"main": "webinarfuel.app.mjs",
"keywords": [
Expand All @@ -12,4 +12,4 @@
"publishConfig": {
"access": "public"
}
}
}
112 changes: 107 additions & 5 deletions components/webinarfuel/webinarfuel.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,113 @@
import {
axios, ConfigurationError,
} from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "webinarfuel",
propDefinitions: {},
propDefinitions: {
webinarId: {
type: "string",
label: "Webinar ID",
description: "The ID of the webinar",
async options({ page }) {
const { webinars } = await this.getWebinars({
params: {
page: page + 1,
},
});
return webinars.map(({
id: value, name: label,
}) => ({
value,
label,
}));
},
},
webinarSessionId: {
type: "string",
label: "Session ID",
description: "The webinar session id.",
async options({ webinarId }) {
const { webinar: { sessions } } = await this.getWebinar({
webinarId,
});
return sessions.map(({
id: value, formatted_scheduled_at: label,
}) => ({
value,
label,
}));
},
},
timeZone: {
type: "string",
label: "Time Zone",
description: "Session [TimeZone name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). Required if webinar timezone is `registrant`. Example: `America/New_York`.",
},
email: {
type: "string",
label: "Email",
description: "The email of the registrant",
},
firstName: {
type: "string",
label: "First Name",
description: "The first name of the registrant",
},
tags: {
type: "string[]",
label: "Tags",
description: "The tags to add to the registrant",
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
exportSummary(step) {
if (!step?.export) {
throw new ConfigurationError("The summary method should be bind to the step object aka `$`");
}
return (msg = "") => step.export(constants.SUMMARY_LABEL, msg);
},
async makeRequest({
step = this, path, headers, summary, ...args
} = {}) {
const config = {
...args,
url: constants.BASE_URL + path,
headers: {
...headers,
"Authorization": `Bearer ${this.$auth.api_key}`,
},
};

const response = await axios(step, config);

if (typeof summary === "function") {
this.exportSummary(step)(summary(response));
}

return response;
},
post(args = {}) {
return this.makeRequest({
method: "post",
...args,
});
},
getWebinars(args = {}) {
return this.makeRequest({
path: "/webinars",
...args,
});
},
getWebinar({
webinarId, ...args
} = {}) {
return this.makeRequest({
path: `/webinars/${webinarId}`,
...args,
});
},
},
};
};