|
| 1 | +import { axios } from "@pipedream/platform"; |
| 2 | + |
1 | 3 | export default { |
2 | 4 | type: "app", |
3 | 5 | app: "breeze", |
4 | | - propDefinitions: {}, |
| 6 | + propDefinitions: { |
| 7 | + workspaceId: { |
| 8 | + type: "string", |
| 9 | + label: "Workspace ID", |
| 10 | + description: "The workspace to associate the project with", |
| 11 | + optional: true, |
| 12 | + async options() { |
| 13 | + const workspaces = await this.getWorkspaces(); |
| 14 | + return workspaces.map((workspace) => ({ |
| 15 | + label: workspace.name || workspace.id, |
| 16 | + value: workspace.id, |
| 17 | + })); |
| 18 | + }, |
| 19 | + }, |
| 20 | + projectId: { |
| 21 | + type: "string", |
| 22 | + label: "Project ID", |
| 23 | + description: "The project to associate the task with", |
| 24 | + async options() { |
| 25 | + const projects = await this.getProjects(); |
| 26 | + return projects.map((project) => ({ |
| 27 | + label: project.name || project.id, |
| 28 | + value: project.id, |
| 29 | + })); |
| 30 | + }, |
| 31 | + }, |
| 32 | + stageId: { |
| 33 | + type: "string", |
| 34 | + label: "Stage ID", |
| 35 | + description: "The stage (list) to associate the task with", |
| 36 | + async options({ projectId }) { |
| 37 | + if (!projectId) return []; |
| 38 | + const lists = await this.getLists({ |
| 39 | + projectId, |
| 40 | + }); |
| 41 | + return lists.map((list) => ({ |
| 42 | + label: list.name || list.id, |
| 43 | + value: list.id, |
| 44 | + })); |
| 45 | + }, |
| 46 | + }, |
| 47 | + swimlaneId: { |
| 48 | + type: "string", |
| 49 | + label: "Swimlane ID", |
| 50 | + description: "The swimlane to associate the task with", |
| 51 | + async options({ projectId }) { |
| 52 | + if (!projectId) return []; |
| 53 | + const swimlanes = await this.getSwimlanes({ |
| 54 | + projectId, |
| 55 | + }); |
| 56 | + return swimlanes.map((swimlane) => ({ |
| 57 | + label: swimlane.name || swimlane.id, |
| 58 | + value: swimlane.id, |
| 59 | + })); |
| 60 | + }, |
| 61 | + }, |
| 62 | + taskId: { |
| 63 | + type: "string", |
| 64 | + label: "Task ID", |
| 65 | + description: "The task to monitor", |
| 66 | + async options({ projectId }) { |
| 67 | + if (!projectId) return []; |
| 68 | + const tasks = await this.getTasks({ |
| 69 | + projectId, |
| 70 | + }); |
| 71 | + return tasks.map((task) => ({ |
| 72 | + label: task.name || task.id, |
| 73 | + value: task.id, |
| 74 | + })); |
| 75 | + }, |
| 76 | + }, |
| 77 | + }, |
5 | 78 | methods: { |
6 | | - // this.$auth contains connected account data |
7 | | - authKeys() { |
8 | | - console.log(Object.keys(this.$auth)); |
| 79 | + _baseUrl() { |
| 80 | + return "https://api.breeze.pm"; |
| 81 | + }, |
| 82 | + async _makeRequest(opts = {}) { |
| 83 | + const { |
| 84 | + $ = this, |
| 85 | + path, |
| 86 | + ...otherOpts |
| 87 | + } = opts; |
| 88 | + return axios($, { |
| 89 | + ...otherOpts, |
| 90 | + url: this._baseUrl() + path, |
| 91 | + params: { |
| 92 | + api_token: this.$auth.api_token, |
| 93 | + ...otherOpts.params, |
| 94 | + }, |
| 95 | + }); |
| 96 | + }, |
| 97 | + async getWorkspaces(args = {}) { |
| 98 | + return this._makeRequest({ |
| 99 | + path: "/workspaces.json", |
| 100 | + ...args, |
| 101 | + }); |
| 102 | + }, |
| 103 | + async getProjects(args = {}) { |
| 104 | + return this._makeRequest({ |
| 105 | + path: "/projects.json", |
| 106 | + ...args, |
| 107 | + }); |
| 108 | + }, |
| 109 | + async getLists({ |
| 110 | + projectId, ...args |
| 111 | + } = {}) { |
| 112 | + return this._makeRequest({ |
| 113 | + path: `/projects/${projectId}/stages.json`, |
| 114 | + ...args, |
| 115 | + }); |
| 116 | + }, |
| 117 | + async getSwimlanes({ |
| 118 | + projectId, ...args |
| 119 | + } = {}) { |
| 120 | + return this._makeRequest({ |
| 121 | + path: `/projects/${projectId}/swimlanes.json`, |
| 122 | + ...args, |
| 123 | + }); |
| 124 | + }, |
| 125 | + async getTasks({ |
| 126 | + projectId, ...args |
| 127 | + } = {}) { |
| 128 | + return this._makeRequest({ |
| 129 | + path: `/V2/projects/${projectId}/cards.json`, |
| 130 | + ...args, |
| 131 | + }); |
| 132 | + }, |
| 133 | + async createTask({ |
| 134 | + projectId, ...args |
| 135 | + } = {}) { |
| 136 | + return this._makeRequest({ |
| 137 | + path: `/projects/${projectId}/cards.json`, |
| 138 | + method: "post", |
| 139 | + ...args, |
| 140 | + }); |
| 141 | + }, |
| 142 | + async createProject(args = {}) { |
| 143 | + return this._makeRequest({ |
| 144 | + path: "/projects.json", |
| 145 | + method: "post", |
| 146 | + ...args, |
| 147 | + }); |
9 | 148 | }, |
10 | 149 | }, |
11 | 150 | }; |
0 commit comments