Skip to content

Commit 883a06b

Browse files
authored
[Components] mailgenius #14754 (#15056)
* Added actions * pnpm * Update get-email-result.mjs * Done requests changes
1 parent 4d177fb commit 883a06b

File tree

6 files changed

+147
-7
lines changed

6 files changed

+147
-7
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import app from "../../mailgenius.app.mjs";
2+
3+
export default {
4+
key: "mailgenius-get-daily-limit",
5+
name: "Get Daily Limit",
6+
description: "Returns daily limit for api token, how many email tests are used in last 24 hours and how many are still remaining for use. [See the documentation](https://app.mailgenius.com/api-docs/index.html)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
},
12+
13+
async run({ $ }) {
14+
const response = await this.app.getDailyLimit({
15+
$,
16+
});
17+
18+
$.export("$summary", `Your account has '${response.daily_tests_remaining}' remaining tests today`);
19+
20+
return response;
21+
},
22+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import app from "../../mailgenius.app.mjs";
2+
3+
export default {
4+
key: "mailgenius-get-email-audit",
5+
name: "Get Email Audit",
6+
description: "Returns generated test email, limit exceeded if daily limit is reached. [See the documentation](https://app.mailgenius.com/api-docs/index.html)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
},
12+
13+
async run({ $ }) {
14+
const response = await this.app.emailAudit({
15+
$,
16+
});
17+
18+
$.export("$summary", `Your test email is: ${response.test_email}. Please send an email to this address using the account you want to test`);
19+
20+
return response;
21+
},
22+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import app from "../../mailgenius.app.mjs";
2+
3+
export default {
4+
key: "mailgenius-get-email-result",
5+
name: "Get Email Results",
6+
description: "Returns the results of the test. [See the documentation](https://app.mailgenius.com/api-docs/index.html)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
slug: {
12+
propDefinition: [
13+
app,
14+
"slug",
15+
],
16+
},
17+
},
18+
19+
async run({ $ }) {
20+
const response = await this.app.emailResult({
21+
$,
22+
slug: this.slug,
23+
});
24+
25+
$.export("$summary", `The test results are '${response.status}'`);
26+
27+
return response;
28+
},
29+
};
Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,71 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "mailgenius",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
slug: {
8+
type: "string",
9+
label: "Model",
10+
description: "Specifies the model to be used for the request",
11+
async options() {
12+
const response = await this.getEmails();
13+
const emailsSlugs = response.test_emails;
14+
return emailsSlugs.map(({
15+
slug, test_email,
16+
}) => ({
17+
value: slug,
18+
label: test_email,
19+
}));
20+
},
21+
},
22+
},
523
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
24+
_baseUrl() {
25+
return "https://app.mailgenius.com";
26+
},
27+
async _makeRequest(opts = {}) {
28+
const {
29+
$ = this,
30+
path,
31+
headers,
32+
...otherOpts
33+
} = opts;
34+
return axios($, {
35+
...otherOpts,
36+
url: this._baseUrl() + path,
37+
headers: {
38+
...headers,
39+
Authorization: `Bearer ${this.$auth.api_token}`,
40+
accept: "*/*",
41+
},
42+
});
43+
},
44+
async emailAudit(args = {}) {
45+
return this._makeRequest({
46+
path: "/external/api/email-audit",
47+
...args,
48+
});
49+
},
50+
async emailResult({
51+
slug, ...args
52+
}) {
53+
return this._makeRequest({
54+
path: `/external/api/email-result/${slug}`,
55+
...args,
56+
});
57+
},
58+
async getDailyLimit(args = {}) {
59+
return this._makeRequest({
60+
path: "/external/api/daily_limit",
61+
...args,
62+
});
63+
},
64+
async getEmails(args = {}) {
65+
return this._makeRequest({
66+
path: "/external/api/audits",
67+
...args,
68+
});
969
},
1070
},
1171
};

components/mailgenius/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/mailgenius",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream MailGenius Components",
55
"main": "mailgenius.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.0.3"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)