python-pipedrive icon indicating copy to clipboard operation
python-pipedrive copied to clipboard

Output as generator with lazy-loading pagination

Open kevhill opened this issue 8 years ago • 2 comments

This is a backward incompatible change to the way you use the pipedrive client, but I found it useful so I'm putting it up here for discussion.

Basically, I ended up writing a bunch of management code to get more than 100 things to handle pipedrive's pagination. Instead I really just wanted to write simple for loops over the results. So, I decided to change the wrapper into something that returned a python-style generator. The interface is quite nice for basic things, but if you rely on using response['additional_data'] then that is now obscured.

tldr, you can now do this:

pd = Pipedrive(PIPEDRIVE_API_TOKEN)

for person in pd.persons()
    # each person object is a dict representing the data on that person
    func(person)

kevhill avatar Jul 19 '17 20:07 kevhill

Looks good to me - but I don't use the library any more so I'll wait and see if there's more feedback on it either way okay? :)

jscott1989 avatar Aug 19 '17 17:08 jscott1989

Using it with this PR and it works fine. :+1:

Dunedan avatar Jan 15 '18 09:01 Dunedan