Skip to content
Closed
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
28 changes: 28 additions & 0 deletions components/toggl/actions/create-new-client/create-new-client.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import toggl from "../../toggl.app.mjs";

export default {
name: "Create a new client",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: "Create a new client",
name: "Create Client",

version: "0.0.1",
description: "Create a new Client [See docs here.](https://developers.track.toggl.com/docs/api/clients/index.html#post-create-client)",
type: "action",
key: "toggle-create-new-client",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
key: "toggle-create-new-client",
key: "toggle-create-client",

props: {
toggl,
name: {
type: "string",
label: "Name",
},
workspace_id: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use camelCase for prop names

Comment on lines +11 to +15
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add descriptions, even if very brief, to these props if possible

type: "integer",
label: "Workspace ID",
}
},
async run({ $ }) {
const response = await this.toggl.createNewClient({
name: this.name,
workspace_id: this.workspace_id,
})

response && $.export("$summary", "Successfully created new client");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the response should be the return value of the step

Suggested change
response && $.export("$summary", "Successfully created new client");
response && $.export("$summary", "Successfully created new client");
return response;

}
}
138 changes: 138 additions & 0 deletions components/toggl/actions/create-project/create-project.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import toggl from "../../toggl.app.mjs";

export default {
name: "Create a new Project",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: "Create a new Project",
name: "Create Project",

version: "0.0.1",
description: "Create project for given workspace. [See docs here.](https://developers.track.toggl.com/docs/api/projects#post-workspaceprojects)",
type: "action",
key: "toggle-create-new-project",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
key: "toggle-create-new-project",
key: "toggle-create-project",

props: {
toggl,
name: {
type: "string",
label: "Name",
description: 'unique for client and workspace'
},
workspace_id: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the same as the prop in the previous action, they should be a propDefinition in the app file to be used by both

Suggested change
workspace_id: {
workspaceId: {

type: "integer",
label: "Workspace ID",
description: "Numeric ID of the workspace"
},
client_id: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
client_id: {
clientId: {

type: 'integer',
label: 'client ID',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
label: 'client ID',
label: 'Client ID',

optional: true,
},
client_name: {
type: 'string',
label: 'client Name',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
label: 'client Name',
label: 'Client Name',

optional: true,
},
active: {
type: 'boolean',
label: 'Active',
optional: true,
description: ' Whether the project is archived or not',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: ' Whether the project is archived or not',
description: 'Whether the project is archived or not',

},
is_private: {
type: 'boolean',
label: 'Is Private',
optional: true,
description: 'Whether project is accessible for only project users or for all workspace users',
},
template: {
type: 'boolean',
label: 'Template',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Template" doesn't sound like a boolean

Suggested change
label: 'Template',
label: 'Is Template',

optional: true,
description: 'Whether the project can be used as a template',
},
template_id: {
type: 'integer',
label: 'Template ID',
description: "Id of the template project used on current project's creation",
optional: true,
},
billable: {
type: 'boolean',
label: 'Billable',
description: "Whether the project is billable or no (available only for pro workspaces)",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is available only for pro workspaces, shouldn't it be an optional prop?

Suggested change
description: "Whether the project is billable or no (available only for pro workspaces)",
description: "Whether the project is billable or not (available only for pro workspaces)",

},
auto_estimates: {
type: 'boolean',
label: 'Auto Estimates',
optional: true,
description: "whether the estimated hours are automatically calculated based on task estimations or manually fixed based on the value of 'estimated_hours' (premium functionality) ",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: "whether the estimated hours are automatically calculated based on task estimations or manually fixed based on the value of 'estimated_hours' (premium functionality) ",
description: "Whether the estimated hours are automatically calculated based on task estimations or manually fixed based on the value of `Estimated Hours` (premium functionality) ",

},
estimated_hours: {
type: 'boolean',
label: 'Estimated Hours',
optional: true,
description: "if auto_estimates is true then the sum of task estimations is returned, otherwise user inserted hours (premium functionality)"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: "if auto_estimates is true then the sum of task estimations is returned, otherwise user inserted hours (premium functionality)"
description: "If `Auto Estimates` is true then the sum of task estimations is returned, otherwise user inserted hours (premium functionality)"


},
color: {
type: 'string',
label: 'Color',
description: 'Project color (hex value in the form of #[0-9a-f]{6}.)',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: 'Project color (hex value in the form of #[0-9a-f]{6}.)',
description: 'Project color (hex value in the form of #[0-9a-f]{6}.)',
optional: true

},
rate: {
type: 'integer',
label: 'Rate',
description: 'Hourly Rate. premium feature',
optional: true,
},
fixed_fee: {
type: 'integer',
label: 'Rate',
description: 'Project fixed fee. premium feature',
optional: true,
},
currency: {
type: 'string',
label: 'Currency',
description: 'Project currency. premium feature',
optional: true,
},
start_date: {
type: 'string',
label: 'Start Date',
description: 'Start date of a project timeframe',
},
end_date: {
type: 'string',
label: 'End Date',
description: 'End date of a project timeframe',
},
Comment on lines +78 to +105
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase and capitalization after periods

},
async run({ $ }) {
const {
name, workspace_id,client_id,client_name, active,
is_private, template, template_id, billable, auto_estimates,
estimated_hours, color, rate, fixed_fee, currency, start_date, end_date} = this;
const payload = {
name,
workspace_id,
client_id,
client_name,
active,
is_private,
template,
template_id,
billable,
auto_estimates,
estimated_hours,
color,
rate,
fixed_fee,
currency,
start_date,
end_date
}
const response = await this.toggl.createProject({
workspace_id: this.workspace_id,
payload,
})

response && $.export("$summary", `Successfully created new project, ${response.name}`);
}
}
33 changes: 33 additions & 0 deletions components/toggl/actions/update-client/update-client.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import toggl from "../../toggl.app.mjs";

export default {
name: "Update new client",
version: "0.0.1",
description: "Upate a Client [See docs here.](https://developers.track.toggl.com/docs/api/clients/index.html#put-change-client)",
type: "action",
key: "toggle-update-client",
props: {
toggl,
name: {
type: "string",
label: "Name",
},
workspace_id: {
type: "integer",
label: "Workspace ID",
},
client_id: {
type: "integer",
label: "Client ID",
},
},
async run({ $ }) {
const response = await this.toggl.updateClient({
name: this.name,
workspace_id: this.workspace_id,
client_id: this.client_id
})

response && $.export("$summary", "Successfully updated client info.");
}
}
144 changes: 144 additions & 0 deletions components/toggl/actions/update-project/update-project.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import toggl from "../../toggl.app.mjs";

export default {
name: "Update a Project",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: "Update a Project",
name: "Update Project",

version: "0.0.1",
description: "Update project for given workspace. [See docs here.](https://developers.track.toggl.com/docs/api/projects#post-workspaceprojects)",
type: "action",
key: "toggle-update-project",
props: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These props also need to be updated with camelCase and proper capitalization

toggl,
workspace_id: {
type: "integer",
label: "Workspace ID",
description: "Numeric ID of the workspace"
},
project_id: {
type: "integer",
label: "Project ID",
description: "Numeric ID of the project"
},
name: {
type: "string",
label: "Name",
description: 'unique for client and workspace'
},
client_id: {
type: 'integer',
label: 'client ID',
optional: true,
},
client_name: {
type: 'string',
label: 'client Name',
optional: true,
},
active: {
type: 'boolean',
label: 'Active',
optional: true,
description: ' Whether the project is archived or not',
},
is_private: {
type: 'boolean',
label: 'Is Private',
optional: true,
description: 'Whether project is accessible for only project users or for all workspace users',
},
template: {
type: 'boolean',
label: 'Template',
optional: true,
description: 'Whether the project can be used as a template',
},
template_id: {
type: 'integer',
label: 'Template ID',
description: "Id of the template project used on current project's creation",
optional: true,
},
billable: {
type: 'boolean',
label: 'Billable',
description: "Whether the project is billable or no (available only for pro workspaces)",
},
auto_estimates: {
type: 'boolean',
label: 'Auto Estimates',
optional: true,
description: "whether the estimated hours are automatically calculated based on task estimations or manually fixed based on the value of 'estimated_hours' (premium functionality) ",
},
estimated_hours: {
type: 'boolean',
label: 'Estimated Hours',
optional: true,
description: "if auto_estimates is true then the sum of task estimations is returned, otherwise user inserted hours (premium functionality)"

},
color: {
type: 'string',
label: 'Color',
description: 'Project color',
},
rate: {
type: 'integer',
label: 'Rate',
description: 'Hourly Rate. premium feature',
optional: true,
},
fixed_fee: {
type: 'integer',
label: 'Rate',
description: 'Project fixed fee. premium feature',
optional: true,
},
currency: {
type: 'string',
label: 'Currency',
description: 'Project currency. premium feature',
optional: true,
},
start_date: {
type: 'string',
label: 'Start Date',
description: 'Start date of a project timeframe',
},
end_date: {
type: 'string',
label: 'End Date',
description: 'End date of a project timeframe',
},
},
async run({ $ }) {
const {
name, workspace_id,client_id,client_name, active,
is_private, template, template_id, billable, auto_estimates,
estimated_hours, color, rate, fixed_fee, currency, start_date, end_date} = this;
const data = {
name,
workspace_id,
client_id,
client_name,
active,
is_private,
template,
template_id,
billable,
auto_estimates,
estimated_hours,
color,
rate,
fixed_fee,
currency,
start_date,
end_date
}
const response = await this.toggl.updateProject({
workspace_id: this.workspace_id,
project_id: this.project_id,
payload: data,
})

response && $.export("$summary", `Successfully created updated the ${response.name} project`);
}
}
1 change: 1 addition & 0 deletions components/toggl/common/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export default {
API_BASE_URL_VERSIONS: {
"v1": "https://track.toggl.com/webhooks/api/v1",
"v8": "https://api.track.toggl.com/api/v8",
"v9": "https://api.track.toggl.com/api/v9"
},
};
34 changes: 34 additions & 0 deletions components/toggl/toggl.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,39 @@ export default {

return data;
},
async createNewClient({name, workspace_id, $, } = {}) {
const { data } = await this._makeRequest("v9", `workspaces/${workspace_id}/clients`, {
method: 'post',
data: {
name,
wid: workspace_id,
}
}, $)
return data;
},
async updateClient({name, workspace_id, client_id, $, } = {}) {
const { data } = await this._makeRequest("v9", `workspaces/${workspace_id}/clients/${client_id}`, {
method: 'put',
data: {
name,
wid: workspace_id,
}
}, $)
return data;
},
async createProject({workspace_id, payload, $, } = {}) {
const { data } = await this._makeRequest("v9", `workspaces/${workspace_id}/projects`, {
method: 'post',
data: payload,
}, $)
return data;
},
async updateProject({workspace_id, payload, project_id, $, } = {}) {
const { data } = await this._makeRequest("v9", `workspaces/${workspace_id}/projects/${project_id}`, {
method: 'put',
data: payload,
}, $)
return data;
},
},
};