Skip to content

Commit 7ab52a3

Browse files
committed
Added actions
1 parent 3f4aaff commit 7ab52a3

File tree

7 files changed

+362
-8
lines changed

7 files changed

+362
-8
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import app from "../../mumble.app.mjs";
2+
3+
export default {
4+
key: "mumble-add-new-customer",
5+
name: "Add New Customer",
6+
description: "Adds a new customer. [See the documentation](https://app.mumble.co.il/mumbleapi/docs)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
customerPhone: {
12+
propDefinition: [
13+
app,
14+
"customerPhone",
15+
],
16+
},
17+
name: {
18+
propDefinition: [
19+
app,
20+
"name",
21+
],
22+
},
23+
email: {
24+
propDefinition: [
25+
app,
26+
"email",
27+
],
28+
},
29+
source: {
30+
propDefinition: [
31+
app,
32+
"source",
33+
],
34+
},
35+
utmSource: {
36+
propDefinition: [
37+
app,
38+
"utmSource",
39+
],
40+
},
41+
utmMedium: {
42+
propDefinition: [
43+
app,
44+
"utmMedium",
45+
],
46+
},
47+
utmCampaign: {
48+
propDefinition: [
49+
app,
50+
"utmCampaign",
51+
],
52+
},
53+
gclid: {
54+
propDefinition: [
55+
app,
56+
"gclid",
57+
],
58+
},
59+
currentUrl: {
60+
propDefinition: [
61+
app,
62+
"currentUrl",
63+
],
64+
},
65+
},
66+
async run({ $ }) {
67+
const response = await this.app.addNewCustomer({
68+
$,
69+
data: {
70+
customer_phone: this.customerPhone,
71+
name: this.name,
72+
email: this.email,
73+
source: this.source,
74+
utm_source: this.utmSource,
75+
utm_medium: this.utmMedium,
76+
utm_campaign: this.utmCampaign,
77+
gclid: this.gclid,
78+
current_url: this.currentUrl,
79+
},
80+
});
81+
$.export("$summary", "Successfully sent the request to add a new customer: " + response.message);
82+
return response;
83+
},
84+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import app from "../../mumble.app.mjs";
2+
3+
export default {
4+
key: "mumble-add-new-label",
5+
name: "Add New Label",
6+
description: "Adds a new label. [See the documentation](https://app.mumble.co.il/mumbleapi/docs)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
labelName: {
12+
propDefinition: [
13+
app,
14+
"labelName",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.app.addNewLabel({
20+
$,
21+
data: {
22+
label_name: this.labelName,
23+
},
24+
});
25+
$.export("$summary", "Successfully sent the request to add a new label: " + response.message);
26+
return response;
27+
},
28+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import app from "../../mumble.app.mjs";
2+
3+
export default {
4+
key: "mumble-delete-label",
5+
name: "Delete Label",
6+
description: "Deletes a label. [See the documentation](https://app.mumble.co.il/mumbleapi/docs)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
labelNameList: {
12+
propDefinition: [
13+
app,
14+
"labelNameList",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.app.deleteLabel({
20+
$,
21+
data: {
22+
label_name: this.labelNameList,
23+
},
24+
});
25+
$.export("$summary", "Successfully sent the request do delete a label: " + response.message);
26+
return response;
27+
},
28+
};
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import app from "../../mumble.app.mjs";
2+
3+
export default {
4+
key: "mumble-edit-customer",
5+
name: "Edit Customer",
6+
description: "Edits the customer with the specified phone number. [See the documentation](https://app.mumble.co.il/mumbleapi/docs)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
customerPhone: {
12+
propDefinition: [
13+
app,
14+
"customerPhone",
15+
],
16+
},
17+
name: {
18+
propDefinition: [
19+
app,
20+
"name",
21+
],
22+
},
23+
email: {
24+
propDefinition: [
25+
app,
26+
"email",
27+
],
28+
},
29+
source: {
30+
propDefinition: [
31+
app,
32+
"source",
33+
],
34+
},
35+
utmSource: {
36+
propDefinition: [
37+
app,
38+
"utmSource",
39+
],
40+
},
41+
utmMedium: {
42+
propDefinition: [
43+
app,
44+
"utmMedium",
45+
],
46+
},
47+
utmCampaign: {
48+
propDefinition: [
49+
app,
50+
"utmCampaign",
51+
],
52+
},
53+
gclid: {
54+
propDefinition: [
55+
app,
56+
"gclid",
57+
],
58+
},
59+
currentUrl: {
60+
propDefinition: [
61+
app,
62+
"currentUrl",
63+
],
64+
},
65+
},
66+
async run({ $ }) {
67+
const response = await this.app.editCustomer({
68+
$,
69+
data: {
70+
customer_phone: this.customerPhone,
71+
name: this.name,
72+
email: this.email,
73+
source: this.source,
74+
utm_source: this.utmSource,
75+
utm_medium: this.utmMedium,
76+
utm_campaign: this.utmCampaign,
77+
gclid: this.gclid,
78+
current_url: this.currentUrl,
79+
},
80+
});
81+
$.export("$summary", "Successfully sent the request to edit a customer: " + response.message);
82+
return response;
83+
},
84+
};

components/mumble/mumble.app.mjs

Lines changed: 128 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,134 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "mumble",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
labelName: {
8+
type: "string",
9+
label: "Label Name",
10+
description: "Name of the label",
11+
},
12+
customerPhone: {
13+
type: "string",
14+
label: "Customer Phone",
15+
description: "Phone number of the customer",
16+
},
17+
name: {
18+
type: "string",
19+
label: "Name",
20+
description: "Name of the customer",
21+
optional: true,
22+
},
23+
email: {
24+
type: "string",
25+
label: "Email",
26+
description: "Email address",
27+
optional: true,
28+
},
29+
source: {
30+
type: "string",
31+
label: "Source",
32+
description: "Source identifier",
33+
optional: true,
34+
},
35+
utmSource: {
36+
type: "string",
37+
label: "UTM Source",
38+
description: "UTM source value",
39+
optional: true,
40+
},
41+
utmMedium: {
42+
type: "string",
43+
label: "UTM Medium",
44+
description: "UTM medium value",
45+
optional: true,
46+
},
47+
utmCampaign: {
48+
type: "string",
49+
label: "UTM Campaign",
50+
description: "UTM campaign value",
51+
optional: true,
52+
},
53+
gclid: {
54+
type: "string",
55+
label: "GCLID",
56+
description: "Google Ads click ID",
57+
optional: true,
58+
},
59+
currentUrl: {
60+
type: "string",
61+
label: "Current URL",
62+
description: "Current URL",
63+
optional: true,
64+
},
65+
labelNameList: {
66+
type: "string",
67+
label: "Label Name",
68+
description: "Name of the label",
69+
async options() {
70+
const response = await this.getLabels();
71+
const labelsArray = response.labels;
72+
return labelsArray.map((label) => ({
73+
value: label,
74+
label: label,
75+
}));
76+
},
77+
},
78+
},
579
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
80+
_baseUrl() {
81+
return "https://app.mumble.co.il/mumbleapi";
82+
},
83+
async _makeRequest(opts = {}) {
84+
const {
85+
$ = this,
86+
path,
87+
headers,
88+
...otherOpts
89+
} = opts;
90+
return axios($, {
91+
...otherOpts,
92+
url: this._baseUrl() + path,
93+
headers: {
94+
"mumble-api-key": `${this.$auth.api_key}`,
95+
...headers,
96+
},
97+
});
98+
},
99+
async addNewLabel(args = {}) {
100+
return this._makeRequest({
101+
path: "/add-new-label",
102+
method: "post",
103+
...args,
104+
});
105+
},
106+
async deleteLabel(args = {}) {
107+
return this._makeRequest({
108+
path: "/delete-label",
109+
method: "delete",
110+
...args,
111+
});
112+
},
113+
async addNewCustomer(args = {}) {
114+
return this._makeRequest({
115+
path: "/add-new-customer",
116+
method: "post",
117+
...args,
118+
});
119+
},
120+
async editCustomer(args = {}) {
121+
return this._makeRequest({
122+
path: "/edit-customer",
123+
method: "post",
124+
...args,
125+
});
126+
},
127+
async getLabels(args = {}) {
128+
return this._makeRequest({
129+
path: "/get-labels",
130+
...args,
131+
});
9132
},
10133
},
11-
};
134+
};

components/mumble/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/mumble",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Mumble Components",
55
"main": "mumble.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.0"
1417
}
15-
}
18+
}

0 commit comments

Comments
 (0)