Skip to content

Commit

Permalink
Tested components
Browse files Browse the repository at this point in the history
  • Loading branch information
jcortes committed May 10, 2024
1 parent 7845401 commit 6bc7931
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "microsoft_365_planner-create-bucket",
name: "Create Bucket",
description: "Create a new bucket in Microsoft 365 Planner. [See the documentation](https://learn.microsoft.com/en-us/graph/api/planner-post-buckets)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
microsoft365Planner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "microsoft_365_planner-create-plan",
name: "Create Plan",
description: "Create a new plan in Microsoft 365 Planner. [See the documentation](https://learn.microsoft.com/en-us/graph/api/planner-post-plans)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
microsoft365Planner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "microsoft_365_planner-create-task",
name: "Create Task",
description: "Create a new task in Microsoft 365 Planner. [See the documentation](https://learn.microsoft.com/en-us/graph/api/planner-post-tasks)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
microsoft365Planner,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import app from "../../microsoft_365_planner.app.mjs";

export default {
key: "microsoft_365_list-user-tasks",
name: "List User Tasks",
description: "List all user tasks in Microsoft 365 Planner. [See the documentation](https://learn.microsoft.com/en-us/graph/api/planneruser-list-tasks?view=graph-rest-1.0&tabs=http)",
version: "0.0.1",
type: "action",
props: {
app,
},
async run({ $ }) {
const response = await this.app.listUserTasks({
$,
});

$.export("$summary", `Successfully retrieved \`${response?.value?.length}\` task(s).`);

return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import app from "../../microsoft_365_planner.app.mjs";

export default {
key: "microsoft_365_update-task",
name: "Update Task",
description: "Updates a task in Microsoft 365 Planner. [See the documentation](https://learn.microsoft.com/en-us/graph/api/plannertask-update?view=graph-rest-1.0&tabs=http)",
version: "0.0.1",
type: "action",
props: {
app,
taskId: {
propDefinition: [
app,
"userTaskId",
],
},
title: {
type: "string",
label: "Title",
description: "Title of the task",
optional: true,
},
priority: {
type: "integer",
label: "Priority",
description: "Priority of the task",
optional: true,
},
percentComplete: {
type: "integer",
label: "Percent Complete",
description: "Percentage of task completion. When set to `100`, the task is considered completed.",
optional: true,
},
startDateTime: {
type: "datetime",
label: "Start Date Time",
description: "Date and time at which the task starts. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time. For example, midnight UTC on Jan 1, 2014 is `2014-01-01T00:00:00Z`.",
optional: true,
},
},
methods: {
updateTask({
taskId, ...args
} = {}) {
return this.app._makeRequest({
method: "PATCH",
path: `/planner/tasks/${taskId}`,
...args,
});
},
},
async run({ $ }) {
const {
app,
updateTask,
taskId,
title,
priority,
percentComplete,
startDateTime,
} = this;

const { ["@odata.etag"]: etag } = await app.getTask({
$,
taskId,
});

const response = await updateTask({
$,
taskId,
headers: {
"Content-Type": "application/json",
"If-Match": etag,
"Prefer": "return=representation",
},
data: {
title,
priority,
percentComplete,
startDateTime,
},
});

$.export("$summary", `Successfully updated task with ID \`${response.id}\`.`);

return response;
},
};
38 changes: 32 additions & 6 deletions components/microsoft_365_planner/microsoft_365_planner.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -156,25 +156,37 @@ export default {
};
},
},
userTaskId: {
type: "string",
label: "User Task ID",
description: "Identifier of a user task",
async options() {
const response = await this.listUserTasks();
return response.value?.map(({
id: value, title: label,
}) => ({
value,
label,
}));
},
},
},
methods: {
_baseUrl() {
return "https://graph.microsoft.com/v1.0";
},
_headers() {
_headers(headers) {
return {
...headers,
Authorization: `Bearer ${this.$auth.oauth_access_token}`,
};
},
_makeRequest({
$ = this,
path,
url,
...args
$ = this, path, url, headers, ...args
}) {
return axios($, {
url: url || `${this._baseUrl()}${path}`,
headers: this._headers(),
headers: this._headers(headers),
...args,
});
},
Expand Down Expand Up @@ -237,6 +249,20 @@ export default {
...args,
});
},
getTask({
taskId, ...args
}) {
return this._makeRequest({
path: `/planner/tasks/${taskId}`,
...args,
});
},
listUserTasks(args = {}) {
return this._makeRequest({
path: "/me/planner/tasks",
...args,
});
},
async *paginate({
fn, args,
}) {
Expand Down
4 changes: 2 additions & 2 deletions components/microsoft_365_planner/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/microsoft_365_planner",
"version": "0.1.0",
"version": "0.2.0",
"description": "Pipedream Microsoft 365 Planner Components",
"main": "microsoft_365_planner.app.mjs",
"keywords": [
Expand All @@ -13,6 +13,6 @@
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.5.1"
"@pipedream/platform": "^1.6.5"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "microsoft_365_planner-new-plan-created",
name: "New Plan Created",
description: "Emit new event when a new Plan is created in Microsoft 365 Planner",
version: "0.0.1",
version: "0.0.2",
type: "source",
dedupe: "unique",
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "microsoft_365_planner-new-task-created",
name: "New Task Created",
description: "Emit new event when a new Task is created in Microsoft 365 Planner",
version: "0.0.1",
version: "0.0.2",
type: "source",
dedupe: "unique",
props: {
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

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

0 comments on commit 6bc7931

Please sign in to comment.