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.

Quick Start

To instantiate the 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:

from parsons import Hustle

# First approach: Use API credentials via environmental variables
hustle = Hustle()

# Second approach: Pass API credentials as arguments
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.
get_agent(agent_id)[source]

Get a single agent.

Args:
agent_id: str
The agent id.
Returns:
dict
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_group(group_id)[source]

Get a single group.

Args:
group_id: str
The group id.
get_lead(lead_id)[source]

Get a single lead..

Args:
lead_id: str
The lead id.
Returns:
dict
get_leads(organization_id=None, group_id=None)[source]

Get leads metadata. One of organization_id and group_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
tag_ids: list
Tags to apply to 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.
get_tag(tag_id)[source]

Get a single tag.

Args:
tag_id: str
The tag id.
Returns:
dict