Skip to content

Commit

Permalink
ActiTime: New action and source components (#13798)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcortes authored Sep 4, 2024
1 parent 246a000 commit 06576ef
Show file tree
Hide file tree
Showing 15 changed files with 710 additions and 8 deletions.
49 changes: 49 additions & 0 deletions components/actitime/actions/create-customer/create-customer.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import app from "../../actitime.app.mjs";

export default {
key: "actitime-create-customer",
name: "Create Customer",
description: "Creates a new customer. [See the documentation](https://online.actitime.com/pipedream/api/v1/swagger).",
version: "0.0.1",
type: "action",
props: {
app,
name: {
type: "string",
label: "Name",
description: "The name of the customer.",
},
description: {
type: "string",
label: "Description",
description: "Details about the customer.",
optional: true,
},
},
methods: {
createCustomer(args = {}) {
return this.app.post({
path: "/customers",
...args,
});
},
},
async run({ $ }) {
const {
createCustomer,
name,
description,
} = this;

const response = await createCustomer({
$,
data: {
name,
description,
},
});

$.export("$summary", `Successfully created customer with ID \`${response.id}\`.`);
return response;
},
};
107 changes: 107 additions & 0 deletions components/actitime/actions/create-task/create-task.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import { ConfigurationError } from "@pipedream/platform";
import app from "../../actitime.app.mjs";

export default {
key: "actitime-create-task",
name: "Create Task",
description: "Creates a new task. [See the documentation](https://online.actitime.com/pipedream/api/v1/swagger).",
version: "0.0.1",
type: "action",
props: {
app,
projectId: {
propDefinition: [
app,
"projectId",
],
},
name: {
type: "string",
label: "Name",
description: "The name of the task.",
},
description: {
type: "string",
label: "Description",
description: "Details about the task.",
optional: true,
},
typeOfWorkId: {
propDefinition: [
app,
"typeOfWorkId",
],
},
deadline: {
type: "string",
label: "Deadline",
description: "The deadline for the task. Eg. `2024-12-31`.",
optional: true,
},
estimatedTime: {
type: "integer",
label: "Estimated Time",
description: "The estimated time for the task in minutes.",
optional: true,
},
status: {
type: "string",
label: "Status",
description: "The status of the task. This field is mutually exclusive with **Workflow Status ID**.",
optional: true,
options: [
"open",
"completed",
],
},
workflowStatusId: {
description: "The ID of the workflow status. This field is mutually exclusive with **Status**.",
propDefinition: [
app,
"workflowStatusId",
],
},
},
methods: {
createTask(args = {}) {
return this.app.post({
path: "/tasks",
...args,
});
},
},
async run({ $ }) {
const {
createTask,
name,
description,
status,
workflowStatusId,
typeOfWorkId,
deadline,
estimatedTime,
projectId,
} = this;

if (status && workflowStatusId) {
throw new ConfigurationError("The **Status** and **Workflow Status ID** fields are mutually exclusive. Please provide only one of them.");
}

const response = await createTask({
$,
data: {
name,
description,
status,
workflowStatusId,
typeOfWorkId,
deadline,
estimatedTime,
projectId,
},
});

$.export("$summary", `Successfully created task with ID \`${response.id}\`.`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import app from "../../actitime.app.mjs";

export default {
key: "actitime-modify-leave-time",
name: "Modify Leave Time",
description: "Changes the existing leave time record with a given value in actiTIME. [See the documentation](https://online.actitime.com/pipedream/api/v1/swagger).",
version: "0.0.1",
type: "action",
props: {
app,
userId: {
propDefinition: [
app,
"userId",
],
},
date: {
type: "string",
label: "Date",
description: "The date of the leave record. Date in following format: `YYYY-MM-DD` OR `today`.",
},
leaveTypeId: {
propDefinition: [
app,
"leaveTypeId",
],
},
leaveTime: {
type: "integer",
label: "Leave Time",
description: "The leave time in minutes.",
},
},
methods: {
updateLeaveTime({
userId, date, leaveTypeId, ...args
} = {}) {
return this.app.patch({
path: `/leavetime/${userId}/${date}/${leaveTypeId}`,
...args,
});
},
},
async run({ $ }) {
const {
updateLeaveTime,
userId,
date,
leaveTypeId,
leaveTime,
} = this;

const response = await updateLeaveTime({
$,
userId,
date,
leaveTypeId,
data: {
leaveTime,
},
});

$.export("$summary", "Successfully modified leave time record.");

return response;
},
};
Loading

0 comments on commit 06576ef

Please sign in to comment.