Add stop_time_entry()
API method
This commit is contained in:
parent
d8e9714771
commit
c6332be453
|
@ -58,6 +58,9 @@ class HarvestWebAPI(object):
|
|||
elif request_method == 'POST':
|
||||
response = requests.post('{}/{}'.format(self.base_url, api_method),
|
||||
headers=headers, params=params)
|
||||
elif request_method == 'PATCH':
|
||||
response = requests.patch('{}/{}'.format(self.base_url, api_method),
|
||||
headers=headers, params=params)
|
||||
else:
|
||||
raise NotImplementedError("unknown request method: {}".format(
|
||||
request_method))
|
||||
|
@ -76,6 +79,12 @@ class HarvestWebAPI(object):
|
|||
"""
|
||||
return self._request('POST', api_method, params=params)
|
||||
|
||||
def patch(self, api_method, params=None):
|
||||
"""
|
||||
Perform a PATCH request for the given API method, and return the response.
|
||||
"""
|
||||
return self._request('PATCH', api_method, params=params)
|
||||
|
||||
def get_company(self):
|
||||
"""
|
||||
Retrieves the company for the currently authenticated user.
|
||||
|
@ -168,6 +177,15 @@ class HarvestWebAPI(object):
|
|||
response = self.post('/time_entries', params=kwargs)
|
||||
return response.json()
|
||||
|
||||
def stop_time_entry(self, time_entry_id):
|
||||
"""
|
||||
Stop a running time entry.
|
||||
|
||||
https://help.getharvest.com/api-v2/timesheets-api/timesheets/time-entries/#stop-a-running-time-entry
|
||||
"""
|
||||
response = self.patch('/time_entries/{}/stop'.format(time_entry_id))
|
||||
return response.json()
|
||||
|
||||
|
||||
def make_harvest_webapi(config):
|
||||
access_token = config.require('harvest', 'api.access_token')
|
||||
|
|
Loading…
Reference in a new issue