-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Toggl Client & Project Creation #13884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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; | ||
}, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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; | ||
}, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
101 changes: 101 additions & 0 deletions
101
components/toggl/actions/update-project/update-project.mjs
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.