Fix Contact limit to 500 (#249)

* update contacts to fetch more than 500 contacts

* Make it work

Co-authored-by: Joshua Meier <joshim5@gmail.com>
This commit is contained in:
Quentame 2020-03-20 23:00:42 +01:00 committed by GitHub
parent 0757bc6ff2
commit 0fefc5cff1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,7 @@ class ContactsService(object):
self._service_root = service_root self._service_root = service_root
self._contacts_endpoint = '%s/co' % self._service_root self._contacts_endpoint = '%s/co' % self._service_root
self._contacts_refresh_url = '%s/startup' % self._contacts_endpoint self._contacts_refresh_url = '%s/startup' % self._contacts_endpoint
self._contacts_next_url = '%s/contacts' % self._contacts_endpoint
self._contacts_changeset_url = '%s/changeset' % self._contacts_endpoint self._contacts_changeset_url = '%s/changeset' % self._contacts_endpoint
def refresh_client(self): def refresh_client(self):
@ -35,9 +36,22 @@ class ContactsService(object):
) )
self.response = req.json() self.response = req.json()
params_next = dict(params_contacts)
params_next.update({
'prefToken': self.response["prefToken"],
'syncToken': self.response["syncToken"],
'limit': '0',
'offset': '0',
})
req = self.session.get(
self._contacts_next_url,
params=params_next
)
self.response = req.json()
def all(self): def all(self):
""" """
Retrieves all contacts. Retrieves all contacts.
""" """
self.refresh_client() self.refresh_client()
return self.response['contacts'] return self.response.get('contacts')