Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
51 changes: 51 additions & 0 deletions components/icontact/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import icontact from "../../icontact.app.mjs";
import { axios } from "@pipedream/platform";

Check failure on line 2 in components/icontact/actions/create-contact/create-contact.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'axios' is defined but never used

export default {
key: "icontact-create-contact",
name: "Create Contact",
description: "Creates a new contact within the iContact account. [See the documentation](https://help.icontact.com/customers/s/article/contacts-icontact-api)",
version: "0.0.1",
type: "action",
props: {
icontact,
contactEmail: {
propDefinition: [
icontact,
"contactEmail",
],
},
contactInfo: {
propDefinition: [
icontact,
"contactInfo",
],
optional: true,
},
firstName: {
propDefinition: [
icontact,
"firstName",
],
optional: true,
},
lastName: {
propDefinition: [
icontact,
"lastName",
],
optional: true,
},
},
async run({ $ }) {
const response = await this.icontact.createContact({
contactEmail: this.contactEmail,
contactInfo: this.contactInfo || {},
firstName: this.firstName,
lastName: this.lastName,
});

$.export("$summary", `Successfully created contact with email ${this.contactEmail}`);
return response;
},
};
49 changes: 49 additions & 0 deletions components/icontact/actions/create-message/create-message.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import icontact from "../../icontact.app.mjs";
import { axios } from "@pipedream/platform";

Check failure on line 2 in components/icontact/actions/create-message/create-message.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'axios' is defined but never used

export default {
key: "icontact-create-message",
name: "Create and Dispatch Message",
description: "Creates and dispatches a new message using custom HTML. [See the documentation](https://help.icontact.com/customers/s/article/messages-icontact-api)",
version: "0.0.{{ts}}",

Check warning on line 8 in components/icontact/actions/create-message/create-message.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

{{ts}} macro should be removed before committing
type: "action",
props: {
icontact,
recipientEmail: {
propDefinition: [
icontact,
"recipientEmail",
],
},
senderEmail: {
propDefinition: [
icontact,
"senderEmail",
],
},
htmlContent: {
propDefinition: [
icontact,
"htmlContent",
],
},
subject: {
propDefinition: [
icontact,
"subject",
],
optional: true,
},
},
async run({ $ }) {
const response = await this.icontact.createAndSendMessage({
recipientEmail: this.recipientEmail,
senderEmail: this.senderEmail,
htmlContent: this.htmlContent,
subject: this.subject,
});

$.export("$summary", `Message sent successfully to ${this.recipientEmail}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import icontact from "../../icontact.app.mjs";
import { axios } from "@pipedream/platform";

Check failure on line 2 in components/icontact/actions/subscribe-contact-list/subscribe-contact-list.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

'axios' is defined but never used

export default {
key: "icontact-subscribe-contact-list",
name: "Subscribe Contact to List",
description: "Adds a contact to a specific list within iContact. [See the documentation](https://help.icontact.com/customers/s/article/subscriptions-icontact-api)",
version: "0.0.{{ts}}",

Check warning on line 8 in components/icontact/actions/subscribe-contact-list/subscribe-contact-list.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

{{ts}} macro should be removed before committing
type: "action",
props: {
icontact,
contactEmail: {
propDefinition: [
icontact,
"contactEmail",
],
},
listId: {
propDefinition: [
icontact,
"listId",
],
},
},
async run({ $ }) {
const response = await this.icontact.subscribeContactToList({
contactEmail: this.contactEmail,
listId: this.listId,
});

$.export("$summary", `Successfully subscribed ${this.contactEmail} to list with ID ${this.listId}`);
return response;
},
};
2 changes: 1 addition & 1 deletion components/icontact/app/icontact.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export default defineApp({
console.log(Object.keys(this.$auth));
},
},
});
});
167 changes: 167 additions & 0 deletions components/icontact/icontact.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "icontact",
propDefinitions: {
contactEmail: {
type: "string",
label: "Contact Email",
description: "The email of the contact",
},
contactInfo: {
type: "object",
label: "Contact Information",
description: "Additional information for the contact",
},
contactId: {
type: "string",
label: "Contact ID",
description: "The ID of the contact",
},
listId: {
type: "string",
label: "List ID",
description: "The ID of the list",
async options() {
const lists = await this.getLists();
return lists.map((list) => ({
label: list.name,
value: list.id,
}));
},
},
senderEmail: {
type: "string",
label: "Sender Email",
description: "The email of the sender",
},
recipientEmail: {
type: "string",
label: "Recipient Email",
description: "The email of the recipient",
},
htmlContent: {
type: "string",
label: "HTML Content",
description: "The HTML content for the message",
},
subject: {
type: "string",
label: "Subject",
description: "The subject of the message",
optional: true,
},
firstName: {
type: "string",
label: "First Name",
description: "The contact's first name",
optional: true,
},
lastName: {
type: "string",
label: "Last Name",
description: "The contact's last name",
optional: true,
},
},
methods: {
_baseUrl() {
return "https://api.icontact.com/v2.0";
},
async _makeRequest(opts = {}) {
const {
$ = this,
method = "GET",
path = "/",
headers = {},
...otherOpts
} = opts;
return axios($, {
...otherOpts,
method,
url: this._baseUrl() + path,
headers: {
...headers,
"Content-Type": "application/json",
"Authorization": `Bearer ${this.$auth.api_key}`,
},
});
},
async getLists(opts = {}) {
return this._makeRequest({
path: "/lists",
...opts,
});
},
async createContact({
contactEmail, contactInfo, firstName, lastName, ...opts
}) {
return this._makeRequest({
method: "POST",
path: "/contacts",
data: {
email: contactEmail,
firstName,
lastName,
...contactInfo,
},
...opts,
});
},
async updateContact({
contactId, contactInfo, ...opts
}) {
return this._makeRequest({
method: "PUT",
path: `/contacts/${contactId}`,
data: contactInfo,
...opts,
});
},
async subscribeContactToList({
contactEmail, listId, ...opts
}) {
return this._makeRequest({
method: "POST",
path: `/lists/${listId}/contacts`,
data: {
email: contactEmail,
},
...opts,
});
},
async createAndSendMessage({
recipientEmail,
senderEmail,
htmlContent,
subject,
...opts
}) {
return this._makeRequest({
method: "POST",
path: "/messages",
data: {
recipient: recipientEmail,
sender: senderEmail,
message: {
body: htmlContent,
subject,
},
},
...opts,
});
},
},
hooks: {
async contactCreated() {
// Emit a new event when a contact is created.
},
async contactUpdated() {
// Emit a new event when a contact is updated.
},
async contactSubscribed() {
// Emit a new event when a contact is subscribed to a list.
},
},
};
Loading
Loading