Skip to content

Commit

Permalink
feat(toggl.js): add getTimeEntryDetails method
Browse files Browse the repository at this point in the history
Add method to get details about a specified timeEntry

re #3
  • Loading branch information
CodeSpent committed Jul 13, 2020
1 parent 5839111 commit 7280a6e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions toggl.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,27 @@ const stopTimer = (apiToken, timeEntryId) => {
});
};

const getTimeEntryDetails = (apiToken, timeEntryId) => {
return axios({
method: 'get',
url: `https://www.toggl.com/api/v8/time_entries/${timeEntryId}`,
auth: {
// Per Toggl API docs supply the apiToken as the
// username, and a string of 'api_token' for the password.
// Reference: https://github.com/toggl/toggl_api_docs/blob/master/chapters/authentication.md
username: apiToken,
password: 'api_token',
},
headers: {'Content-Type': 'application/json'},
}).then((response) => {
return response.data.data;
});
};

exports.validateApiToken = validateApiToken;
exports.getUserWorkspaces = getUserWorkspaces;
exports.getWorkspaceProjects = getWorkspaceProjects;
exports.createProject = createProject;
exports.startTimer = startTimer;
exports.stopTimer = stopTimer;
exports.getTimeEntryDetails = getTimeEntryDetails;

0 comments on commit 7280a6e

Please sign in to comment.