Skip to content

Commit e822597

Browse files
authored
17129 app issuebadge (#17297)
* [APP] Issuebadge #17129 Actions - Create Badge - Create Issue - Create Organization - Get All Badges - Get All Organizations * pnpm update
1 parent 35607f0 commit e822597

File tree

8 files changed

+299
-9
lines changed

8 files changed

+299
-9
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { getFileStreamAndMetadata } from "@pipedream/platform";
2+
import FormData from "form-data";
3+
import issueBadge from "../../issue_badge.app.mjs";
4+
5+
export default {
6+
key: "issue_badge-create-badge",
7+
name: "Create Badge",
8+
description: "Create a new badge [See the documentation](https://documenter.getpostman.com/view/19911979/2sA2r9X4Aj#2d909087-86e3-4e78-82ce-7b1691285a20)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
issueBadge,
13+
name: {
14+
type: "string",
15+
label: "Badge Name",
16+
description: "The name of the badge",
17+
optional: true,
18+
},
19+
description: {
20+
type: "string",
21+
label: "Description",
22+
description: "Description of the badge",
23+
},
24+
badgeLogo: {
25+
type: "string",
26+
label: "Badge Logo",
27+
description: "Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.png`)",
28+
},
29+
comment: {
30+
type: "string",
31+
label: "Comment",
32+
description: "Comment for the badge",
33+
optional: true,
34+
},
35+
},
36+
async run({ $ }) {
37+
const formData = new FormData();
38+
if (this.name) formData.append("name", this.name);
39+
if (this.description) formData.append("description", this.description);
40+
if (this.comment) formData.append("comment", this.comment);
41+
42+
if (this.badgeLogo) {
43+
const {
44+
stream, metadata,
45+
} = await getFileStreamAndMetadata(this.badgeLogo);
46+
formData.append("badge_logo", stream, {
47+
contentType: metadata.contentType,
48+
knownLength: metadata.size,
49+
filename: metadata.name,
50+
});
51+
}
52+
53+
const result = await this.issueBadge.createBadge({
54+
$,
55+
data: formData,
56+
headers: formData.getHeaders(),
57+
});
58+
59+
$.export("$summary", `Successfully created badge with ID: ${result.badgeId}`);
60+
return result;
61+
},
62+
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import issueBadge from "../../issue_badge.app.mjs";
2+
3+
export default {
4+
key: "issue_badge-create-issue",
5+
name: "Create Issue",
6+
description: "Create a new issue [See the documentation](https://documenter.getpostman.com/view/19911979/2sA2r9X4Aj#b5b9801a-432d-4d2e-96ef-a9fb2d2d2a94)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
issueBadge,
11+
name: {
12+
type: "string",
13+
label: "Name",
14+
description: "The name of the issue",
15+
},
16+
badgeId: {
17+
propDefinition: [
18+
issueBadge,
19+
"badgeId",
20+
],
21+
},
22+
email: {
23+
type: "string",
24+
label: "Email",
25+
description: "The email of the recipient",
26+
optional: true,
27+
},
28+
phone: {
29+
type: "string",
30+
label: "Phone",
31+
description: "The phone number of the recipient",
32+
optional: true,
33+
},
34+
},
35+
async run({ $ }) {
36+
const result = await this.issueBadge.createIssue({
37+
$,
38+
data: {
39+
name: this.name,
40+
badge_id: this.badgeId,
41+
email: this.email,
42+
phone: this.phone,
43+
},
44+
});
45+
46+
$.export("$summary", `Successfully created issue with ID: ${result.IssueId}`);
47+
return result;
48+
},
49+
};
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { getFileStreamAndMetadata } from "@pipedream/platform";
2+
import FormData from "form-data";
3+
import issueBadge from "../../issue_badge.app.mjs";
4+
5+
export default {
6+
key: "issue_badge-create-organization",
7+
name: "Create Organization",
8+
description: "Create a new organization [See the documentation](https://documenter.getpostman.com/view/19911979/2sA2r9X4Aj#9f046aa2-e975-420f-a9ec-3274ea74c6bd)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
issueBadge,
13+
name: {
14+
type: "string",
15+
label: "Organization Name",
16+
description: "The name of the organization",
17+
},
18+
description: {
19+
type: "string",
20+
label: "Description",
21+
description: "Description of the organization",
22+
},
23+
badgeLogo: {
24+
type: "string",
25+
label: "Badge Logo",
26+
description: "Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.png`)",
27+
optional: true,
28+
},
29+
comment: {
30+
type: "string",
31+
label: "Comment",
32+
description: "Comment for the organization",
33+
optional: true,
34+
},
35+
},
36+
async run({ $ }) {
37+
const formData = new FormData();
38+
formData.append("name", this.name);
39+
formData.append("description", this.description);
40+
if (this.comment) formData.append("comment", this.comment);
41+
42+
if (this.badgeLogo) {
43+
const {
44+
stream, metadata,
45+
} = await getFileStreamAndMetadata(this.badgeLogo);
46+
formData.append("badge_logo", stream, {
47+
contentType: metadata.contentType,
48+
knownLength: metadata.size,
49+
filename: metadata.name,
50+
});
51+
}
52+
53+
const response = await this.issueBadge.createOrganization({
54+
$,
55+
data: formData,
56+
headers: formData.getHeaders(),
57+
});
58+
59+
$.export("$summary", `Successfully created organization with ID: ${response.data.uu_id.id}`);
60+
return response;
61+
},
62+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import issueBadge from "../../issue_badge.app.mjs";
2+
3+
export default {
4+
key: "issue_badge-get-all-badges",
5+
name: "Get All Badges",
6+
description: "Retrieve all badges [See the documentation](https://documenter.getpostman.com/view/19911979/2sA2r9X4Aj#5d30c8a9-f16a-4dfb-a3e0-c241e60935c4)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
issueBadge,
11+
},
12+
async run({ $ }) {
13+
const response = await this.issueBadge.listAllBadges({
14+
$,
15+
});
16+
17+
$.export("$summary", `Successfully retrieved ${response.data.length} badges`);
18+
return response.data;
19+
},
20+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import issueBadge from "../../issue_badge.app.mjs";
2+
3+
export default {
4+
key: "issue_badge-get-all-organizations",
5+
name: "Get All Organizations",
6+
description: "Retrieve all organizations [See the documentation](https://documenter.getpostman.com/view/19911979/2sA2r9X4Aj#64e5ee48-8e20-463b-addd-e697452e8e5a)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
issueBadge,
11+
},
12+
async run({ $ }) {
13+
const response = await this.issueBadge.listAllOrganizations({
14+
$,
15+
});
16+
17+
$.export("$summary", `Successfully retrieved ${response.data.length} organizations`);
18+
return response.data;
19+
},
20+
};
Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,78 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "issue_badge",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
badgeId: {
8+
type: "string",
9+
label: "Badge ID",
10+
description: "The ID of the badge to create an issue for",
11+
async options() {
12+
const { data } = await this.listAllBadges();
13+
14+
return data.map(({
15+
id: value, name: label,
16+
}) => ({
17+
label,
18+
value,
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.issuebadge.com/api/v1";
26+
},
27+
_headers(headers = {}) {
28+
return {
29+
Authorization: `Bearer ${this.$auth.api_key}`,
30+
accept: "application/json",
31+
...headers,
32+
};
33+
},
34+
_makeRequest({
35+
$ = this, path, headers, ...opts
36+
}) {
37+
return axios($, {
38+
url: this._baseUrl() + path,
39+
headers: this._headers(headers),
40+
...opts,
41+
});
42+
},
43+
createOrganization(opts = {}) {
44+
return this._makeRequest({
45+
method: "POST",
46+
path: "/organization/create",
47+
...opts,
48+
});
49+
},
50+
listAllOrganizations(opts = {}) {
51+
return this._makeRequest({
52+
method: "POST",
53+
path: "/organization/getall",
54+
...opts,
55+
});
56+
},
57+
listAllBadges(opts = {}) {
58+
return this._makeRequest({
59+
path: "/badge/getall",
60+
...opts,
61+
});
62+
},
63+
createBadge(opts = {}) {
64+
return this._makeRequest({
65+
method: "POST",
66+
path: "/badge/create",
67+
...opts,
68+
});
69+
},
70+
createIssue(opts = {}) {
71+
return this._makeRequest({
72+
method: "POST",
73+
path: "/issue/create",
74+
...opts,
75+
});
976
},
1077
},
1178
};
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
{
22
"name": "@pipedream/issue_badge",
3-
"version": "0.0.1",
4-
"description": "Pipedream Issue Badge Components",
3+
"version": "0.1.0",
4+
"description": "Pipedream Issue Badge Components - Manage badges, issues, and organizations",
55
"main": "issue_badge.app.mjs",
66
"keywords": [
77
"pipedream",
8-
"issue_badge"
8+
"issue_badge",
9+
"badges",
10+
"issues",
11+
"organizations"
912
],
1013
"homepage": "https://pipedream.com/apps/issue_badge",
1114
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1215
"publishConfig": {
1316
"access": "public"
17+
},
18+
"dependencies": {
19+
"@pipedream/platform": "^3.1.0"
1420
}
15-
}
21+
}

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)