jpetrucciani / hubspot3

python3.6+ hubspot client based on hapipy, but modified to use the newer endpoints and non-legacy python
MIT License
147 stars 73 forks source link

No "hello world" example, or documentation at all #5

Closed guysoft closed 6 years ago

guysoft commented 6 years ago

Hey, I see no way to understand where to start with this package - is there some basic connection and information retrieval example anywhere?

Thanks,

jpetrucciani commented 6 years ago

Thanks for pointing that out! That's one thing I overlooked. I'll get some documentation written and added when I get back to a computer

guysoft commented 6 years ago

Even something like this in the readme start (I can PR):

from hubspot3.companies import CompaniesClient
API = "your-api"
a = CompaniesClient(api_key=API)

Better if it has a bit more examples to other parts. For example I can't find where to get company properties API.

jpetrucciani commented 6 years ago

Feel free to PR! I can merge that in and expand on it if you'd like!

Currently I don't have a client put together for the Company Properties API. I'm missing a few different APIs, some of which were added/changed after the last time I worked on this repo.

I should be able to revisit and add some of these APIs soon, but in the meantime, could you list out the APIs I'm missing that you would like to have?

guysoft commented 6 years ago

Found you can get the company properties if you get each company individually. But Started running in to rate limits, That would also be helpful to document )

jpetrucciani commented 6 years ago

Ahh yeah, you'll be able to get all of the properties for a given company on the get company method, but there's no CompanyPropertiesClient to interact with the fine-grained properties API that hubspot has.

As for rate limits, it'll just be however Hubspot rate limits their API: https://developers.hubspot.com/apps/api_guidelines

guysoft commented 6 years ago

Er- so how about an example that shows how to use BaseClient with stuff you didn't write yet? It would help completeness.

jpetrucciani commented 6 years ago

Yeah I could add a snippet about that in just a bit

guysoft commented 6 years ago

I wrote one myself since I actually need this.

import json
from hubspot3.base import BaseClient

PIPELINES_API_VERSION = '1'
class PipelineClient(BaseClient):
    """
    Lets you extend to non-existing clients, this example extends pipelines
    """

    def __init__(self, *args, **kwargs):
        super(PipelineClient, self).__init__(*args, **kwargs)

    def get_pipelines(self, **options):
        params = {}

        return self._call('pipelines', method='GET', params=params)

    def _get_path(self, subpath):
        return 'deals/v{}/{}'.format(
            self.options.get('version') or PIPELINES_API_VERSION,
            subpath
        )

if __name__ == "__main__":
    import json
    API = "your_api"
    a = PipelineClient(api_key=API)
    print(json.dumps(a.get_pipelines()))
guysoft commented 6 years ago

Also, no docs on how to use params, for example:


import json
from hubspot3.deals import DealsClient

deal_id = "12345"
API = "your_api"
params = {"includePropertyVersions": "true"} # Note values are not pythonized
deals_client = DealsClient(api_key=API)
deal_data = deals_client.get(deal_id, params=params)
print(json.dumps(deal_data))
jpetrucciani commented 6 years ago

Added these examples to the readme! I probably should split that off into a wiki or some more involved documentation at some point