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
3 changes: 0 additions & 3 deletions components/icontact/.gitignore

This file was deleted.

124 changes: 124 additions & 0 deletions components/icontact/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { STATUS_OPTIONS } from "../../common/constants.mjs";
import { checkWarnings } from "../../common/utils.mjs";
import icontact from "../../icontact.app.mjs";

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?r=153&ui-knowledge-components-aura-actions.KnowledgeArticleVersionCreateDraftFromOnlineAction.createDraftFromOnlineArticle=1)",
version: "0.0.1",
type: "action",
props: {
icontact,
email: {
type: "string",
label: "Email",
description: "The contact's email address. **Note: The email address must be unique**.",
},
prefix: {
type: "string",
label: "Prefix",
description: "The contact's salutation. **E.g. Miss**",
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,
},
suffix: {
type: "string",
label: "Suffix",
description: "The contact's name qualifications **E.g. III**.",
optional: true,
},
street: {
type: "string",
label: "Street",
description: "The contact's street address information.",
optional: true,
},
street2: {
type: "string",
label: "Street 2",
description: "The contact's line 2 information.",
optional: true,
},
city: {
type: "string",
label: "City",
description: "The contact's city information.",
optional: true,
},
state: {
type: "string",
label: "State",
description: "The contact's state information.",
optional: true,
},
postalCode: {
type: "string",
label: "Postal Code",
description: "The contact's postal code information.",
optional: true,
},
phone: {
type: "string",
label: "Phone",
description: "The contact's phone number.",
optional: true,
},
fax: {
type: "string",
label: "Fax",
description: "The contact's fax number.",
optional: true,
},
business: {
type: "string",
label: "Business",
description: "The contact's business phone number.",
optional: true,
},
status: {
type: "string",
label: "Status",
description: "The subscription status of the contact.",
options: STATUS_OPTIONS,
optional: true,
},
},
async run({ $ }) {
const {
icontact,
...contact
} = this;

const { contacts } = await icontact.searchContact({
params: {
email: contact.email,
},
});

if (contacts.length) throw new Error("A contact with the provided email already exists.");

const response = await icontact.createContact({
$,
data: {
contact,
},
});

checkWarnings(response);

$.export("$summary", `Successfully created contact with ID: ${response.contacts[0].contactId}`);
return response.contacts[0];
},
};
82 changes: 82 additions & 0 deletions components/icontact/actions/create-message/create-message.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { MESSAGE_TYPE_OPTIONS } from "../../common/constants.mjs";
import { checkWarnings } from "../../common/utils.mjs";
import icontact from "../../icontact.app.mjs";

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?r=153&ui-knowledge-components-aura-actions.KnowledgeArticleVersionCreateDraftFromOnlineAction.createDraftFromOnlineArticle=1)",
version: "0.0.1",
type: "action",
props: {
icontact,
campaignId: {
propDefinition: [
icontact,
"campaignId",
],
},
messageType: {
type: "string",
label: "Message Type",
description: "The kind of message being added.",
options: MESSAGE_TYPE_OPTIONS,
},
subject: {
type: "string",
label: "Subject",
description: "The subject line of the email.",
},
htmlBody: {
type: "string",
label: "HTML Body",
description: "Contains the HTML version of the email message body.",
optional: true,
},
textBody: {
type: "string",
label: "Text Body",
description: "Contains the text version of the email message body.",
optional: true,
},
messageName: {
type: "string",
label: "Message Name",
description: "The reference name of the message. This is used for organizational purposes and will not be seen by your contacts.",
optional: true,
},
previewText: {
type: "string",
label: "Preview Text",
description: "Indicates the preview text that some email systems display before opening the email.",
optional: true,
},
replyToCampaignId: {
propDefinition: [
icontact,
"campaignId",
],
label: "Reply To Campaign Id",
description: "Indicates the sender property where you want reply emails to be sent to.",
optional: true,
},
},
async run({ $ }) {
const {
icontact,
...message
} = this;

const response = await icontact.createMessage({
$,
data: {
message,
},
});

checkWarnings(response);

$.export("$summary", `Successfully created message with ID: ${response.messages[0].messageId}`);
return response.messages[0];
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { checkWarnings } from "../../common/utils.mjs";
import icontact from "../../icontact.app.mjs";

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?r=153&ui-knowledge-components-aura-actions.KnowledgeArticleVersionCreateDraftFromOnlineAction.createDraftFromOnlineArticle=1)",
version: "0.0.1",
type: "action",
props: {
icontact,
contactId: {
propDefinition: [
icontact,
"contactId",
],
},
listId: {
propDefinition: [
icontact,
"listId",
],
},
},
async run({ $ }) {
const response = await this.icontact.subscribeContactToList({
data: {
subscription: {
contactId: this.contactId,
listId: this.listId,
status: "normal",
},
},
});

checkWarnings(response);

$.export("$summary", `Successfully created subscription with ID: ${response.subscriptions[0].subscriptionId}`);
return response.subscriptions[0];
},
};
13 changes: 0 additions & 13 deletions components/icontact/app/icontact.app.ts

This file was deleted.

37 changes: 37 additions & 0 deletions components/icontact/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export const STATUS_OPTIONS = [
{
label: "Normal - Contact can receive emails sent to them.",
value: "normal",
},
{
label: "Bounced - Contact is unreachable via email.",
value: "bounced",
},
{
label: "Do Not Contact - Contact is blocked from receiving emails.",
value: "donotcontact",
},
{
label: "Pending - Contact must confirm a subscription before receiving emails.",
value: "pending",
},
{
label: "Invitable - Contact must be sent an invitation message before receiving emails.",
value: "invitable",
},
{
label: "Deleted - Contact was deleted from your records",
value: "deleted",
},
];

export const MESSAGE_TYPE_OPTIONS = [
{
label: "Normal - An email message.",
value: "normal",
},
{
label: "Confirmation - An email that requests a contact to confirm their subscription",
value: "confirmation",
},
];
10 changes: 10 additions & 0 deletions components/icontact/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ConfigurationError } from "@pipedream/platform";

export const checkWarnings = (response) => {
if (response.warnings) {
throw new ConfigurationError(response.warnings[0]);
}
if (response.notices) {
throw new ConfigurationError(response.notices[0]);
}
};
Loading
Loading