Skip to content

Commit

Permalink
Migration is complete with tested components
Browse files Browse the repository at this point in the history
  • Loading branch information
jcortes committed Jun 17, 2024
1 parent c40f0cd commit 35da75f
Show file tree
Hide file tree
Showing 26 changed files with 1,035 additions and 686 deletions.
72 changes: 45 additions & 27 deletions components/onedesk/actions/create-item/create-item.mjs
Original file line number Diff line number Diff line change
@@ -1,57 +1,75 @@
import onedesk from "../../onedesk.app.mjs";
import app from "../../onedesk.app.mjs";

export default {
key: "onedesk-create-item",
name: "Create Item",
description: "Creates a new item. [See the docs](https://www.onedesk.com/developers/#_create_work_item)",
version: "0.0.1",
description: "Creates a new item. [See the documentation](https://www.onedesk.com/dev/).",
version: "0.0.2",
type: "action",
props: {
onedesk,
app,
name: {
propDefinition: [
app,
"itemName",
],
},
type: {
propDefinition: [
onedesk,
app,
"itemType",
],
},
name: {
type: "string",
label: "Name",
description: "Name of the item",
},
description: {
type: "string",
label: "Description",
description: "Description of the item",
optional: true,
propDefinition: [
app,
"itemDescription",
],
},
spaceId: {
projectExternalId: {
propDefinition: [
onedesk,
"spaceId",
app,
"projectId",
],
},
priority: {
propDefinition: [
onedesk,
app,
"priority",
],
},
},
methods: {
createItem(args = {}) {
return this.app.post({
path: "/items/",
...args,
});
},
},
async run({ $ }) {
const { data } = await this.onedesk.createItem({
const {
createItem,
name,
type,
description,
projectExternalId,
priority,
} = this;

const response = await createItem({
$,
data: {
type: this.type,
name: this.name,
description: this.description,
spaceId: this.spaceId,
priority: this.priority,
name,
type,
description,
projectExternalId,
priority,
},
$,
});

$.export("$summary", `Successfully created item with ID ${data.id}.`);
$.export("$summary", `Successfully created item with ID \`${response.data}\`.`);

return data;
return response;
},
};
52 changes: 29 additions & 23 deletions components/onedesk/actions/create-message/create-message.mjs
Original file line number Diff line number Diff line change
@@ -1,44 +1,50 @@
import onedesk from "../../onedesk.app.mjs";
import app from "../../onedesk.app.mjs";

export default {
key: "onedesk-create-message",
name: "Create Message",
description: "Creates a message or comment. [See the docs](https://www.onedesk.com/developers/#_create_comment)",
version: "0.0.1",
description: "Creates a message or comment. [See the documentation](https://www.onedesk.com/dev/).",
version: "0.0.2",
type: "action",
props: {
onedesk,
itemId: {
app,
conversationExternalId: {
propDefinition: [
onedesk,
"itemId",
app,
"conversationExternalId",
],
},
description: {
content: {
type: "string",
label: "Description",
description: "Content of the message",
label: "Content",
description: "Content of the conversation message",
},
postType: {
propDefinition: [
onedesk,
"postType",
],
},
methods: {
createMessage(args = {}) {
return this.app.post({
path: "/conversation-messages/",
...args,
});
},
},
async run({ $ }) {
const { data } = await this.onedesk.createComment({
const {
createMessage,
conversationExternalId,
content,
} = this;

const response = await createMessage({
$,
data: {
itemId: this.itemId,
description: this.description,
postType: this.postType,
token: this.onedesk._authToken(),
conversationExternalId,
content,
},
$,
});

$.export("$summary", `Successfully created comment with ID ${data}.`);
$.export("$summary", `Successfully created message with ID \`${response.data}\`.`);

return data;
return response;
},
};
62 changes: 40 additions & 22 deletions components/onedesk/actions/create-project/create-project.mjs
Original file line number Diff line number Diff line change
@@ -1,50 +1,68 @@
import onedesk from "../../onedesk.app.mjs";
import app from "../../onedesk.app.mjs";

export default {
key: "onedesk-create-project",
name: "Create Project",
description: "Creates a project/space. [See the docs](https://www.onedesk.com/developers/#_create_space)",
version: "0.0.1",
description: "Creates a project/space. [See the documentation](https://www.onedesk.com/dev/).",
version: "0.0.2",
type: "action",
props: {
onedesk,
app,
name: {
type: "string",
label: "Name",
description: "Name of the project.",
},
type: {
label: "Project Type",
description: "Type of the project.",
propDefinition: [
onedesk,
app,
"containerType",
],
},
name: {
type: "string",
label: "Name",
description: "Name of the project/space",
},
description: {
type: "string",
label: "Description",
description: "Description of the project/space",
description: "Description of the project",
optional: true,
},
parentIds: {
parentPortfolioExternalIds: {
propDefinition: [
onedesk,
"parentIds",
app,
"parentPortfolioExternalIds",
],
},
},
methods: {
createProject(args = {}) {
return this.app.post({
path: "/projects/",
...args,
});
},
},
async run({ $ }) {
const { data } = await this.onedesk.createSpace({
const {
createProject,
type,
name,
description,
parentPortfolioExternalIds,
} = this;

const response = await createProject({
$,
data: {
containerType: this.type,
name: this.name,
description: this.description,
parentIds: this.parentIds,
type,
name,
description,
parentPortfolioExternalIds,
},
$,
});

$.export("$summary", `Successfully created project with ID ${data.id}.`);
$.export("$summary", `Successfully created project with ID \`${response.data}\`.`);

return data;
return response;
},
};
68 changes: 45 additions & 23 deletions components/onedesk/actions/create-user/create-user.mjs
Original file line number Diff line number Diff line change
@@ -1,62 +1,84 @@
import onedesk from "../../onedesk.app.mjs";
import app from "../../onedesk.app.mjs";

export default {
key: "onedesk-create-user",
name: "Create User",
description: "Creates a user or a customer. [See the docs](https://www.onedesk.com/developers/#_create_user)",
version: "0.0.1",
description: "Creates a user or a customer. [See the documentation](https://www.onedesk.com/dev/).",
version: "0.0.2",
type: "action",
props: {
onedesk,
app,
email: {
type: "string",
label: "Email",
description: "The new user email",
},
firstName: {
type: "string",
label: "First Name",
description: "The first name of the new user",
optional: true,
},
lastName: {
type: "string",
label: "Last Name",
description: "The last name of the new user",
},
email: {
type: "string",
label: "Email",
description: "The new user email",
optional: true,
},
type: {
propDefinition: [
onedesk,
app,
"userType",
],
},
teamId: {
teams: {
type: "string[]",
label: "Team IDs",
propDefinition: [
onedesk,
app,
"teamId",
],
},
isAdministrator: {
isAdmin: {
type: "boolean",
label: "Is Administrator",
description: "Set to `true` if the new user should be an administrator",
optional: true,
},
},
methods: {
createUser(args = {}) {
return this.app.post({
path: "/users/",
...args,
});
},
},
async run({ $ }) {
const { data } = await this.onedesk.createUser({
const {
createUser,
email,
firstName,
lastName,
type,
teams,
isAdmin,
} = this;

const response = await createUser({
$,
data: {
firstName: this.firstName,
lastName: this.lastName,
email: this.email,
type: this.type,
teamId: this.teamId,
isAdministrator: this.isAdministrator,
email,
firstName,
lastName,
type,
teams,
isAdmin,
},
$,
});

$.export("$summary", `Successfully created user with ID ${data.id}.`);
$.export("$summary", `Successfully created user with ID \`${response.data}\`.`);

return data;
return response;
},
};
Loading

0 comments on commit 35da75f

Please sign in to comment.