Add basic support for updating a Harvest Time Entry via API

This commit is contained in:
Lance Edgar 2022-03-06 11:09:59 -06:00
parent d84cc7a9d9
commit 03066f1135
2 changed files with 27 additions and 5 deletions

View file

@ -163,7 +163,7 @@ class HarvestWebAPI(object):
response = self.get('/time_entries/{}'.format(time_entry_id))
return response.json()
def put_time_entry(self, **kwargs):
def create_time_entry(self, **kwargs):
"""
Create a new time entry. All kwargs are passed on as POST parameters.
@ -177,6 +177,9 @@ class HarvestWebAPI(object):
response = self.post('/time_entries', params=kwargs)
return response.json()
# TODO: deprecate / remove this
put_time_entry = create_time_entry
def stop_time_entry(self, time_entry_id):
"""
Stop a running time entry.
@ -186,6 +189,15 @@ class HarvestWebAPI(object):
response = self.patch('/time_entries/{}/stop'.format(time_entry_id))
return response.json()
def update_time_entry(self, time_entry_id, **kwargs):
"""
Update a time entry.
https://help.getharvest.com/api-v2/timesheets-api/timesheets/time-entries/#update-a-time-entry
"""
response = self.patch('/time_entries/{}'.format(time_entry_id), params=kwargs)
return response.json()
def make_harvest_webapi(config):
access_token = config.require('harvest', 'api.access_token')