-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - icontact #16870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
New Components - icontact #16870
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5914093
icontact init
luancazarine a21a58c
[Components] icontact #13263
luancazarine f059355
pnpm update
luancazarine 10e2033
Update components/icontact/actions/create-message/create-message.mjs
luancazarine 65f764a
Update components/icontact/actions/create-contact/create-contact.mjs
luancazarine 3ff0549
Update components/icontact/actions/create-contact/create-contact.mjs
michelle0927 d7258b8
some adjusts
luancazarine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
components/icontact/actions/create-contact/create-contact.mjs
This file contains hidden or 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,51 @@ | ||
| import icontact from "../../icontact.app.mjs"; | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| 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, | ||
| }); | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| $.export("$summary", `Successfully created contact with email ${this.contactEmail}`); | ||
| return response; | ||
| }, | ||
| }; | ||
49 changes: 49 additions & 0 deletions
49
components/icontact/actions/create-message/create-message.mjs
This file contains hidden or 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,49 @@ | ||
| import icontact from "../../icontact.app.mjs"; | ||
| import { axios } from "@pipedream/platform"; | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 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}}", | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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; | ||
| }, | ||
| }; | ||
34 changes: 34 additions & 0 deletions
34
components/icontact/actions/subscribe-contact-list/subscribe-contact-list.mjs
This file contains hidden or 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,34 @@ | ||
| import icontact from "../../icontact.app.mjs"; | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| 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}}", | ||
| 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; | ||
| }, | ||
| }; | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -10,4 +10,4 @@ export default defineApp({ | |
| console.log(Object.keys(this.$auth)); | ||
| }, | ||
| }, | ||
| }); | ||
| }); | ||
This file contains hidden or 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,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}`, | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }, | ||
| }); | ||
| }, | ||
| 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, | ||
| }); | ||
| }, | ||
luancazarine marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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. | ||
| }, | ||
| }, | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.