######
Hustle
######
Overview
========
`Hustle `__ is a peer to peer texting communication platform. This Parsons integration with the
the `Hustle v1 API `__ provides methods for fetching agents,
organizations, groups, leads, and tags, as well as creating and updating agents and leads.
.. admonition:: Authentication
Hustle uses the
`OAuth2 client credentials flow `__.
Clients with a Hustle account can obtain the client ID and client secret needed to request a token which
grants to access the Hustle API for 2 hours before expiring.
**Warning:** 10 failed attempts to generate an access token will result in a temporary block on your IP address,
and 100 failed attempts in 24 hour results in a permanent ban.
.. admonition:: API Limits
There is a limit of 100 requests per second for endpoints returning resources.
Quickstart
==========
To instantiate the :class:`~parsons.hustle.hustle.Hustle` class,
you can either store your Hustle client ID and secret as environmental variables
(``HUSTLE_CLIENT_ID`` and ``HUSTLE_CLIENT_SECRET``, respectively) or pass them in as keyword arguments.
.. code-block:: python
:caption: Use API credentials via environmental variables
from parsons import Hustle
hustle = Hustle()
.. code-block:: python
:caption: Pass API key as argument
from parsons import Hustle
hustle = Hustle(client_id='MYID', client_secret='MYSECRET')
.. code-block:: python
:caption: Export your groups to a csv
tbl = hustle.get_groups(organization_id='ORGID')
tbl.to_csv('my_hustle_groups.csv')
.. code-block:: python
:caption: Export organizations to Redshift
tbl.get_organizations().to_redshift('hustleschema.hustle_organizations')
.. code-block:: python
:caption: Import leads from a csv
leads = Table.from_csv('my_leads.csv')
group_id = 'MYGROUP'
hustle.create_leads(leads, group_id)
API
====
.. autoclass:: parsons.hustle.hustle.Hustle
:inherited-members:
:members: