New/Mode

Overview

New/Mode is a multi-channel advocacy and civic engagement platform for organizations and campaigns. This Parsons class includes methods for fetching tools, actions, targets, campaigns, organizations, services, and outreaches. There are also methods for looking up targets and running actions given a tool_id. Most methods return either individual items as dictionaries or lists of items as Parsons Table objects.

Note

Authentication
To use the class, you need to provide a New/Mode username and password. For more information, see The New/Mode API is Here.

Quick Start

To instantiate the Newmode class, you can either store your New/Mode username and password as environmental variables (NEWMODE_API_USER and NEWMODE_API_PASSWORD, respectively) or pass in your username and password as arguments:

from parsons import Newmode

# instantiate with API credentials stored as environmental variables
newmode = Newmode()

# instantiate with API credentials passed as arguments
newmode = Newmode(api_user='my_username', api_password='my_password')

# Get existing tools.
tools = newmode.get_tools()

# Get specific tool.
tool = newmode.get_tool(tool_id)

API

class parsons.Newmode(api_user=None, api_password=None, api_version=None)[source]
get_tools(params={})[source]

Get existing tools. Args:

params:
Extra parameters sent to New/Mode library.
Returns:
Tools information as table.
get_tool(tool_id, params={})[source]

Get specific tool. Args:

tool_id:
The id of the tool to return.
params:
Extra parameters sent to New/Mode library.
Returns:
Tool information.
lookup_targets(tool_id, search=None, params={})[source]

Lookup targets for a given tool Args:

tool_id:
The tool to lookup targets.
search:
The search criteria. It could be: - Empty: If empty, return custom targets associated to the tool. - Postal code: Return targets matched by postal code. - Lat/Long: Latitude and Longitude pair separated by ‘::’. Ex. 45.451596::-73.59912099999997. It will return targets matched for those coordinates. - Search term: For your csv tools, this will return targets matched by given valid search term.
Returns:
Targets information as table.
get_action(tool_id, params={})[source]

Get the action information for a given tool. Args:

tool_id:
The id of the tool to return.
params:
Extra parameters sent to New/Mode library.
Returns:
Tool action information.
run_action(tool_id, payload, params={})[source]

Run specific action with given payload. Args:

tool_id:
The id of the tool to run.
payload:
Payload data used to run the action. Structure will depend on the stuff returned by get_action.
params:
Extra parameters sent to New/Mode library.
Returns:
Action link (if otl) or sid.
get_target(target_id, params={})[source]

Get specific target. Args:

target_id:
The id of the target to return.
params:
Extra parameters sent to New/Mode library.
Returns:
Target information.
get_campaigns(params={})[source]

Get existing campaigns. Args:

params:
Extra parameters sent to New/Mode library.
Returns:
Campaigns information as table.
get_campaign(campaign_id, params={})[source]

Get specific campaign. Args:

campaign_id:
The id of the campaign to return.
params:
Extra parameters sent to New/Mode library.
Returns:
Campaign information.
get_organizations(params={})[source]

Get existing organizations. Args:

params:
Extra parameters sent to New/Mode library.
Returns:
Organizations information as table.
get_organization(organization_id, params={})[source]

Get specific organization. Args:

organization_id:
The id of the organization to return.
params:
Extra parameters sent to New/Mode library.
Returns:
Organization information.
get_services(params={})[source]

Get existing services. Args:

params:
Extra parameters sent to New/Mode library.
Returns:
Services information as table.
get_service(service_id, params={})[source]

Get specific service. Args:

service_id:
The id of the service to return.
params:
Extra parameters sent to New/Mode library.
Returns:
Service information.
get_outreaches(tool_id, params={})[source]

Get existing outreaches for a given tool. Args:

tool_id:
Tool to return outreaches.
params:
Extra parameters sent to New/Mode library.
Returns:
Outreaches information as table.
get_outreach(outreach_id, params={})[source]

Get specific outreach. Args:

outreach_id:
The id of the outreach to return.
params:
Extra parameters sent to New/Mode library.
Returns:
Outreach information.