Hustle
Overview
Hustle is a peer to peer texting communication platform. The methods are built against the Hustle v1 API.
Access to the API is limited to 100 requests per second for endpoints returning resources. When this limit is reached the API will return an error and the request will need to be retried.
Creating an access token is an exception in that it only limits the number of failed attempts to create an access token. After 10 failed attempts to create an access token the ip of the request will be blocked for some period of time, but only for the account in question. Additionally 100 failed attempts in a 24-hour period will result in the requester’s ip being blocked.
Quick Start
from parsons import Hustle
hustle = Hustle(client_id='MYID', client_secret='MYSECRET')
# Export your groups to a csv
tbl = hustle.get_groups(organization_id='ORGID')
tbl.to_csv('my_hustle_groups.csv')
# Export organizations to Redshift
tbl.get_organizations().to_redshift('hustleschema.hustle_organizations')
# Import leads from a csv
leads = Table.from_csv('my_leads.csv')
group_id = 'MYGROUP'
hustle.create_leads(leads, group_id)
API
- class parsons.Hustle(client_id, client_secret)[source]
Instantiate Hustle Class
- Args:
- client_id:
The client id provided by Hustle. Not required if
HUSTLE_CLIENT_ID
env variable set.- client_secret:
The client secret provided by Hustle. Not required if
HUSTLE_CLIENT_SECRET
env variable set.
- Returns:
Hustle Class
- get_agents(group_id)[source]
Get a list of agents.
- Args:
- group_id: str
The group id.
- Returns:
- Parsons Table
See Parsons Table for output options.
- create_agent(group_id, name, full_name, phone_number, send_invite=False, email=None)[source]
Create an agent.
- Args:
- group_id: str
The group id to assign the agent.
- name: str
The name of the agent.
- full_name: str
The full name of the agent.
- phone_number: str
The valid phone number of the agent.
- send_invite: boolean
Send an invitation to the agent.
- email:
The email address of the agent.
- Returns:
dict
- update_agent(agent_id, name=None, full_name=None, send_invite=False)[source]
Update an agent.
- Args:
- agent_id: str
The agent id.
- name: str
The name of the agent.
- full_name: str
The full name of the agent.
- phone_number: str
The valid phone number of the agent.
- send_invite: boolean
Send an invitation to the agent.
- Returns:
dict
- get_organizations()[source]
Get organizations.
- Returns:
- Parsons Table
See Parsons Table for output options.
- get_organization(organization_id)[source]
Get a single organization.
- Args:
- organization_id: str
The organization id.
- Returns:
dict
- get_groups(organization_id)[source]
Get a list of groups.
- Args:
organization_id: str
- Returns:
- Parsons Table
See Parsons Table for output options.
- get_leads(organization_id=None, group_id=None)[source]
Get leads metadata. One of
organization_id
andgroup_id
must be passed as an argument. If both are passed, an error will be raised.- Args:
- organization_id: str
The organization id.
- group_id: str
The group id.
- Returns:
- Parsons Table
See Parsons Table for output options.
- create_lead(group_id, phone_number, first_name, last_name=None, email=None, notes=None, follow_up=None, custom_fields=None, tag_ids=None)[source]
Create a lead.
- Args:
- group_id: str
The group id to assign the leads.
- first_name: str
The first name of the lead.
- phone_number: str
The phone number of the lead.
- last_name: str
The last name of the lead.
- email: str
The email address of the lead.
- notes: str
The notes for the lead.
- follow_up: str
Follow up for the lead.
- custom_fields: dict
A dictionary of custom fields, with key as the value name, and value as the value.
- tag_ids: list
A list of tag ids.
- Returns:
None
- create_leads(table, group_id=None)[source]
Create multiple leads. All unrecognized fields will be passed as custom fields. Column names must map to the following names.
- Args:
- table: Parsons table
A Parsons table containing leads
- group_id:
The group id to assign the leads. If
None
, must be passed as a column value.
- Returns:
A table of created ids with associated lead id.
- update_lead(lead_id, first_name=None, last_name=None, email=None, global_opt_out=None, notes=None, follow_up=None, tag_ids=None)[source]
Update a lead.
- Args:
- lead_id: str
The lead id
- first_name: str
The first name of the lead
- last_name: str
The last name of the lead
- email: str
The email address of the lead
- global_opt_out: boolean
Opt out flag for the lead
- notes: str
The notes for the lead
- follow_up: str
Follow up for the lead
- Returns:
dict
- get_tags(organization_id)[source]
Get an organization’s tags.
- Args:
- organization_id: str
The organization id.
- Returns:
- Parsons Table
See Parsons Table for output options.