-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - slicktext #16596
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Merged
Merged
New Components - slicktext #16596
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2075aaa
slicktext init
luancazarine 58808fe
[Components] slicktext #13364
luancazarine baba587
pnpm update
luancazarine fc91541
fix api key constant name
luancazarine 8edc06c
Update components/slicktext/actions/create-contact/create-contact.mjs
luancazarine d7e0d3c
Merge branch 'issue-13364' of https://github.com/PipedreamHQ/pipedrea…
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
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
components/slicktext/actions/add-contact-to-lists/add-contact-to-lists.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,39 @@ | ||
import { parseObject } from "../../common/utils.mjs"; | ||
import slicktext from "../../slicktext.app.mjs"; | ||
|
||
export default { | ||
key: "slicktext-add-contact-to-lists", | ||
name: "Add Contact To Lists", | ||
description: "Add a contact to lists. [See the documentation](https://api.slicktext.com/docs/v2/lists#scroll-to-add-contacts-to-lists)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
slicktext, | ||
contactId: { | ||
propDefinition: [ | ||
slicktext, | ||
"contactId", | ||
], | ||
}, | ||
listIds: { | ||
propDefinition: [ | ||
slicktext, | ||
"listIds", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.slicktext.addContactToLists({ | ||
$, | ||
data: [ | ||
{ | ||
contact_id: this.contactId, | ||
lists: parseObject(this.listIds), | ||
}, | ||
], | ||
}); | ||
|
||
$.export("$summary", `Successfully added contact with ID: ${this.contactId} to lists with ID: ${parseObject(this.listIds).join()}`); | ||
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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import slicktext from "../../slicktext.app.mjs"; | ||
|
||
export const commonProps = { | ||
firstName: { | ||
propDefinition: [ | ||
slicktext, | ||
"firstName", | ||
], | ||
optional: true, | ||
}, | ||
lastName: { | ||
propDefinition: [ | ||
slicktext, | ||
"lastName", | ||
], | ||
optional: true, | ||
}, | ||
email: { | ||
propDefinition: [ | ||
slicktext, | ||
"email", | ||
], | ||
optional: true, | ||
}, | ||
birthdate: { | ||
propDefinition: [ | ||
slicktext, | ||
"birthdate", | ||
], | ||
optional: true, | ||
}, | ||
address: { | ||
propDefinition: [ | ||
slicktext, | ||
"address", | ||
], | ||
optional: true, | ||
}, | ||
city: { | ||
propDefinition: [ | ||
slicktext, | ||
"city", | ||
], | ||
optional: true, | ||
}, | ||
state: { | ||
propDefinition: [ | ||
slicktext, | ||
"state", | ||
], | ||
optional: true, | ||
}, | ||
zip: { | ||
propDefinition: [ | ||
slicktext, | ||
"zip", | ||
], | ||
optional: true, | ||
}, | ||
country: { | ||
propDefinition: [ | ||
slicktext, | ||
"country", | ||
], | ||
optional: true, | ||
}, | ||
timezone: { | ||
propDefinition: [ | ||
slicktext, | ||
"timezone", | ||
], | ||
optional: true, | ||
}, | ||
language: { | ||
propDefinition: [ | ||
slicktext, | ||
"language", | ||
], | ||
optional: true, | ||
}, | ||
optInStatus: { | ||
propDefinition: [ | ||
slicktext, | ||
"optInStatus", | ||
], | ||
optional: true, | ||
}, | ||
}; |
41 changes: 41 additions & 0 deletions
41
components/slicktext/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,41 @@ | ||
import { objectCamelToSnakeCase } from "../../common/utils.mjs"; | ||
import slicktext from "../../slicktext.app.mjs"; | ||
import { commonProps } from "../common/base.mjs"; | ||
|
||
export default { | ||
key: "slicktext-create-contact", | ||
name: "Create Contact", | ||
description: "Add a new contact to your messaging list. [See the documentation](https://api.slicktext.com/docs/v1/contacts)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
slicktext, | ||
mobileNumber: { | ||
propDefinition: [ | ||
slicktext, | ||
"mobileNumber", | ||
], | ||
}, | ||
...commonProps, | ||
forceDoubleOptIn: { | ||
propDefinition: [ | ||
slicktext, | ||
"forceDoubleOptIn", | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
slicktext, | ||
...data | ||
} = this; | ||
|
||
const response = await slicktext.createContact({ | ||
$, | ||
data: objectCamelToSnakeCase(data), | ||
}); | ||
$.export("$summary", `Successfully initiated opt-in for contact with number: ${this.mobileNumber}`); | ||
return response; | ||
}, | ||
}; |
44 changes: 44 additions & 0 deletions
44
components/slicktext/actions/edit-contact/edit-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,44 @@ | ||
import { objectCamelToSnakeCase } from "../../common/utils.mjs"; | ||
import slicktext from "../../slicktext.app.mjs"; | ||
import { commonProps } from "../common/base.mjs"; | ||
|
||
export default { | ||
key: "slicktext-edit-contact", | ||
name: "Edit Contact", | ||
description: "Updates personal details of an existing contact. [See the documentation](https://api.slicktext.com/docs/v1/contacts#6)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
slicktext, | ||
contactId: { | ||
propDefinition: [ | ||
slicktext, | ||
"contactId", | ||
], | ||
}, | ||
mobileNumber: { | ||
propDefinition: [ | ||
slicktext, | ||
"mobileNumber", | ||
], | ||
optional: true, | ||
}, | ||
...commonProps, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
slicktext, | ||
contactId, | ||
...data | ||
} = this; | ||
|
||
const response = await slicktext.updateContact({ | ||
$, | ||
contactId, | ||
data: objectCamelToSnakeCase(data), | ||
}); | ||
|
||
$.export("$summary", `Successfully updated contact with ID: ${this.contactId}`); | ||
return response; | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
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,15 @@ | ||
export const LIMIT = 250; | ||
|
||
export const OPT_IN_STATUS_OPTIONS = [ | ||
"not subscribed", | ||
"subscribed", | ||
"unsubscribed", | ||
"blocked", | ||
]; | ||
|
||
export const TIMEZONE_OPTIONS = [ | ||
"America/New_York", | ||
"America/Chicago", | ||
"America/Denver", | ||
"America/Los_Angeles", | ||
]; | ||
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,36 @@ | ||
export const objectCamelToSnakeCase = (obj) => { | ||
return Object.entries(obj).reduce((acc, [ | ||
key, | ||
value, | ||
]) => { | ||
const newKey = key.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`); | ||
acc[newKey] = value; | ||
return acc; | ||
} | ||
, {}); | ||
}; | ||
|
||
export const parseObject = (obj) => { | ||
if (!obj) return undefined; | ||
|
||
if (Array.isArray(obj)) { | ||
return obj.map((item) => { | ||
if (typeof item === "string") { | ||
try { | ||
return JSON.parse(item); | ||
} catch (e) { | ||
return item; | ||
} | ||
} | ||
return item; | ||
}); | ||
} | ||
if (typeof obj === "string") { | ||
try { | ||
return JSON.parse(obj); | ||
} catch (e) { | ||
return obj; | ||
} | ||
} | ||
return obj; | ||
}; |
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 |
---|---|---|
@@ -1,16 +1,18 @@ | ||
{ | ||
"name": "@pipedream/slicktext", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"description": "Pipedream SlickText Components", | ||
"main": "dist/app/slicktext.app.mjs", | ||
"main": "slicktext.app.mjs", | ||
"keywords": [ | ||
"pipedream", | ||
"slicktext" | ||
], | ||
"files": ["dist"], | ||
"homepage": "https://pipedream.com/apps/slicktext", | ||
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.0.3" | ||
} | ||
} |
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.