Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions components/issue_badge/actions/create-badge/create-badge.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { getFileStreamAndMetadata } from "@pipedream/platform";
import FormData from "form-data";
import issueBadge from "../../issue_badge.app.mjs";

export default {
key: "issue_badge-create-badge",
name: "Create Badge",
description: "Create a new badge [See the documentation](https://documenter.getpostman.com/view/19911979/2sA2r9X4Aj#2d909087-86e3-4e78-82ce-7b1691285a20)",
version: "0.0.1",
type: "action",
props: {
issueBadge,
name: {
type: "string",
label: "Badge Name",
description: "The name of the badge",
optional: true,
},
description: {
type: "string",
label: "Description",
description: "Description of the badge",
},
badgeLogo: {
type: "string",
label: "Badge Logo",
description: "Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.png`)",
},
comment: {
type: "string",
label: "Comment",
description: "Comment for the badge",
optional: true,
},
},
async run({ $ }) {
const formData = new FormData();
if (this.name) formData.append("name", this.name);
if (this.description) formData.append("description", this.description);
if (this.comment) formData.append("comment", this.comment);

if (this.badgeLogo) {
const {
stream, metadata,
} = await getFileStreamAndMetadata(this.badgeLogo);
formData.append("badge_logo", stream, {
contentType: metadata.contentType,
knownLength: metadata.size,
filename: metadata.name,
});
}

const result = await this.issueBadge.createBadge({
$,
data: formData,
headers: formData.getHeaders(),
});

$.export("$summary", `Successfully created badge with ID: ${result.badgeId}`);
return result;
},
};
49 changes: 49 additions & 0 deletions components/issue_badge/actions/create-issue/create-issue.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import issueBadge from "../../issue_badge.app.mjs";

export default {
key: "issue_badge-create-issue",
name: "Create Issue",
description: "Create a new issue [See the documentation](https://documenter.getpostman.com/view/19911979/2sA2r9X4Aj#b5b9801a-432d-4d2e-96ef-a9fb2d2d2a94)",
version: "0.0.1",
type: "action",
props: {
issueBadge,
name: {
type: "string",
label: "Name",
description: "The name of the issue",
},
badgeId: {
propDefinition: [
issueBadge,
"badgeId",
],
},
email: {
type: "string",
label: "Email",
description: "The email of the recipient",
optional: true,
},
phone: {
type: "string",
label: "Phone",
description: "The phone number of the recipient",
optional: true,
},
},
async run({ $ }) {
const result = await this.issueBadge.createIssue({
$,
data: {
name: this.name,
badge_id: this.badgeId,
email: this.email,
phone: this.phone,
},
});

$.export("$summary", `Successfully created issue with ID: ${result.IssueId}`);
return result;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { getFileStreamAndMetadata } from "@pipedream/platform";
import FormData from "form-data";
import issueBadge from "../../issue_badge.app.mjs";

export default {
key: "issue_badge-create-organization",
name: "Create Organization",
description: "Create a new organization [See the documentation](https://documenter.getpostman.com/view/19911979/2sA2r9X4Aj#9f046aa2-e975-420f-a9ec-3274ea74c6bd)",
version: "0.0.1",
type: "action",
props: {
issueBadge,
name: {
type: "string",
label: "Organization Name",
description: "The name of the organization",
},
description: {
type: "string",
label: "Description",
description: "Description of the organization",
},
badgeLogo: {
type: "string",
label: "Badge Logo",
description: "Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.png`)",
optional: true,
},
comment: {
type: "string",
label: "Comment",
description: "Comment for the organization",
optional: true,
},
},
async run({ $ }) {
const formData = new FormData();
formData.append("name", this.name);
formData.append("description", this.description);
if (this.comment) formData.append("comment", this.comment);

if (this.badgeLogo) {
const {
stream, metadata,
} = await getFileStreamAndMetadata(this.badgeLogo);
formData.append("badge_logo", stream, {
contentType: metadata.contentType,
knownLength: metadata.size,
filename: metadata.name,
});
}

const response = await this.issueBadge.createOrganization({
$,
data: formData,
headers: formData.getHeaders(),
});

$.export("$summary", `Successfully created organization with ID: ${response.data.uu_id.id}`);
return response;
},
};
20 changes: 20 additions & 0 deletions components/issue_badge/actions/get-all-badges/get-all-badges.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import issueBadge from "../../issue_badge.app.mjs";

export default {
key: "issue_badge-get-all-badges",
name: "Get All Badges",
description: "Retrieve all badges [See the documentation](https://documenter.getpostman.com/view/19911979/2sA2r9X4Aj#5d30c8a9-f16a-4dfb-a3e0-c241e60935c4)",
version: "0.0.1",
type: "action",
props: {
issueBadge,
},
async run({ $ }) {
const response = await this.issueBadge.listAllBadges({
$,
});

$.export("$summary", `Successfully retrieved ${response.data.length} badges`);
return response.data;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import issueBadge from "../../issue_badge.app.mjs";

export default {
key: "issue_badge-get-all-organizations",
name: "Get All Organizations",
description: "Retrieve all organizations [See the documentation](https://documenter.getpostman.com/view/19911979/2sA2r9X4Aj#64e5ee48-8e20-463b-addd-e697452e8e5a)",
version: "0.0.1",
type: "action",
props: {
issueBadge,
},
async run({ $ }) {
const response = await this.issueBadge.listAllOrganizations({
$,
});

$.export("$summary", `Successfully retrieved ${response.data.length} organizations`);
return response.data;
},
};
75 changes: 71 additions & 4 deletions components/issue_badge/issue_badge.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,78 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "issue_badge",
propDefinitions: {},
propDefinitions: {
badgeId: {
type: "string",
label: "Badge ID",
description: "The ID of the badge to create an issue for",
async options() {
const { data } = await this.listAllBadges();

return data.map(({
id: value, name: label,
}) => ({
label,
value,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://app.issuebadge.com/api/v1";
},
_headers(headers = {}) {
return {
Authorization: `Bearer ${this.$auth.api_key}`,
accept: "application/json",
...headers,
};
},
_makeRequest({
$ = this, path, headers, ...opts
}) {
return axios($, {
url: this._baseUrl() + path,
headers: this._headers(headers),
...opts,
});
},
createOrganization(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/organization/create",
...opts,
});
},
listAllOrganizations(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/organization/getall",
...opts,
});
},
listAllBadges(opts = {}) {
return this._makeRequest({
path: "/badge/getall",
...opts,
});
},
createBadge(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/badge/create",
...opts,
});
},
createIssue(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/issue/create",
...opts,
});
},
},
};
14 changes: 10 additions & 4 deletions components/issue_badge/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
{
"name": "@pipedream/issue_badge",
"version": "0.0.1",
"description": "Pipedream Issue Badge Components",
"version": "0.1.0",
"description": "Pipedream Issue Badge Components - Manage badges, issues, and organizations",
"main": "issue_badge.app.mjs",
"keywords": [
"pipedream",
"issue_badge"
"issue_badge",
"badges",
"issues",
"organizations"
],
"homepage": "https://pipedream.com/apps/issue_badge",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
}
Loading
Loading