jscott1989 / python-pipedrive

Python API for interacting with the pipedrive.com API
MIT License
93 stars 44 forks source link

Output as generator with lazy-loading pagination #12

Open kevhill opened 7 years ago

kevhill commented 7 years ago

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)
jscott1989 commented 7 years ago

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? :)

Dunedan commented 6 years ago

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