diff --git a/components/issue_badge/actions/create-badge/create-badge.mjs b/components/issue_badge/actions/create-badge/create-badge.mjs new file mode 100644 index 0000000000000..a3587f26300d9 --- /dev/null +++ b/components/issue_badge/actions/create-badge/create-badge.mjs @@ -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; + }, +}; diff --git a/components/issue_badge/actions/create-issue/create-issue.mjs b/components/issue_badge/actions/create-issue/create-issue.mjs new file mode 100644 index 0000000000000..42ec11e83e088 --- /dev/null +++ b/components/issue_badge/actions/create-issue/create-issue.mjs @@ -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; + }, +}; diff --git a/components/issue_badge/actions/create-organization/create-organization.mjs b/components/issue_badge/actions/create-organization/create-organization.mjs new file mode 100644 index 0000000000000..924a3a73c9cb0 --- /dev/null +++ b/components/issue_badge/actions/create-organization/create-organization.mjs @@ -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; + }, +}; diff --git a/components/issue_badge/actions/get-all-badges/get-all-badges.mjs b/components/issue_badge/actions/get-all-badges/get-all-badges.mjs new file mode 100644 index 0000000000000..98b46483e264e --- /dev/null +++ b/components/issue_badge/actions/get-all-badges/get-all-badges.mjs @@ -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; + }, +}; diff --git a/components/issue_badge/actions/get-all-organizations/get-all-organizations.mjs b/components/issue_badge/actions/get-all-organizations/get-all-organizations.mjs new file mode 100644 index 0000000000000..96db7d4ef487c --- /dev/null +++ b/components/issue_badge/actions/get-all-organizations/get-all-organizations.mjs @@ -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; + }, +}; diff --git a/components/issue_badge/issue_badge.app.mjs b/components/issue_badge/issue_badge.app.mjs index 5acc7aef47f87..65392a988c136 100644 --- a/components/issue_badge/issue_badge.app.mjs +++ b/components/issue_badge/issue_badge.app.mjs @@ -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, + }); }, }, }; diff --git a/components/issue_badge/package.json b/components/issue_badge/package.json index 980a4996161b8..af39bfeb4ae5a 100644 --- a/components/issue_badge/package.json +++ b/components/issue_badge/package.json @@ -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 (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 25489a5af8b01..f2b8643584c9f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1124,8 +1124,7 @@ importers: components/avochato: {} - components/avosms: - specifiers: {} + components/avosms: {} components/aweber: dependencies: @@ -2853,8 +2852,7 @@ importers: components/common_paper: {} - components/commonninja: - specifiers: {} + components/commonninja: {} components/commpeak: dependencies: @@ -4026,8 +4024,7 @@ importers: components/easy_projects: {} - components/easybroker: - specifiers: {} + components/easybroker: {} components/easycsv: {} @@ -6777,8 +6774,7 @@ importers: specifier: ^1.1.1 version: 1.6.6 - components/ipstack: - specifiers: {} + components/ipstack: {} components/iqair_airvisual: {} @@ -6798,7 +6794,11 @@ importers: specifier: ^1.6.5 version: 1.6.6 - components/issue_badge: {} + components/issue_badge: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/itemize: dependencies: @@ -9316,8 +9316,7 @@ importers: specifier: ^17.0.45 version: 17.0.45 - components/openai_passthrough: - specifiers: {} + components/openai_passthrough: {} components/opencage: dependencies: @@ -9916,8 +9915,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/phonely: - specifiers: {} + components/phonely: {} components/php_point_of_sale: dependencies: @@ -10406,8 +10404,7 @@ importers: components/predictleads: {} - components/predis_ai: - specifiers: {} + components/predis_ai: {} components/prepr_graphql: {} @@ -10568,8 +10565,7 @@ importers: specifier: ^3.0.0 version: 3.0.3 - components/prompthub: - specifiers: {} + components/prompthub: {} components/promptmate_io: {} @@ -11597,8 +11593,7 @@ importers: specifier: ^2.3.0 version: 2.3.0 - components/salesroom: - specifiers: {} + components/salesroom: {} components/salestown: {} @@ -13439,8 +13434,7 @@ importers: components/test_apps_for_switching_appslug_009: {} - components/test_apps_for_switching_appslug_025: - specifiers: {} + components/test_apps_for_switching_appslug_025: {} components/testlocally: dependencies: