-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3106435
commit bde7b75
Showing
13 changed files
with
409 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import toggl from "../../toggl.app.mjs"; | ||
|
||
export default { | ||
key: "toggl-create-client", | ||
name: "Create Client", | ||
description: "Create a new client in Toggl. [See the documentation](https://engineering.toggl.com/docs/api/clients#post-create-client)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
toggl, | ||
workspaceId: { | ||
propDefinition: [ | ||
toggl, | ||
"workspaceId", | ||
], | ||
}, | ||
name: { | ||
propDefinition: [ | ||
toggl, | ||
"clientName", | ||
], | ||
}, | ||
notes: { | ||
propDefinition: [ | ||
toggl, | ||
"notes", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.toggl.createClient({ | ||
$, | ||
workspaceId: this.workspaceId, | ||
data: { | ||
name: this.name, | ||
notes: this.notes, | ||
wid: this.workspaceId, | ||
}, | ||
}); | ||
if (response.id) { | ||
$.export("$summary", `Successfully created client with ID: ${response.id}`); | ||
} | ||
return response; | ||
}, | ||
}; |
86 changes: 86 additions & 0 deletions
86
components/toggl/actions/create-project/create-project.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import toggl from "../../toggl.app.mjs"; | ||
|
||
export default { | ||
key: "toggl-create-project", | ||
name: "Create Project", | ||
description: "Create a new project in Toggl. [See the documentation](https://engineering.toggl.com/docs/api/projects#post-workspaceprojects)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
toggl, | ||
workspaceId: { | ||
propDefinition: [ | ||
toggl, | ||
"workspaceId", | ||
], | ||
}, | ||
name: { | ||
propDefinition: [ | ||
toggl, | ||
"projectName", | ||
], | ||
}, | ||
startDate: { | ||
propDefinition: [ | ||
toggl, | ||
"startDate", | ||
], | ||
}, | ||
endDate: { | ||
propDefinition: [ | ||
toggl, | ||
"endDate", | ||
], | ||
}, | ||
active: { | ||
type: "boolean", | ||
label: "Active", | ||
description: "Whether the project is active or archived. Defaults to `true`.", | ||
optional: true, | ||
default: true, | ||
}, | ||
isPrivate: { | ||
type: "boolean", | ||
label: "Is Private?", | ||
description: "Whether the project is private or not. Defaults to `false`.", | ||
optional: true, | ||
default: false, | ||
}, | ||
isShared: { | ||
type: "boolean", | ||
label: "Is Shared?", | ||
description: "Whether the project is shared or not. Defaults to `false`.", | ||
optional: true, | ||
default: false, | ||
}, | ||
clientId: { | ||
propDefinition: [ | ||
toggl, | ||
"clientId", | ||
(c) => ({ | ||
workspaceId: c.workspaceId, | ||
}), | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.toggl.createProject({ | ||
$, | ||
workspaceId: this.workspaceId, | ||
data: { | ||
name: this.name, | ||
start_date: this.startDate, | ||
end_date: this.endDate, | ||
active: this.active, | ||
is_private: this.isPrivate, | ||
is_shared: this.isShared, | ||
client_id: this.clientId, | ||
}, | ||
}); | ||
if (response.id) { | ||
$.export("$summary", `Successfully created project with ID: ${response.id}`); | ||
} | ||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import toggl from "../../toggl.app.mjs"; | ||
|
||
export default { | ||
key: "toggl-update-client", | ||
name: "Update Client", | ||
description: "Updates an existing client in Toggl. [See the documentation](https://engineering.toggl.com/docs/api/clients#put-change-client)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
toggl, | ||
workspaceId: { | ||
propDefinition: [ | ||
toggl, | ||
"workspaceId", | ||
], | ||
}, | ||
clientId: { | ||
propDefinition: [ | ||
toggl, | ||
"clientId", | ||
(c) => ({ | ||
workspaceId: c.workspaceId, | ||
}), | ||
], | ||
}, | ||
name: { | ||
propDefinition: [ | ||
toggl, | ||
"clientName", | ||
], | ||
optional: true, | ||
}, | ||
notes: { | ||
propDefinition: [ | ||
toggl, | ||
"notes", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const client = await this.toggl.getClient({ | ||
$, | ||
workspaceId: this.workspaceId, | ||
clientId: this.clientId, | ||
}); | ||
const response = await this.toggl.updateClient({ | ||
$, | ||
workspaceId: this.workspaceId, | ||
clientId: this.clientId, | ||
data: { | ||
name: this.name || client.name, | ||
notes: this.notes || client.notes, | ||
wid: this.workspaceId, | ||
}, | ||
}); | ||
if (response.id) { | ||
$.export("$summary", `Successfully updated client with ID: ${response.id}`); | ||
} | ||
return response; | ||
}, | ||
}; |
101 changes: 101 additions & 0 deletions
101
components/toggl/actions/update-project/update-project.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import toggl from "../../toggl.app.mjs"; | ||
|
||
export default { | ||
key: "toggl-update-project", | ||
name: "Update Project", | ||
description: "Updates an existing project in Toggl. [See the documentation](https://engineering.toggl.com/docs/api/projects#put-workspaceproject)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
toggl, | ||
workspaceId: { | ||
propDefinition: [ | ||
toggl, | ||
"workspaceId", | ||
], | ||
}, | ||
projectId: { | ||
propDefinition: [ | ||
toggl, | ||
"projectId", | ||
(c) => ({ | ||
workspaceId: c.workspaceId, | ||
}), | ||
], | ||
}, | ||
name: { | ||
propDefinition: [ | ||
toggl, | ||
"projectName", | ||
], | ||
optional: true, | ||
}, | ||
startDate: { | ||
propDefinition: [ | ||
toggl, | ||
"startDate", | ||
], | ||
optional: true, | ||
}, | ||
endDate: { | ||
propDefinition: [ | ||
toggl, | ||
"endDate", | ||
], | ||
optional: true, | ||
}, | ||
active: { | ||
type: "boolean", | ||
label: "Active", | ||
description: "Whether the project is active or archived.", | ||
optional: true, | ||
}, | ||
isPrivate: { | ||
type: "boolean", | ||
label: "Is Private?", | ||
description: "Whether the project is private or not.", | ||
optional: true, | ||
}, | ||
isShared: { | ||
type: "boolean", | ||
label: "Is Shared?", | ||
description: "Whether the project is shared or not.", | ||
optional: true, | ||
}, | ||
clientId: { | ||
propDefinition: [ | ||
toggl, | ||
"clientId", | ||
(c) => ({ | ||
workspaceId: c.workspaceId, | ||
}), | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const project = await this.toggl.getProject({ | ||
$, | ||
workspaceId: this.workspaceId, | ||
projectId: this.projectId, | ||
}); | ||
const response = await this.toggl.updateProject({ | ||
$, | ||
workspaceId: this.workspaceId, | ||
projectId: this.projectId, | ||
data: { | ||
name: this.name || project.name, | ||
start_date: this.startDate || project.start_date, | ||
end_date: this.endDate || project.end_date, | ||
active: this.active || project.active, | ||
is_private: this.isPrivate || project.isPrivate, | ||
is_shared: this.isShared || project.is_shared, | ||
client_id: this.clientId || project.client_id, | ||
}, | ||
}); | ||
if (response.id) { | ||
$.export("$summary", `Successfully updated project with ID: ${response.id}`); | ||
} | ||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.