jpetrucciani/hubspot3

Extending Classes

andrewstautz opened this issue · 2 comments

Hi -

I was using the code snippet from guysoft to extend the base client to emails (for which thanks!), and I noticed a couple of things:

  1. One needs to add "**options" to the params dictionary inside the function definition(s) if one wants to pass parameters as arguments to the function. I don't know if I said that right. What I mean is:
def get_email_campaigns(self, **options):
        params = {**options}
  1. I'm not sure how pagination works, really, in the extended classes, but something like this seems to:
def get_email_campaigns(self, **options):
        params = {**options}
        output = []
        finished = False
        while not finished:
            page = self._call("campaigns", method="GET", params=params)
            params['offset'] = page['offset']
            output.extend(page['campaigns'])
            if page['hasMore'] == False:
                finished = True

        return output

Neither of these is issues with the code itself, I don't think, but maybe they'd be useful for the documentation? I'm very much a beginner and I find it helpful to have examples spelled out for me. Thought I'd maybe save someone some time. Because this really is the best python sdk out there for hubspot!

Andrew S.

Thanks for the suggestions! I've definitely not been taking good care of the documentation for this lib.

I've really gotta get readthedocs set up for this and get things moved from the readme into some real documentation.

I've got a base set up on readthedocs now!
https://hubspot3.readthedocs.io/en/latest/

I've added a section on pagination and included an example.

Feel free to fork and add anything you think would be useful! I'll try to slowly add more and more documentation until it's a bit more built out