-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] Drift. Actions + Sources #16553
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
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
29ac629
Initial
SokolovskyiK 21af602
Save just in case
SokolovskyiK 00d7d45
Save just in case2
SokolovskyiK c14d5e4
alpha
SokolovskyiK 466aa07
Test actions
SokolovskyiK f888650
[Components] Drift. Actions + Sources
SokolovskyiK 6f9160a
Fix CodeRabbit
SokolovskyiK 87d0c6f
Fix folder name
SokolovskyiK 097ff38
Fix minor
SokolovskyiK dd9dcbd
minor fix
SokolovskyiK 9aace2c
Major fix
SokolovskyiK e08c621
add new message source
SokolovskyiK 2a60ac9
Update components/drift/actions/create-contact/create-contact.mjs
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
87 changes: 87 additions & 0 deletions
87
components/drift/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,87 @@ | ||
| import drift from "../../drift.app.mjs"; | ||
| import { removeNullEntries } from "../../common/utils.mjs"; | ||
|
|
||
| export default { | ||
| key: "drift-create-contact", | ||
| name: "Create Contact", | ||
| description: "Creates a contact in Drift. [See the docs](https://devdocs.drift.com/docs/creating-a-contact).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| drift, | ||
| email: { | ||
| type: "string", | ||
| label: "Email", | ||
| description: "The contact's email address", | ||
| }, | ||
| name: { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "The contact's full name", | ||
| optional: true, | ||
| }, | ||
| phone: { | ||
| type: "string", | ||
| label: "Phone", | ||
| description: "The contact's phone number", | ||
| optional: true, | ||
| }, | ||
| source: { | ||
| type: "string", | ||
| label: "Lead Source", | ||
| description: "The value of the 'lead_create_source' custom attribute to match (case-sensitive).", | ||
| optional: true, | ||
| }, | ||
| customAttributes: { | ||
| type: "object", | ||
| label: "Custom Attributes", | ||
| description: "Additional custom attributes to store on the contact", | ||
| optional: true, | ||
| }, | ||
| }, | ||
|
|
||
| async run({ $ }) { | ||
|
|
||
| const warnings = []; | ||
|
|
||
| const { | ||
| drift, email, name, phone, source, | ||
| } = this; | ||
|
|
||
| warnings.push(...drift.checkIfEmailValid(email)); | ||
|
|
||
| const customAttributes = drift.parseIfJSONString(this.customAttributes); | ||
|
|
||
| const attributes = removeNullEntries({ | ||
| email, | ||
| name, | ||
| phone, | ||
| source, | ||
| ...customAttributes, | ||
| }); | ||
|
|
||
| const existingContact = await drift.getContactByEmail({ | ||
| $, | ||
| params: { | ||
| email, | ||
| }, | ||
| }); | ||
|
|
||
| if (existingContact && existingContact.data.length > 0) { | ||
| throw new Error (`Contact ${email} already exists`); | ||
| }; | ||
|
|
||
| const response = await drift.createContact({ | ||
| $, | ||
| data: { | ||
| attributes, | ||
| }, | ||
| }); | ||
|
|
||
| console.log(response.data.id); | ||
luancazarine marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| $.export("$summary", `Contact ${email} created.` + warnings.join("\n- ")); | ||
| return response; | ||
| }, | ||
| }; | ||
|
|
||
45 changes: 45 additions & 0 deletions
45
components/drift/actions/delete-contact/delete-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,45 @@ | ||||||
| import drift from "../../drift.app.mjs"; | ||||||
|
|
||||||
| export default { | ||||||
| key: "drift-delete-contact", | ||||||
| name: "Delete Contact", | ||||||
| description: "Deletes a contact in Drift by ID or email. [See the docs](https://devdocs.drift.com/docs/removing-a-contact).", | ||||||
|
||||||
| description: "Deletes a contact in Drift by ID or email. [See the docs](https://devdocs.drift.com/docs/removing-a-contact).", | |
| description: "Deletes a contact in Drift by ID or email. [See the documentation](https://devdocs.drift.com/docs/removing-a-contact).", |
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,39 @@ | ||||||
| import drift from "../../drift.app.mjs"; | ||||||
|
|
||||||
| export default { | ||||||
| key: "drift-delete-contact", | ||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| name: "Get Contact", | ||||||
| description: "Retrieves a contact in Drift by ID or email. [See the docs](https://devdocs.drift.com/docs/retrieving-contact)", | ||||||
|
||||||
| description: "Retrieves a contact in Drift by ID or email. [See the docs](https://devdocs.drift.com/docs/retrieving-contact)", | |
| description: "Retrieves a contact in Drift by ID or email. [See the documentation](https://devdocs.drift.com/docs/retrieving-contact)", |
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
90 changes: 90 additions & 0 deletions
90
components/drift/actions/update-contact/update-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,90 @@ | ||||||
| import drift from "../../drift.app.mjs"; | ||||||
| import { removeNullEntries } from "../../common/utils.mjs"; | ||||||
|
|
||||||
| export default { | ||||||
| key: "drift-update-contact", | ||||||
| name: "Update Contact", | ||||||
| description: "Updates a contact in Drift using ID or email. Only changed attributes will be updated. [See Drift API docs](https://devdocs.drift.com/docs/updating-a-contact)", | ||||||
|
||||||
| description: "Updates a contact in Drift using ID or email. Only changed attributes will be updated. [See Drift API docs](https://devdocs.drift.com/docs/updating-a-contact)", | |
| description: "Updates a contact in Drift using ID or email. Only changed attributes will be updated. [See the documentation](https://devdocs.drift.com/docs/updating-a-contact)", |
SokolovskyiK marked this conversation as resolved.
Show resolved
Hide resolved
SokolovskyiK marked this conversation as resolved.
Show resolved
Hide resolved
SokolovskyiK marked this conversation as resolved.
Show resolved
Hide resolved
SokolovskyiK marked this conversation as resolved.
Show resolved
Hide resolved
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.