Skip to content

Commit 58808fe

Browse files
committed
[Components] slicktext #13364
Actions - Create Contact - Edit Contact - Add Contact To Lists
1 parent 2075aaa commit 58808fe

File tree

12 files changed

+369
-269
lines changed

12 files changed

+369
-269
lines changed

components/slicktext/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { parseObject } from "../../common/utils.mjs";
2+
import slicktext from "../../slicktext.app.mjs";
3+
4+
export default {
5+
key: "slicktext-add-contact-to-lists",
6+
name: "Add Contact To Lists",
7+
description: "Add a contact to lists. [See the documentation](https://api.slicktext.com/docs/v2/lists#scroll-to-add-contacts-to-lists)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
slicktext,
12+
contactId: {
13+
propDefinition: [
14+
slicktext,
15+
"contactId",
16+
],
17+
},
18+
listIds: {
19+
propDefinition: [
20+
slicktext,
21+
"listIds",
22+
],
23+
},
24+
},
25+
async run({ $ }) {
26+
const response = await this.slicktext.addContactToLists({
27+
$,
28+
data: [
29+
{
30+
contact_id: this.contactId,
31+
lists: parseObject(this.listIds),
32+
},
33+
],
34+
});
35+
36+
$.export("$summary", `Successfully added contact with ID: ${this.contactId} to lists with ID: ${parseObject(this.listIds).join()}`);
37+
return response;
38+
},
39+
};
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import slicktext from "../../slicktext.app.mjs";
2+
3+
export const commonProps = {
4+
firstName: {
5+
propDefinition: [
6+
slicktext,
7+
"firstName",
8+
],
9+
optional: true,
10+
},
11+
lastName: {
12+
propDefinition: [
13+
slicktext,
14+
"lastName",
15+
],
16+
optional: true,
17+
},
18+
email: {
19+
propDefinition: [
20+
slicktext,
21+
"email",
22+
],
23+
optional: true,
24+
},
25+
birthdate: {
26+
propDefinition: [
27+
slicktext,
28+
"birthdate",
29+
],
30+
optional: true,
31+
},
32+
address: {
33+
propDefinition: [
34+
slicktext,
35+
"address",
36+
],
37+
optional: true,
38+
},
39+
city: {
40+
propDefinition: [
41+
slicktext,
42+
"city",
43+
],
44+
optional: true,
45+
},
46+
state: {
47+
propDefinition: [
48+
slicktext,
49+
"state",
50+
],
51+
optional: true,
52+
},
53+
zip: {
54+
propDefinition: [
55+
slicktext,
56+
"zip",
57+
],
58+
optional: true,
59+
},
60+
country: {
61+
propDefinition: [
62+
slicktext,
63+
"country",
64+
],
65+
optional: true,
66+
},
67+
timezone: {
68+
propDefinition: [
69+
slicktext,
70+
"timezone",
71+
],
72+
optional: true,
73+
},
74+
language: {
75+
propDefinition: [
76+
slicktext,
77+
"language",
78+
],
79+
optional: true,
80+
},
81+
optInStatus: {
82+
propDefinition: [
83+
slicktext,
84+
"optInStatus",
85+
],
86+
optional: true,
87+
},
88+
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { objectCamelToSnakeCase } from "../../common/utils.mjs";
2+
import slicktext from "../../slicktext.app.mjs";
3+
import { commonProps } from "../common/base.mjs";
4+
5+
export default {
6+
key: "slicktext-create-contact",
7+
name: "Create Contact",
8+
description: "Add a new contact to your messaging list. [See the documentation](https://api.slicktext.com/docs/v1/contacts)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
slicktext,
13+
mobileNumber: {
14+
propDefinition: [
15+
slicktext,
16+
"mobileNumber",
17+
],
18+
},
19+
...commonProps,
20+
forceDoubleOptIn: {
21+
propDefinition: [
22+
slicktext,
23+
"forceDoubleOptIn",
24+
],
25+
optional: true,
26+
},
27+
},
28+
async run({ $ }) {
29+
const {
30+
slicktext,
31+
...data
32+
} = this;
33+
34+
const response = await slicktext.createContact({
35+
$,
36+
data: objectCamelToSnakeCase(data),
37+
});
38+
$.export("$summary", `Successfully initiated opt-in for contact with number: ${this.contactNumber}`);
39+
return response;
40+
},
41+
};

components/slicktext/actions/edit-contact/edit-contact.mjs

Lines changed: 16 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import { objectCamelToSnakeCase } from "../../common/utils.mjs";
12
import slicktext from "../../slicktext.app.mjs";
2-
import { axios } from "@pipedream/platform";
3+
import { commonProps } from "../common/base.mjs";
34

45
export default {
56
key: "slicktext-edit-contact",
67
name: "Edit Contact",
78
description: "Updates personal details of an existing contact. [See the documentation](https://api.slicktext.com/docs/v1/contacts#6)",
8-
version: "0.0.{{ts}}",
9+
version: "0.0.1",
910
type: "action",
1011
props: {
1112
slicktext,
@@ -15,58 +16,26 @@ export default {
1516
"contactId",
1617
],
1718
},
18-
name: {
19+
mobileNumber: {
1920
propDefinition: [
2021
slicktext,
21-
"name",
22-
],
23-
optional: true,
24-
},
25-
emailAddress: {
26-
propDefinition: [
27-
slicktext,
28-
"emailAddress",
29-
],
30-
optional: true,
31-
},
32-
city: {
33-
propDefinition: [
34-
slicktext,
35-
"city",
36-
],
37-
optional: true,
38-
},
39-
state: {
40-
propDefinition: [
41-
slicktext,
42-
"state",
43-
],
44-
optional: true,
45-
},
46-
zipCode: {
47-
propDefinition: [
48-
slicktext,
49-
"zipCode",
50-
],
51-
optional: true,
52-
},
53-
country: {
54-
propDefinition: [
55-
slicktext,
56-
"country",
22+
"mobileNumber",
5723
],
5824
optional: true,
5925
},
26+
...commonProps,
6027
},
6128
async run({ $ }) {
62-
const response = await this.slicktext.updateContact({
63-
contactId: this.contactId,
64-
name: this.name,
65-
emailAddress: this.emailAddress,
66-
city: this.city,
67-
state: this.state,
68-
zipCode: this.zipCode,
69-
country: this.country,
29+
const {
30+
slicktext,
31+
contactId,
32+
...data
33+
} = this;
34+
35+
const response = await slicktext.updateContact({
36+
$,
37+
contactId,
38+
data: objectCamelToSnakeCase(data),
7039
});
7140

7241
$.export("$summary", `Successfully updated contact with ID: ${this.contactId}`);

components/slicktext/actions/opt-in-contact/opt-in-contact.mjs

Lines changed: 0 additions & 88 deletions
This file was deleted.

components/slicktext/actions/send-message-to-contact/send-message-to-contact.mjs

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)