Fix API call to return all Harvest Projects

This commit is contained in:
Lance Edgar 2022-07-01 12:46:06 -05:00
parent 03066f1135
commit 782cb1fcec
2 changed files with 12 additions and 2 deletions

View file

@ -122,7 +122,17 @@ class HarvestWebAPI(object):
https://help.getharvest.com/api-v2/projects-api/projects/projects/#list-all-projects
"""
response = self.get('/projects', params=kwargs)
return response.json()
data = response.json()
projects = data['projects']
while data['next_page']:
kw = dict(kwargs)
kw['page'] = data['next_page']
response = self.get('/projects', params=kw)
data = response.json()
projects.extend(data['projects'])
return projects
def get_tasks(self, **kwargs):
"""

View file

@ -151,7 +151,7 @@ class HarvestProjectImporter(FromHarvest, rattail_harvest_importing.model.Harves
model.HarvestProject.deleted == None))
def get_host_objects(self):
return self.webapi.get_projects()['projects']
return self.webapi.get_projects()
def normalize_host_object(self, project):
data = super(HarvestProjectImporter, self).normalize_host_object(project)