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
56 changes: 56 additions & 0 deletions components/elorus/actions/create-task/create-task.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import app from "../../elorus.app.mjs";

export default {
key: "elorus-create-task",
name: "Create Task",
description: "Create a new task in Elorus. [See the documentation](https://developer.elorus.com/#operation/tasks_create)",
version: "0.0.1",
type: "action",
props: {
app,
name: {
propDefinition: [
app,
"name",
],
},
description: {
propDefinition: [
app,
"description",
],
},
hourlyRate: {
propDefinition: [
app,
"hourlyRate",
],
},
project: {
propDefinition: [
app,
"project",
],
},
active: {
propDefinition: [
app,
"active",
],
},
},
async run({ $ }) {
const response = await this.app.createTask({
$,
data: {
name: this.name,
description: this.description,
hourly_rate: this.hourlyRate,
project: this.project,
active: this.active,
},
});
$.export("$summary", "Successfully created the task with id: " + response.id);
return response;
},
};
26 changes: 26 additions & 0 deletions components/elorus/actions/delete-tasks/delete-tasks.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import app from "../../elorus.app.mjs";

export default {
key: "elorus-delete-tasks",
name: "Delete Tasks",
description: "Delete a task from Elorus. [See the documentation](https://developer.elorus.com/#operation/tasks_delete)",
version: "0.0.1",
type: "action",
props: {
app,
taskId: {
propDefinition: [
app,
"taskId",
],
},
},
async run({ $ }) {
const response = await this.app.deleteTasks({
$,
taskId: this.taskId,
});
$.export("$summary", "Successfully deleted the task with ID: " + this.taskId);
return response;
},
};
44 changes: 44 additions & 0 deletions components/elorus/actions/get-tasks/get-tasks.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import app from "../../elorus.app.mjs";

export default {
key: "elorus-get-tasks",
name: "Get Tasks",
description: "Get a list of tasks from Elorus. [See the documentation](https://developer.elorus.com/#operation/tasks_list)",
version: "0.0.1",
type: "action",
props: {
app,
search: {
propDefinition: [
app,
"search",
],
},
project: {
propDefinition: [
app,
"project",
],
},
active: {
propDefinition: [
app,
"active",
],
},
},
async run({ $ }) {
const response = await this.app.getTasks({
$,
params: {
search: this.search,
project: this.project,
active: this.active
? 1
: 0,
},
});
$.export("$summary", "Successfully sent the request and retrieved " + response.results.length + " results");
return response;
},
};
131 changes: 127 additions & 4 deletions components/elorus/elorus.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,134 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "elorus",
propDefinitions: {},
propDefinitions: {
name: {
type: "string",
label: "Name",
description: "The name of the task",
},
description: {
type: "string",
label: "Description",
description: "Short description of the task",
optional: true,
},
hourlyRate: {
type: "string",
label: "Hourly Rate",
description: "The hourly rate of the task",
optional: true,
},
project: {
type: "string",
label: "Project",
description: "The project associated with the task",
async options() {
const response = await this.getProjects();
const projectsIds = response.results;
return projectsIds.map(({
id,
name,
}) => ({
value: id,
label: name,
}));
},
optional: true,
},
active: {
type: "boolean",
label: "Active",
description: "Specifies if the task is active",
optional: true,
},
taskId: {
type: "string",
label: "Task Id",
description: "The unique identifier of the task",
async options({ page }) {
try {
const response = await this.getTasks({
params: {
"page": page + 1,
"page_size": 100,
},
});
const tasks = response.results || [];
if (!tasks.length) {
return [];
}
return tasks.map(({
id, name,
}) => ({
value: id,
label: name,
}));
} catch (err) {
if (err.response?.data?.detail === "Invalid page.") {
return [];
}
throw err;
}
},
},
search: {
type: "string",
label: "Search",
description: "A search term",
optional: true,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.elorus.com";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
"Authorization": `Token ${this.$auth.api_key}`,
"X-Elorus-Organization": `${this.$auth.organization_id}`,
...headers,
},
});
},
async getTasks(args = {}) {
return this._makeRequest({
path: "/v1.2/tasks/",
...args,
});
},
async getProjects(args = {}) {
return this._makeRequest({
path: "/v1.2/projects/",
...args,
});
},
async deleteTasks({
taskId, ...args
}) {
return this._makeRequest({
path: `/v1.2/tasks/${taskId}/`,
method: "delete",
...args,
});
},
async createTask(args = {}) {
return this._makeRequest({
path: "/v1.2/tasks/",
method: "post",
...args,
});
},
},
};
5 changes: 4 additions & 1 deletion components/elorus/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/elorus",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Elorus Components",
"main": "elorus.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
11 changes: 8 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading