"""Python wrapper for Follow the Money web API.

This module allows you to access Follow the Money's web API. It's descripted here:
	http://www.followthemoney.org/services/

This module borrows heavily from the pyamazon module.

You will need an API key to use this module. Follow the link above to get one. The functions will look in several places (in order) for the API key:
- the "license_key" argument for each function
- the module-level LICENSE_KEY variable (call setLicense once to set it)
- an environment variable called FOLLOWTHEMONEY_LICENSE_KEY
- a file called ".followthemoney" in the current directory
- a file called "followthemoney.txt" in the current directory
- a file called ".followthemoney" in your home directory
- a file called "followthemoney.txt" in your home directory
- a file called ".followthemoney" in the same directory as followthemoney.py
- a file called "followthemoney.txt" in the same directory as followthemoney.py

Sample usage:
>>> import followthemoney
>>> c = followthemoney.candidates_list(state='ga', year='2006', candidate_name='Johnson, Eric')
>>> candidate=c.candidate
>>> print candidate.candidate_name, candidate.district, candidate.imsp_candidate_id
JOHNSON, ERIC 001 415990
>>> top = followthemoney.candidates_top_contributors(imsp_candidate_id=candidate.imsp_candidate_id)
>>> for tc in top.top_contributor: print tc.contributor_name
...

Available functions:
- elections_state_list
- elections_year_list
- industries_list
- states_offices_breakdowns
- states_offices_businesses
- states_offices_districts
- states_offices_industries
- states_offices
- states_offices_sectors
- states_top_contributors
- candidates_businesses
- candidates_contributions
- candidates_industries
- candidates_list
- candidates_sectors
- candidates_top_contributors
- party_pacs_committees_businesses
- party_pacs_committees_contributions
- party_pacs_committees_industries
- party_pacs_committees
- party_pacs_committees_sectors
- party_pacs_committees_top_contributors
- ballot_measures_committees_businesses
- ballot_measures_committees_contributions
- ballot_measures_committees_industries
- ballot_measures_committees
- ballot_measures_committees_sectors
- ballot_measures_committees_top_contributors
- ballot_measures_list
- contributors_name_search

"""

__author__ = "Bryan L. Fordham (bfordham@socialistsushi.com)"
__version__ = "0.9.0"
__copyright__ = "Copyright (c) 2007 Bryan L. Fordham"
__license__ = "Python"

import os, sys, urllib2, string
from xml.dom import minidom
from urlparse import urljoin
from urllib import urlencode

LICENSE_KEY = None

BASE = 'http://www.followthemoney.org/api/'

class FollowTheMoneyError(Exception): pass
class NoLicenseKey(Exception): pass

# the code for finding the key gleefully stolen and adopted from pyamazon
_ftmfile1 = ".followthemoneykey"
_ftmfile2 = "followthemoneykey.txt"
_licenseLocations = (
    (lambda key: key, 'passed to the function in license_key variable'),
    (lambda key: LICENSE_KEY, 'module-level LICENSE_KEY variable (call setLicense to set it)'),
    (lambda key: os.environ.get('FOLLOWTHEMONEY_LICENSE_KEY', None), 'an environment variable called FOLLOWTHEMONEY_LICENSE_KEY'),
    (lambda key: _contentsOf(os.getcwd(), _ftmfile1), '%s in the current directory' % _ftmfile1),
    (lambda key: _contentsOf(os.getcwd(), _ftmfile2), '%s in the current directory' % _ftmfile2),
    (lambda key: _contentsOf(os.environ.get('HOME', ''), _ftmfile1), '%s in your home directory' % _ftmfile1),
    (lambda key: _contentsOf(os.environ.get('HOME', ''), _ftmfile2), '%s in your home directory' % _ftmfile2),
    (lambda key: _contentsOf(_getScriptDir(), _ftmfile1), '%s in the followthemoney.py directory' % _ftmfile1),
    (lambda key: _contentsOf(_getScriptDir(), _ftmfile2), '%s in the followthemoney.py directory' % _ftmfile2)
    )
    
def setLicense(license_key):
    """set license key"""
    global LICENSE_KEY
    LICENSE_KEY = license_key

def getLicense(license_key = None):
    """get license key

    license key can come from any number of locations;
    see module docs for search order"""
    for get, location in _licenseLocations:
        rc = get(license_key)
        if rc: return rc
    raise NoLicenseKey, 'get a license key at http://www.followthemoney.org/services/'

def _contentsOf(dirname, filename):
    filename = os.path.join(dirname, filename)
    if not os.path.exists(filename): return None
    fsock = open(filename)
    contents =  fsock.read().strip()
    fsock.close()
    return contents
    
def _getScriptDir():
    if __name__ == '__main__':
        return os.path.abspath(os.path.dirname(sys.argv[0]))
    else:
        return os.path.abspath(os.path.dirname(sys.modules[__name__].__file__))


# the code for unmarshal() gleefully stolen and adopted from pyamazon
class Bag: pass

def unmarshal(element):
    rc = Bag()
    if isinstance(element, minidom.Element) and element.hasAttributes():
        atts = element.attributes
        for k, v in atts.items():
            setattr(rc, k, v)
    childElements = [e for e in element.childNodes if isinstance(e, minidom.Element)]
    if childElements:
        for child in childElements:
            key = child.tagName
            if hasattr(rc, key):
                if type(getattr(rc, key)) <> type([]):
                    setattr(rc, key, [getattr(rc, key)])
                setattr(rc, key, getattr(rc, key) + [unmarshal(child)])
            else:
                setattr(rc, key, unmarshal(child))
    return rc                               

def run_query(method, opts, license_key=None, required=[], optional=[]):
    args = {}
    for k, v in opts.items():
        if v: args[k]=v

    for key in args.keys():
        if key not in required and key not in optional:
            raise FollowTheMoneyError, "Invalid argument: %s" % key

        for key in required:
            if not args[key]:
                raise FollowTheMoneyError, "Missing required argument: %s" % key
    args['key'] = getLicense(license_key)
    url = urljoin(BASE, method+".php") + '?' + urlencode(args)
    usock = urllib2.urlopen(url)
    xmldoc = minidom.parse(usock)
    usock.close() 
    data = unmarshal(xmldoc)
    if hasattr(data, 'error'):
        msg = '%s %s' % (data.error.code, data.error.text)
        raise FollowTheMoneyError, str(msg)
    else:
        data = getattr(data, method)
        return data
    
def elections_state_list(license_key=None, **args):
    """Corresponds to the "base_level.elections.state.list" command.

This method will return a list of states that have campaign data available.
This can be refined down to a specific year and/or office if desired.

Parameters:
	license_key - Follow the money API key
    state - this argument will expect either the full state name or the postal abbreviation of the state the election is in.
    year - this argument expects the year the election is being voting on.
    office - this argument expects the office name, office code or a sub part of the office name.
    sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
    state_name - sort in alphabetical order by the name of state.
    state_postal_code - sort in alphabetical order by the postal abbreviation of the state.

Results:
    state - the state you passed from the argument list
    year - the year you passed from the argument list
    office - the office you passed from the argument list
    record_count - the total number of records that were returned
    origin - the source of the data
    process_timestamp - the date and time you ran this query
    update_timestamp - the date and time of the last update to the database
    state_list - elements:
        state_postal_code - the two character postal code abbreviation for the state
        state_name - the full text name of the state
"""

    return run_query('base_level.elections.state.list', 
                     args,
                     license_key,
                     optional=['state', 'year', 'office', 'sort'])

def elections_year_list(license_key=None, **args):
	"""Corresponds to the "base_level.elections.year.list" command
    
This method will return a list of years that have campaign data available. This list can be refined down to a specific state and/or office if desired

Parameters:
	license_key - Follow the money API key
	state - this argument will expect either the full state name or the postal  abbreviation of the state the election is in.
	year - this argument expects the year the election is being voting on.
	office - this argument expects the office name, office code or a sub part  of the office name.

Results:
	state - the state you passed from the argument list
	year - the year you passed from the argument list
	office - the office you passed from the argument list
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	year_list - elements:
		year - the election year
"""
	return run_query('base_level.elections.year.list',
	                 args, 
	                 license_key,
	                 optional=['state','year','office'])
	                 
def industries_list(license_key=None, **args):
	"""Corresponds to the "base_level.industries.list" command
    
This method will return a list of all business, industry and sector categories and how they relate to each other. Including are any id numbers that are used for them. This list is too large to fit on a single page and will require multiple page calls to retrieve the entire list.

Parameters:
	license_key - Follow the money API key
	page - this argument expects a numerical value representing the current
	       page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish 
	       to have the returned data sorted. The following are valid sort 
	       arguments for this method:
	          sector_name - sort in alphabetical order by each sector level  category name.
	          industry_name - sort in alphabetical order by each industry level category name.
	          business_name - sort in alphabetical order by each business level category name.

Results:
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	business_detail - elements:
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		imsp_industry_code - the industry level category id number
		industry_name - the name of the industry level category
		business_name - the name of the business level category
"""
	return run_query('base_level.industries.list',
	                 args, 
	                 license_key,
	                 optional=['page','sort'])

def states_offices_breakdowns(license_key=None, **args):
	"""Corresponds to the "states.offices.breakdowns.php" command
    
This method will return a breakdown of contributions by state, year and office. It will return contribution totals for winners, losers, democrats, republicans, third parties, incumbents, challengers and open seats totaled for each state, year and office in the list.

Parameters:
	license_key - Follow the money API key
	state - this argument will expect either the full state name or the postal  abbreviation of the state being searched.
	year - this argument expects the election year being searched.
	office - this argument expects the office name, office code or a sub part  of the office name.
	page - this argument expects a numerical value representing the current page  of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to  have the returned data sorted. The following are valid sort arguments  for this method:
	           state_name - sort in alphabetical order by the name of state.
	           state_postal_code - sort in alphabetical order by the postal abbreviation of  the state.
	           year - sort in order by election year..
	           office - sort in alphabetical order by office name.

Results:
	state - the state you passed from the argument list
	year - the year you passed from the argument list
	office - the office you passed from the argument list
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database 
	state_office_breakdown - elements:
		state_postal_code - the two character postal code abbreviation for the state
		state_name - the full text name of the state
		year - the election year
		imsp_office_code - the office id number
		office - the name of the office
		winners_total_recipients - the total number of winning recipients in this  group
		winners_total_contribution_records - the total number of contribution records for all winning recipients in this group
		winners_total_dollars - the total of all contributions for all winning  recipients in this group
		losers_total_recipients - the total number of losing recipients in this group
		losers_total_contribution_records - the total number of contribution records for all losing recipients in this group
		losers_total_dollars - the total of all contributions for all losing  recipients in this group
		democrat_total_recipients - the total number of democrat recipients in this  group
		democrat_total_contribution_records - the total number of contribution  records for all democrat recipients  in this group
		democrat_total_dollars - the total of all contributions for all democrat  recipients in this group
		republican_total_recipients - the total number of republican recipients in this group
		republican_total_contribution_records - the total number of contribution  records for all republican recipients in this group
		republican_total_dollars - the total of all contributions for all republican recipients in this group
		third_party_total_recipients - the total number of third party recipients in  this group
		third_party_total_contribution_records - the total number of contribution  records for all third party  recipients in this group
		third_party_total_dollars - the total of all contributions for all third  party recipients in this group
		incumbent_total_recipients - the total number of third incumbent recipients in this group
		incumbent_total_contribution_records - the total number of contribution  records for all incumbent recipients in this group
		incumbent_total_dollars - the total of all contributions for all incumbent recipients in this group
		challenger_total_recipients - the total number of challenger recipients in  this group
		challenger_total_contribution_records - the total number of contribution  records for all challenger recipients in this group
		challenger_total_dollars - the total of all contributions for all challenger recipients in this group
		open_seat_total_recipients - the total number of open seat recipients in this group
		open_seat_total_contribution_records - the total number of contribution  records for all open seat recipients in this group
		open_seat_total_dollars - the total of all contributions for all open seat recipients in this group
"""
	return run_query('states.offices.breakdowns',
	                 args, 
	                 license_key,
	                 optional=['state', 'year', 'office', 'page', 'sort', 'state_name', 'state_postal_code', 'year', 'office'])
	                 

def states_offices_businesses(license_key=None, **args):
    """Corresponds to the "states.offices.businesses" command.

This method will summarize contributions at the business level for an entire state and year. The data can also be broken down by office within each state and year if desired. Please see the base_level.industries.list.php method to obtain a full list of all business categories along with thier industry and sector grouping information.

Parameters:
	license_key - Follow the money API key
	state - this argument will expect either the full state name or the postal abbreviation of the state being searched.
	year - this argument expects the election year being searched.
	office - this argument expects the office name, office code or a sub part of the office name.
	office_breakdown - this arguments expects a value of either 0 or 1 and defaults to 0. 0: Do not summarize data by office; 1: Summarize data by office
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		state_name - sort in alphabetical order by the name of state.
		state_postal_code - sort in alphabetical order by the postal abbreviation of the state.
		year - sort in order by election year..
		office - sort in alphabetical order by office name.
		sector_name - sort in alphabetical order by each sector level category name.
		industry_name - sort in alphabetical order by each industry level category name.
		business_name - sort in alphabetical order by each business level category name.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	state - the state you passed from the argument list
	year - the year you passed from the argument list
	office - the office you passed from the argument list
	office_breakdown - the office breakdown code you passed from the argument list
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	state_offices_business - elements:
		state_postal_code - the two character postal code abbreviation for the state
		state_name - the full text name of the state
		year - the election year
		business_name - the name of the business level category
		imsp_industry_code - the industry level category id number
		industry_name - the name of the industry level category
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('states.offices.businesses', 
                     args,
                     license_key,
                     required=[],
                     optional=['state', 'year', 'office', 'office_breakdown', 'page', 'sort', 'state_name', 'state_postal_code', 'year', 'office', 'sector_name', 'industry_name', 'business_name', 'total_dollars'])

def states_offices_districts(license_key=None, **args):
    """Corresponds to the "states.offices.districts" command.

This method will summarize contributions by state, year, office and district and return a list of contribution totals and recipient counts for each district. The state, year and office arguments are required.

Parameters:
	license_key - Follow the money API key
	state - this is a required argument - this argument will expect either the full state name or the postal abbreviation of the state being searched.
	year - this is a required argument - this argument expects the election year being searched.
	office - this argument expects the office name, office code or a sub part of the office name.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		district - sort in alphabetical order by district.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	state - the state you passed in your argument list
	year - the year you passed in your argument list
	office - the office you passed in your argument list
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	state_office_district - elements:
		state_postal_code - the two character postal code abbreviation for the state
		state_name - the full text name of the state
		year - the election year
		imsp_office_code - the office id number
		office - the office name
		district - the district
		total_recipients - the total number of recipients in this group
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('states.offices.districts', 
                     args,
                     license_key,
                     required=['state', 'year'],
                     optional=['office', 'page', 'sort', 'district', 'total_dollars'])

def states_offices_industries(license_key=None, **args):
    """Corresponds to the "states.offices.industries" command.

This method will summarize contributions at the industry level for an entire state and year. The data can also be broken down by office within each state and year if desired. Please see the base_level.industries.list.php method to obtain a full list of all industry categories along with thier sector grouping information and a list of the business categories under each industry.

Parameters:
	license_key - Follow the money API key
	state - this argument will expect either the full state name or the postal abbreviation of the state being searched.
	year - this argument expects the election year being searched.
	office - this argument expects the office name, office code or a sub part of the office name.
	office_breakdown - this arguments expects a value of either 0 or 1 and defaults to 0. 0: Do not summarize data by office; 1: Summarize data by office
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		state_name - sort in alphabetical order by the name of state.
		state_postal_code - sort in alphabetical order by the postal abbreviation of the state.
		year - sort in order by election year..
		office - sort in alphabetical order by office name.
		sector_name - sort in alphabetical order by each sector level category name.
		industry_name - sort in alphabetical order by each industry level category name.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	state - the state you passed from the argument list
	year - the year you passed from the argument list
	office - the office you passed from the argument list
	office_breakdown - the office breakdown code you passed from the argument list
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	state_offices_industry - elements:
		state_postal_code - the two character postal code abbreviation for the state
		state_name - the full text name of the state
		year - the election year
		imsp_industry_code - the industry level category id number
		industry_name - the name of the industry level category
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('states.offices.industries', 
                     args,
                     license_key,
                     required=[],
                     optional=['state', 'year', 'office', 'office_breakdown', 'page', 'sort', 'state_name', 'state_postal_code', 'year', 'office', 'sector_name', 'industry_name', 'total_dollars'])

def states_offices(license_key=None, **args):
    """Corresponds to the "states.offices" command.

This method will summarize contributions and return a list of offices and thier contribution totals for each state and year selected.

Parameters:
	license_key - Follow the money API key
	state - this argument will expect either the full state name or the postal abbreviation of the state being searched.
	year - this argument expects the election year being searched.
	office - this argument expects the office name, office code or a sub part of the office name.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		state_name - sort in alphabetical order by the name of state.
		state_postal_code - sort in alphabetical order by the postal abbreviation of the state.
		year - sort in order by election year..
		office - sort in alphabetical order by office name.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	state - the state you passed in your argument list
	year - the year you passed in your argument list
	office - the office you passed in your argument list
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	state_office - elements:
		state_postal_code - the two character postal code abbreviation for the state
		state_name - the full text name of the state
		year - the election year
		imsp_office_code - the office id number
		office - the office name
		total_recipients - the total number of recipients in this group
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('states.offices', 
                     args,
                     license_key,
                     required=[],
                     optional=['state', 'year', 'office', 'page', 'sort', 'state_name', 'state_postal_code', 'year', 'office', 'total_dollars'])

def states_offices_sectors(license_key=None, **args):
    """Corresponds to the "states.offices.sectors" command.

This method will summarize contributions at the sector level for an entire state and year. The data can also be broken down by office within each state and year if desired. Please see the base_level.industries.list.php method to obtain a full list of all sector categories along with a list of the industry and business categories under each sector.

Parameters:
	license_key - Follow the money API key
	state - this argument will expect either the full state name or the postal abbreviation of the state being searched.
	year - this argument expects the election year being searched.
	office - this argument expects the office name, office code or a sub part of the office name.
	office_breakdown - this arguments expects a value of either 0 or 1 and defaults to 0. 0: Do not summarize data by office; 1: Summarize data by office
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		state_name - sort in alphabetical order by the name of state.
		state_postal_code - sort in alphabetical order by the postal abbreviation of the state.
		year - sort in order by election year..
		office - sort in alphabetical order by office name.
		sector_name - sort in alphabetical order by each sector level category name.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	state - the state you passed from the argument list
	year - the year you passed from the argument list
	office - the office you passed from the argument list
	office_breakdown - the office breakdown code you passed from the argument list
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	state_offices_sector - elements:
		state_postal_code - the two character postal code abbreviation for the state
		state_name - the full text name of the state
		year - the election year
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('states.offices.sectors', 
                     args,
                     license_key,
                     required=[],
                     optional=['state', 'year', 'office', 'office_breakdown', 'page', 'sort', 'state_name', 'state_postal_code', 'year', 'office', 'sector_name', 'total_dollars'])

def states_top_contributors(license_key=None, **args):
    """Corresponds to the "states.top_contributors" command.

This method will return the top 100 contributors for a specific state and year. This list can be refined further to limit contributions to candidates, ballot measures or party pacs only along with limiting all contributors to a specific industry. Please see the base_level.industries.list.php method to obtain a full list of all industry categories and thier id numbers.

Parameters:
	license_key - Follow the money API key
	state - this is a required argument - this argument will expect either the full state name or the postal abbreviation of the state being searched.
	year - this is a required argument - this argument expects the election year being searched.
	imsp_industry_code - this argument expects a numerical value representing the industry you wish to limit your search too.
	contributor_type - this arguments expects a value of 0, 1, 2 or 3 and defaults to 0. 0: All Contributions; 1: Contributions to candidates only; 2: Contributions to party committees only; 3: Contributions to ballot committees only.


Results:
	state - the state you passed from the argument list
	year - the year you passed from the argument list
	imsp_industry_code - the industry level id numer you passed from the argument list
	industry_name - the name of the industry category selected
	contributor_type - the contributor type code passed from the argument list
	total_contribution_records - the total number of contribution records for this group
	total_dollars - the total of all contributions for this group
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	top_contributor - elements:
		contributor_name - the full name of the contributor
		business_name - the name of the business level category
		contribution_ranking - the ranking of this contributor in the returned list
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group
		percent_of_total_contribution_records - the percentage of this contributions contribution records against the total contribution records in this list
		percent_of_total_total_dollars - the percentage of this contributors total contributions against the total contributions in this list

"""

    return run_query('states.top_contributors', 
                     args,
                     license_key,
                     required=['state', 'year'],
                     optional=['imsp_industry_code', 'contributor_type'])

def candidates_businesses(license_key=None, **args):
    """Corresponds to the "candidates.businesses" command.

This method will summarize contributions at the business level for a specific candidate. Please see the base_level.industries.list.php method to obtain a full list of all business categories along with thier industry and sector grouping information. This method does require a valid imsp_candidate_id number as an argument. To find specific candidates and thier id numbers please see the candidates.list.php method.

Parameters:
	license_key - Follow the money API key
	imsp_candidate_id - this is a required argument - this argument expects a numerical value representing the candidate id number you wish to query.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		sector_name - sort in alphabetical order by each sector level category name.
		industry_name - sort in alphabetical order by each industry level category name.
		business_name - sort in alphabetical order by each business level category name.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	imsp_candidate_id - the id number of the candidate
	candidate_name - the name of the candidate
	state - the state this candidate is in
	year - the year this candidate is being voted on
	party - the party of the candidate
	office - the office of the candidate
	district - the district of the candidate
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	candidate_business - elements:
		business_name - the name of the business level category
		imsp_industry_code - the industry level category id number
		industry_name - the name of the industry level category
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('candidates.businesses', 
                     args,
                     license_key,
                     required=['imsp_candidate_id'],
                     optional=['page', 'sort', 'sector_name', 'industry_name', 'business_name', 'total_dollars'])

def candidates_contributions(license_key=None, **args):
    """Corresponds to the "candidates.contributions" command.

This method will display individual contribution recrods to a specific candidate. This method does require a valid imsp_candidate_id number as an argument. To find specific candidates and thier id numbers please see the candidates.list.php method.

Parameters:
	license_key - Follow the money API key
	imsp_candidate_id - this is a required argument - this argument expects a numerical value representing the candidate id number you wish to query.
	imsp_sector_code - this argument expects a numerical value representing the sector you wish to limit your search too. When using this argument you can not use the imsp_industry_code.
	imsp_industry_code - this argument expects a numerical value representing the industry you wish to limit your search too. When using this argument you can not use the imsp_sector_code.
	contributor_name - this argument expects the name, or part of the name, of a specific contributor you wish to search for. This arguments value will search for a match anywhere within the name, so only a sub portion of the name is required.
	contributor_city - this argument expect the name of the city you wish to limit the list of contributions too.
	contributor_zipcode - this argument expects the zip code you wish it limit the list of contributions too.
	contribution_date_range - this argument expects either one, or two dates seperated by a comma in the form of mm/dd/yyyy. If only one date is supplied only contributions from that date will be returned. If two dates are given all contributions between those two dates, inclusive, will be returned.
	contribution_amount_range - this argument expects either one, or two numbers seperated by a comma. If only one amount is given only contributions of that exact dollar amount will be returned. If two amounts are given all contributions between those two amounts, inclusive, will be returned.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		contributor_name - sort in alphabetical order by the contributor name.
		date - sort in chronological order by the date of the contribution.
		amount - sort in order of the contribution amount.
		contributor_employer - sort in alphabetical order by the employer of the contributor.
		contributor_occupation - sort in alphabetical order by the occuption of the contributor.
		contributor_city - sort in alphabetical order by the city of the contributor.
		contributor_state - sort in alphabetical order by the state of the contributor.
		contributor_zipcode - sort in numerical order by the the zip code of the contributor.
		sector_name - sort in alphabetical order by each sector level category name.
		industry_name - sort in alphabetical order by each industry level category name.
		business_name - sort in alphabetical order by each business level category name.


Results:
	imsp_candidate_id - the id number of the candidate
	imsp_sector_code - the sector code you passed from the argument list.
	sector_name - the category name of the sector you passed from the argument list.
	imsp_industry_code - the industry code you passed from the argument list.
	industry_name - the category name of the industry you passed from the argument list.
	contributor_name - the contributor name you passed from the argument list.
	contributor_city - the contributor city you passed from the argument list.
	contributor_zipcode - the contributor zip code you passed from the argument list.
	contribution_date_range - the contribution date or date range you passed from the argument list.
	contribution_amount_range - the contribution amount or amount range you passed from the argument list.
	candidate_name - the name of the candidate
	state - the state this candidate is in
	year - the year this candidate is being voted on
	party - the party of the candidate
	office - the office of the candidate
	district - the district of the candidate
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	contribution - elements:
		contributor_name - the full name of the contributor
		date - the date of the contribution
		amount - the amount of the contribution
		contributor_employer - the employee name of the contributor
		contributor_occupation - the occupation of the contributor
		contributor_city - the city of the contributor
		contributor_state - the state of the contributor
		contributor_zipcode - the zip code of the contributor
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		imsp_industry_code - the industry level category id number
		industry_name - the name of the industry level category
		business_name - the name of the business level category

"""

    return run_query('candidates.contributions', 
                     args,
                     license_key,
                     required=['imsp_candidate_id'],
                     optional=['imsp_sector_code', 'imsp_industry_code', 'contributor_name', 'contributor_city', 'contributor_zipcode', 'contribution_date_range', 'contribution_amount_range', 'page', 'sort', 'contributor_name', 'date', 'amount', 'contributor_employer', 'contributor_occupation', 'contributor_city', 'contributor_state', 'contributor_zipcode', 'sector_name', 'industry_name', 'business_name'])

def candidates_industries(license_key=None, **args):
    """Corresponds to the "candidates.industries" command.

This method will summarize contributions at the industry level for a specific candidate. Please see the base_level.industries.list.php method to obtain a full list of all industry categories along with thier sector grouping information and a list of the business categories under each industry. This method does require a valid imsp_candidate_id number as an argument. To find specific candidates and thier id numbers please see the candidates.list.php method.

Parameters:
	license_key - Follow the money API key
	imsp_candidate_id - this is a required argument - this argument expects a numerical value representing the candidate id number you wish to query.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		sector_name - sort in alphabetical order by each sector level category name.
		industry_name - sort in alphabetical order by each industry level category name.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	imsp_candidate_id - the id number of the candidate
	candidate_name - the name of the candidate
	state - the state this candidate is in
	year - the year this candidate is being voted on
	party - the party of the candidate
	office - the office of the candidate
	district - the district of the candidate
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	candidate_industry - elements:
		imsp_industry_code - the industry level category id number
		industry_name - the name of the industry level category
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('candidates.industries', 
                     args,
                     license_key,
                     required=['imsp_candidate_id'],
                     optional=['page', 'sort', 'sector_name', 'industry_name', 'total_dollars'])

def candidates_list(license_key=None, **args):
    """Corresponds to the "candidates.list" command.

This method will return a list of all candidates along with thier candidate id numbers. Along with the candidate name and id numbers are thier status and total contributions recieved among other information.

Parameters:
	license_key - Follow the money API key
	state - this argument will expect either the full state name or the postal abbreviation of the state the candidate is in.
	year - this argument expects the year the candidate is being voting on.
	office - this argument expects the office name, office code or a sub part of the office name.
	district - this argument expects a district name or number.
	party - this argument expects the party name, or a sub part of the party name.
	candidate_status - this argument expects the values WON, LOST or OTHER
	candidate_name - this argument expects the candidate name or a sub part of the candidate name.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		state_name - sort in alphabetical order by the name of state.
		state_postal_code - sort in alphabetical order by the postal abbreviation of the state.
		year - sort in order by election year..
		office - sort in alphabetical order by office name.
		district - sort in alphabetical order by the district name.
		candidate_status - sort in alphabetical order by the status of the candidate.
		candidate_name - sort in alphabetical order by the name of the candidate..
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	state - the state you passed from the argument list
	year - the year you passed from the argument list
	office - the office you passed from the argument list
	district - the district you passed from the argument list
	party - the party you passed from the argument list
	candidate_status - the status of the candidate you passed from the argument list
	candidate_name - the name of the candidate you passed from the argument list
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	- Record Level Tag - candidate - elements:imsp_candidate_id - the candidate id number
	state_postal_code - the two character postal code abbreviation for the state
	state_name - the full text name of the state
	year - the election year
	candidate_name - the full name of the candidate
	candidate_status - the election status of the candidate
	party - the party of the candidate
	office - the office the candidate campaigned for
	district - the district the candidate campaigned for
	total_contribution_records - the total number of contribution records for this candidate
	total_dollars - the total of all the contributions for this candidate

"""

    return run_query('candidates.list', 
                     args,
                     license_key,
                     required=[],
                     optional=['state', 'year', 'office', 'district', 'party', 'candidate_status', 'candidate_name', 'page', 'sort', 'state_name', 'state_postal_code', 'year', 'office', 'district', 'candidate_status', 'candidate_name', 'total_dollars'])

def candidates_sectors(license_key=None, **args):
    """Corresponds to the "candidates.sectors" command.

This method will summarize contributions at the sector level for a specific candidate. Please see the base_level.industries.list.php method to obtain a full list of all sector categories along with a list of the industry and business categories under each sector. This method does require a valid imsp_candidate_id number as an argument. To find specific candidates and thier id numbers please see the candidates.list.php method.

Parameters:
	license_key - Follow the money API key
	imsp_candidate_id - this is a required argument - this argument expects a numerical value representing the candidate id number you wish to query.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		sector_name - sort in alphabetical order by each sector level category name.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	imsp_candidate_id - the id number of the candidate
	candidate_name - the name of the candidate
	state - the state this candidate is in
	year - the year this candidate is being voted on
	party - the party of the candidate
	office - the office of the candidate
	district - the district of the candidate
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	candidate_sector - elements:
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('candidates.sectors', 
                     args,
                     license_key,
                     required=['imsp_candidate_id'],
                     optional=['page', 'sort', 'sector_name', 'total_dollars'])

def candidates_top_contributors(license_key=None, **args):
    """Corresponds to the "candidates.top_contributors" command.

This method will return a list of the top contributors for a specific candidate. This method does require a valid imsp_candidate_id number as an argument. To find specific candidates and thier id numbers please see the candidates.list.php method.

Parameters:
	license_key - Follow the money API key
	imsp_candidate_id - this is a required argument - this argument expects a numerical value representing the candidate id number you wish to query.
	imsp_industry_code - this argument expects a numerical value representing the industry you wish to limit your search too.


Results:
	imsp_candidate_id - the id number of the candidate
	imsp_industry_code - the industry level id numer you passed from the argument list
	industry_name - the name of the industry category selected
	candidate_name - the name of the candidate
	state - the state this candidate is in
	year - the year this candidate is being voted on
	party - the party of the candidate
	office - the office of the candidate
	district - the district of the candidate
	total_contribution_records - the total number of contribution records for this group
	total_dollars - the total of all contributions for this group
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	top_contributor - elements:
		contributor_name - the full name of the contributor
		business_name - the name of the business level category
		contribution_ranking - the ranking of this contributor in the returned list
		total_contribution_records - the total number of contribution records for this contributor
		total_dollars - the total of all the contributions for this contributor
		percent_of_total_contribution_records - the percentage of this contributions contribution records against the total contribution records in this list
		percent_of_total_total_dollars - the percentage of this contributors total contributions against the total contributions in this list

"""

    return run_query('candidates.top_contributors', 
                     args,
                     license_key,
                     required=['imsp_candidate_id'],
                     optional=['imsp_industry_code'])

def party_pacs_committees_businesses(license_key=None, **args):
    """Corresponds to the "party_pacs.committees.businesses" command.

This method will summarize contributions at the business level for a specific party pac committee. Please see the base_level.industries.list.php method to obtain a full list of all business categories along with thier industry and sector grouping information. This method does require a valid imsp_committee_id number as an argument. To find specific committees and thier id numbers please see the party_pacs.committees.php method.

Parameters:
	license_key - Follow the money API key
	imsp_committee_id - this is a required argument - this argument expects a numerical value representing the party pac committee id number you wish to query.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		sector_name - sort in alphabetical order by each sector level category name.
		industry_name - sort in alphabetical order by each industry level category name.
		business_name - sort in alphabetical order by each business level category name.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	imsp_committe_id - the id number of the party pac committee
	committee_name - the name of that party pac committee
	state - the state this party pac committee is in
	year - the year this party pac committee is in
	party - the party of the party pac committee
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	committee_business - elements:
		business_name - the name of the business level category
		imsp_industry_code - the industry level category id number
		industry_name - the name of the industry level category
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('party_pacs.committees.businesses', 
                     args,
                     license_key,
                     required=['imsp_committee_id'],
                     optional=['page', 'sort', 'sector_name', 'industry_name', 'business_name', 'total_dollars'])

def party_pacs_committees_contributions(license_key=None, **args):
    """Corresponds to the "party_pacs.committees.contributions" command.

This method will display individual contribution recrods to a specific party pac committee. This method does require a valid imsp_committee_id number as an argument. To find specific committees and thier id numbers please see the party_pacs.committees.php method.

Parameters:
	license_key - Follow the money API key
	imsp_committee_id - this is a required argument - this argument expects a numerical value representing the party pac committee id number you wish to query.
	imsp_sector_code - this argument expects a numerical value representing the sector you wish to limit your search too. When using this argument you can not use the imsp_industry_code.
	imsp_industry_code - this argument expects a numerical value representing the industry you wish to limit your search too. When using this argument you can not use the imsp_sector_code.
	contributor_name - this argument expects the name, or part of the name, of a specific contributor you wish to search for. This arguments value will search for a match anywhere within the name, so only a sub portion of the name is required.
	contributor_city - this argument expect the name of the city you wish to limit the list of contributions too.
	contributor_zipcode - this argument expects the zip code you wish it limit the list of contributions too.
	contribution_date_range - this argument expects either one, or two dates seperated by a comma in the form of mm/dd/yyyy. If only one date is supplied only contributions from that date will be returned. If two dates are given all contributions between those two dates, inclusive, will be returned.
	contribution_amount_range - this argument expects either one, or two numbers seperated by a comma. If only one amount is given only contributions of that exact dollar amount will be returned. If two amounts are given all contributions between those two amounts, inclusive, will be returned.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		contributor_name - sort in alphabetical order by the contributor name.
		date - sort in chronological order by the date of the contribution.
		amount - sort in order of the contribution amount.
		contributor_employer - sort in alphabetical order by the employer of the contributor.
		contributor_occupation - sort in alphabetical order by the occuption of the contributor.
		contributor_city - sort in alphabetical order by the city of the contributor.
		contributor_state - sort in alphabetical order by the state of the contributor.
		contributor_zipcode - sort in numerical order by the the zip code of the contributor.
		sector_name - sort in alphabetical order by each sector level category name.
		industry_name - sort in alphabetical order by each industry level category name.
		business_name - sort in alphabetical order by each business level category name.


Results:
	imsp_committe_id - the id number of the party pac committee
	imsp_sector_code - the sector code you passed from the argument list.
	sector_name - the category name of the sector you passed from the argument list.
	imsp_industry_code - the industry code you passed from the argument list.
	industry_name - the category name of the industry you passed from the argument list.
	contributor_name - the contributor name you passed from the argument list.
	contributor_city - the contributor city you passed from the argument list.
	contributor_zipcode - the contributor zip code you passed from the argument list.
	contribution_date_range - the contribution date or date range you passed from the argument list.
	contribution_amount_range - the contribution amount or amount range you passed from the argument list.
	committee_name - the name of the party pac committee
	state - the state this ballot measure is in
	year - the year this ballot measure is being voted on
	party - the party of the party pac committee
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	contribution - elements:
		contributor_name - the full name of the contributor
		date - the date of the contribution
		amount - the amount of the contribution
		contributor_employer - the employee name of the contributor
		contributor_occupation - the occupation of the contributor
		contributor_city - the city of the contributor
		contributor_state - the state of the contributor
		contributor_zipcode - the zip code of the contributor
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		imsp_industry_code - the industry level category id number
		industry_name - the name of the industry level category
		business_name - the name of the business level category

"""

    return run_query('party_pacs.committees.contributions', 
                     args,
                     license_key,
                     required=['imsp_committee_id'],
                     optional=['imsp_sector_code', 'imsp_industry_code', 'contributor_name', 'contributor_city', 'contributor_zipcode', 'contribution_date_range', 'contribution_amount_range', 'page', 'sort', 'contributor_name', 'date', 'amount', 'contributor_employer', 'contributor_occupation', 'contributor_city', 'contributor_state', 'contributor_zipcode', 'sector_name', 'industry_name', 'business_name'])

def party_pacs_committees_industries(license_key=None, **args):
    """Corresponds to the "party_pacs.committees.industries" command.

This method will summarize contributions at the industry level for a specific party pac committee. Please see the base_level.industries.list.php method to obtain a full list of all industry categories along with thier sector grouping information and a list of the business categories under each industry. This method does require a valid imsp_committee_id number as an argument. To find specific committees and thier id numbers please see the party_pacs.committees.php method.

Parameters:
	license_key - Follow the money API key
	imsp_committee_id - this is a required argument - this argument expects a numerical value representing the party pac committee id number you wish to query.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		sector_name - sort in alphabetical order by each sector level category name.
		industry_name - sort in alphabetical order by each industry level category name.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	imsp_committe_id - the id number of the party pac committee
	committee_name - the name of that party pac committee
	state - the state this party pac committee is in
	year - the year this party pac committee is in
	party - the party of the party pac committee
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	committee_industry - elements:
		imsp_industry_code - the industry level category id number
		industry_name - the name of the industry level category
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('party_pacs.committees.industries', 
                     args,
                     license_key,
                     required=['imsp_committee_id'],
                     optional=['page', 'sort', 'sector_name', 'industry_name', 'total_dollars'])

def party_pacs_committees(license_key=None, **args):
    """Corresponds to the "party_pacs.committees" command.

This method will return a list of all party pac committees along with thier committee id numbers. Along with the committee name and id numbers are it's party and total contributions recieved among other information.

Parameters:
	license_key - Follow the money API key
	state - this argument will expect either the full state name or the postal abbreviation of the state the party pac committee is in.
	year - this argument expects the election year you wish to search.
	party - this argument expects the party name, or a sub part of the party name.
	commitee_name - this argument expects the name, or a sub portion of the name, of the party pac committee.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		state_name - sort in alphabetical order by the name of state.
		state_postal_code - sort in alphabetical order by the postal abbreviation of the state.
		year - sort in order by election year..
		party - sort in alphabetical order by party.
		committee_name - sort in alphabetical order by the name of the party pac committee.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	state - the state you passed from the argument list
	year - the year you passed from the argument list
	party - the party you passed from the argument list
	committee_name - the name of that party pac committee you passed from the argument list
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	committee - elements:
		imsp_committee_id - the party pac committee id number
		state_postal_code - the two character postal code abbreviation for the state
		state_name - the full text name of the state
		year - the election year
		committee_name - the full name of the party pac committee
		party - the party of the party pac committee
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('party_pacs.committees', 
                     args,
                     license_key,
                     required=[],
                     optional=['state', 'year', 'party', 'commitee_name', 'page', 'sort', 'state_name', 'state_postal_code', 'year', 'party', 'committee_name', 'total_dollars'])

def party_pacs_committees_sectors(license_key=None, **args):
    """Corresponds to the "party_pacs.committees.sectors" command.

This method will summarize contributions at the sector level for a specific party pac committee. Please see the base_level.industries.list.php method to obtain a full list of all sector categories along with a list of the industry and business categories under each sector. This method does require a valid imsp_committee_id number as an argument. To find specific committees and thier id numbers please see the party_pacs.committees.php method.

Parameters:
	license_key - Follow the money API key
	imsp_committee_id - this is a required argument - this argument expects a numerical value representing the party pac committee id number you wish to query.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		sector_name - sort in alphabetical order by each sector level category name.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	imsp_committee_id - the id number of the party pac committee
	committee_name - the name of that party pac committee
	state - the state this party pac committee is in
	year - the year this party pac committee is in
	party - the party of the party pac committee
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	committee_sector - elements:
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('party_pacs.committees.sectors', 
                     args,
                     license_key,
                     required=['imsp_committee_id'],
                     optional=['page', 'sort', 'sector_name', 'total_dollars'])

def party_pacs_committees_top_contributors(license_key=None, **args):
    """Corresponds to the "party_pacs.committees.top_contributors" command.

This method will return a list of the top contributors for a specific party pac committee. This method does require a valid imsp_committee_id number as an argument. To find specific committees and thier id numbers please see the party_pacs.committees.php method.

Parameters:
	license_key - Follow the money API key
	imsp_committee_id - this is a required argument - this argument expects a numerical value representing the party pac committee id number you wish to query.


Results:
	imsp_committee_id - the party pac committee id number you passed from the argument list
	imsp_industry_code - the industry level id numer you passed from the argument list
	industry_name - the name of the industry category selected
	committee_name - the name of that party pac committee
	state - the state this ballot measure is in
	year - the year this ballot measure is being voted on
	party - the party of the party pac committee
	total_contribution_records - the total number of contribution records for this group
	total_dollars - the total of all contributions for this group
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	top_contributor - elements:
		contributor_name - the full name of the contributor
		business_name - the name of the business level category
		contribution_ranking - the ranking of this contributor in the returned list
		total_contribution_records - the total number of contribution records for this contributor
		total_dollars - the total of all the contributions for this contributor
		percent_of_total_contribution_records - the percentage of this contributions contribution records against the total contribution records in this list
		percent_of_total_total_dollars - the percentage of this contributors total contributions against the total contributions in this list

"""

    return run_query('party_pacs.committees.top_contributors', 
                     args,
                     license_key,
                     required=['imsp_committee_id'],
                     optional=[])

def ballot_measures_committees_businesses(license_key=None, **args):
    """Corresponds to the "ballot_measures.committees.businesses" command.

This method will summarize contributions at the business level for a specific ballot committee. Please see the base_level.industries.list.php method to obtain a full list of all business categories along with thier industry and sector grouping information. This method does require a valid imsp_committee_id number as an argument. To find specific committees and thier id numbers please see the ballot_measures.committees.php method.

Parameters:
	license_key - Follow the money API key
	imsp_committee_id - this is a required argument - this argument expects a numerical value representing the ballot measure committee id number you wish to query.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		sector_name - sort in alphabetical order by each sector level category name.
		industry_name - sort in alphabetical order by each industry level category name.
		business_name - sort in alphabetical order by each business level category name.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	imsp_committe_id - the id number of the ballot measure committee
	committee_name - the name of that ballot measure committee
	state - the state this ballot measure is in
	year - the year this ballot measure is being voted on
	ballot_measure_name - the name of the ballot measure
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	committee_business - elements:
		business_name - the name of the business level category
		imsp_industry_code - the industry level category id number
		industry_name - the name of the industry level category
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('ballot_measures.committees.businesses', 
                     args,
                     license_key,
                     required=['imsp_committee_id'],
                     optional=['page', 'sort', 'sector_name', 'industry_name', 'business_name', 'total_dollars'])

def ballot_measures_committees_contributions(license_key=None, **args):
    """Corresponds to the "ballot_measures.committees.contributions" command.

This method will display individual contribution recrods to a specific ballot committee. This method does require a valid imsp_committee_id number as an argument. To find specific committees and thier id numbers please see the ballot_measures.committees.php method.

Parameters:
	license_key - Follow the money API key
	imsp_committee_id - this is a required argument - this argument expects a numerical value representing the ballot measure committee id number you wish to query.
	imsp_sector_code - this argument expects a numerical value representing the sector you wish to limit your search too. When using this argument you can not use the imsp_industry_code.
	imsp_industry_code - this argument expects a numerical value representing the industry you wish to limit your search too. When using this argument you can not use the imsp_sector_code.
	contributor_name - this argument expects the name, or part of the name, of a specific contributor you wish to search for.
	contributor_city - this argument expect the name of the city you wish to limit the list of contributions too.
	contributor_zipcode - this argument expects the zip code you wish it limit the list of contributions too.
	contribution_date_range - this argument expects either one, or two dates seperated by a comma in the form of mm/dd/yyyy. If only one date is supplied only contributions from that date will be returned. If two dates are given all contributions between those two dates, inclusive, will be returned.
	contribution_amount_range - this argument expects either one, or two numbers seperated by a comma. If only one amount is given only contributions of that exact dollar amount will be returned. If two amounts are given all contributions between those two amounts, inclusive, will be returned.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		contributor_name - sort in alphabetical order by the contributor name.
		date - sort in chronological order by the date of the contribution.
		amount - sort in order of the contribution amount.
		contributor_employer - sort in alphabetical order by the employer of the contributor.
		contributor_occupation - sort in alphabetical order by the occuption of the contributor.
		contributor_city - sort in alphabetical order by the city of the contributor.
		contributor_state - sort in alphabetical order by the state of the contributor.
		contributor_zipcode - sort in numerical order by the the zip code of the contributor.
		sector_name - sort in alphabetical order by each sector level category name.
		industry_name - sort in alphabetical order by each industry level category name.
		business_name - sort in alphabetical order by each business level category name.


Results:
	imsp_committe_id - the id number of the ballot measure committee
	imsp_sector_code - the sector code you passed from the argument list.
	sector_name - the category name of the sector you passed from the argument list.
	imsp_industry_code - the industry code you passed from the argument list.
	industry_name - the category name of the industry you passed from the argument list.
	contributor_name - the contributor name you passed from the argument list.
	contributor_city - the contributor city you passed from the argument list.
	contributor_zipcode - the contributor zip code you passed from the argument list.
	contribution_date_range - the contribution date or date range you passed from the argument list.
	contribution_amount_range - the contribution amount or amount range you passed from the argument list.
	committee_name - the name of the ballot measure committee
	state - the state this ballot measure is in
	year - the year this ballot measure is being voted on
	ballot_measure_name - the name of the ballot measure
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	contribution - elements:
		contributor_name - the full name of the contributor
		date - the date of the contribution
		amount - the amount of the contribution
		contributor_employer - the employee name of the contributor
		contributor_occupation - the occupation of the contributor
		contributor_city - the city of the contributor
		contributor_state - the state of the contributor
		contributor_zipcode - the zip code of the contributor
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		imsp_industry_code - the industry level category id number
		industry_name - the name of the industry level category
		business_name - the name of the business level category

"""

    return run_query('ballot_measures.committees.contributions', 
                     args,
                     license_key,
                     required=['imsp_committee_id'],
                     optional=['imsp_sector_code', 'imsp_industry_code', 'contributor_name', 'contributor_city', 'contributor_zipcode', 'contribution_date_range', 'contribution_amount_range', 'page', 'sort', 'contributor_name', 'date', 'amount', 'contributor_employer', 'contributor_occupation', 'contributor_city', 'contributor_state', 'contributor_zipcode', 'sector_name', 'industry_name', 'business_name'])

def ballot_measures_committees_industries(license_key=None, **args):
    """Corresponds to the "ballot_measures.committees.industries" command.

This method will summarize contributions at the industry level for a specific ballot committee. Please see the base_level.industries.list.php method to obtain a full list of all industry categories along with thier sector grouping information and a list of the business categories under each industry. This method does require a valid imsp_committee_id number as an argument. To find specific committees and thier id numbers please see the ballot_measures.committees.php method.

Parameters:
	license_key - Follow the money API key
	imsp_committee_id - this is a required argument - this argument expects a numerical value representing the ballot measure committee id number you wish to query.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		sector_name - sort in alphabetical order by each sector level category name.
		industry_name - sort in alphabetical order by each industry level category name.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	imsp_committe_id - the id number of the ballot measure committee
	committee_name - the name of that ballot measure committee
	state - the state this ballot measure is in
	year - the year this ballot measure is being voted on
	ballot_measure_name - the name of the ballot measure
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	committee_industry - elements:
		imsp_industry_code - the industry level category id number
		industry_name - the name of the industry level category
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('ballot_measures.committees.industries', 
                     args,
                     license_key,
                     required=['imsp_committee_id'],
                     optional=['page', 'sort', 'sector_name', 'industry_name', 'total_dollars'])

def ballot_measures_committees(license_key=None, **args):
    """Corresponds to the "ballot_measures.committees" command.

This method will return a list of all ballot measure committees along with thier committee id numbers. Along with the committee name and id numbers are it's status, position and total contributions recieved among other information.

Parameters:
	license_key - Follow the money API key
	state - this argument will expect either the full state name or the postal abbreviation of the state the ballot measure committee is in.
	year - this argument expects the year the ballot measure committe is being voting on.
	commitee_name - this argument expects the name, or a sub portion of the name, of the ballot measure committee.
	imsp_ballot_measure_id - this argument expects the id number of a valid ballot measure.
	ballot_measure_name - this argument expects the name, or a sub portion of the name, of a valid ballot measure.
	ballot_measure_status - this argument expects a status value PASSED, FAILED, PENDING or OTHER.
	position - this argument expects a value of PRO or CON and represents the position the ballot measure committee stands in relationship to the ballot measure.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		state_name - sort in alphabetical order by the name of state.
		state_postal_code - sort in alphabetical order by the postal abbreviation of the state.
		year - sort in order by election year.
		committee_name - sort in alphabetical order by the name of the ballot measure committee.
		imsp_ballot_measure_id - sort in numerical order by the id number of the ballot measure.
		ballot_measure_name - sort in alphabetical order by the name of the ballot measure.
		candidate_status - sort in alphabetical order by the status of the candidate.
		position - sort in alphabetical order by the position of the ballot measure committee.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	state - the state you passed from the argument list
	year - the year you passed from the argument list
	committee_name - the name of that ballot measure committee you passed from the argument list
	imsp_ballot_measure_id - the id number of the ballot measure you passed from the argument list
	ballot_measure_name - the name of the ballot measure you passed from your argument list
	ballot_measure_status - the status of the ballot measure you passed from your argument list
	position - the position of for ballot measure committee you passed from your argument list
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	ballot_measure_committee - elements:
		imsp_committee_id - the ballot measure committee id number
		state_postal_code - the two character postal code abbreviation for the state
		state_name - the full text name of the state
		year - the election year
		committee_name - the full name of the ballot measure committee
		imsp_ballot_measure_id - the ballot measure id number
		ballot_measure_name - the full name of the ballot measure
		ballot_measure_status - the status of the ballot measure
		position - the position of the ballot measure committee
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('ballot_measures.committees', 
                     args,
                     license_key,
                     required=[],
                     optional=['state', 'year', 'commitee_name', 'imsp_ballot_measure_id', 'ballot_measure_name', 'ballot_measure_status', 'position', 'page', 'sort', 'state_name', 'state_postal_code', 'year', 'committee_name', 'imsp_ballot_measure_id', 'ballot_measure_name', 'candidate_status', 'position', 'total_dollars'])

def ballot_measures_committees_sectors(license_key=None, **args):
    """Corresponds to the "ballot_measures.committees.sectors" command.

This method will summarize contributions at the sector level for a specific ballot committee. Please see the base_level.industries.list.php method to obtain a full list of all sector categories along with a list of the industry and business categories under each sector. This method does require a valid imsp_committee_id number as an argument. To find specific committees and thier id numbers please see the ballot_measures.committees.php method.

Parameters:
	license_key - Follow the money API key
	imsp_committee_id - this is a required argument - this argument expects a numerical value representing the ballot measure committee id number you wish to query.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		sector_name - sort in alphabetical order by each sector level category name.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	imsp_committe_id - the id number of the ballot measure committee
	committee_name - the name of that ballot measure committee
	state - the state this ballot measure is in
	year - the year this ballot measure is being voted on
	ballot_measure_name - the name of the ballot measure
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	committee_sector - elements:
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('ballot_measures.committees.sectors', 
                     args,
                     license_key,
                     required=['imsp_committee_id'],
                     optional=['page', 'sort', 'sector_name', 'total_dollars'])

def ballot_measures_committees_top_contributors(license_key=None, **args):
    """Corresponds to the "ballot_measures.committees.top_contributors" command.

This method will return a list of the top contributors for a specific ballot committee. This method does require a valid imsp_committee_id number as an argument. To find specific committees and thier id numbers please see the ballot_measures.committees.php method.

Parameters:
	license_key - Follow the money API key
	imsp_committee_id - this is a required argument - this argument expects a numerical value representing the ballot measure committee id number you wish to query.
	imsp_industry_code - this argument expects a numerical value representing the industry you wish to limit your search too.


Results:
	imsp_committee_id - the ballot measure committee id number you passed from the argument list
	imsp_industry_code - the industry level id numer you passed from the argument list
	industry_name - the name of the industry category selected
	committee_name - the name of that ballot measure committee
	state - the state this ballot measure is in
	year - the year this ballot measure is being voted on
	ballot_measure_name - the name of the ballot measure
	total_contribution_records - the total number of contribution records for this group
	total_dollars - the total of all contributions for this group
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	top_contributor - elements:
		contributor_name - the full name of the contributor
		business_name - the name of the business level category
		contribution_ranking - the ranking of this contributor in the returned list
		total_contribution_records - the total number of contribution records for this contributor
		total_dollars - the total of all the contributions for this contributor
		percent_of_total_contribution_records - the percentage of this contributions contribution records against the total contribution records in this list
		percent_of_total_total_dollars - the percentage of this contributors total contributions against the total contributions in this list

"""

    return run_query('ballot_measures.committees.top_contributors', 
                     args,
                     license_key,
                     required=['imsp_committee_id'],
                     optional=['imsp_industry_code'])

def ballot_measures_list(license_key=None, **args):
    """Corresponds to the "ballot_measures.list" command.

This method will return a list of ballot measures we are collecting contribution records for. This list will return, among other information, the name of the ballot measure it's status and the total contribution dollars it has recieved. You may detail those records out further by using some of the other ballot_measures methods for digging down deeper into the contributions.

Parameters:
	license_key - Follow the money API key
	state - this argument will expect either the full state name or the postal abbreviation of the state the ballot measure committee is in.
	year - this argument expects the year the ballot measure committee is being voting on.
	ballot_measure_name - this argument expects the name, or a sub portion of the name, of a valid ballot measure.
	ballot_measure_status - this argument expects a status value PASSED, FAILED, PENDING or OTHER.
	description - this argument expects a sub part of the full description of a ballot measure.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		state_name - sort in alphabetical order by the name of state.
		state_postal_code - sort in alphabetical order by the postal abbreviation of the state.
		year - sort in order by election year..
		ballot_measure_name - sort in alphabetical order by the name of the ballot measure.
		ballot_measure_status - sort in alphabetical order by the status of the ballot measure.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	state - the state you passed from the argument list
	year - the year you passed from the argument list
	ballot_measure_name - the ballot measure name you passed from the argument list
	ballot_measure_status - the ballot measure status you passed from the argument list
	description - the description of the ballot measure you passed from the argument list
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	ballot_measure - elements:
		imsp_ballot_measure_id - the ballot measure id number
		state_postal_code - the two character postal code abbreviation for the state
		state_name - the full text name of the state
		year - the election year
		ballot_measure_name - the full name of the ballot measure
		ballot_measure_status - the status of the ballot measure
		short_description - the short description of this ballot measure
		long_description - the longer, full description, of this ballot measure
		total_pro_contribution_records - the total number of contributions from ballot measure committees that are in favor of this ballot measure
		total_pro_dollars - the total of all contributions from ballot measure committees that are in favor of this ballot measure
		total_con_contribution_records - the total number of contributions from ballot measure committees that are against this ballot measure
		total_con_dollars - the total of all contributions from ballot measure committees that are against this ballot measure
		total_contribution_records - the total number of contribution records for this ballot measure
		total_dollars - the total of all the contributions for this ballot measure

"""

    return run_query('ballot_measures.list', 
                     args,
                     license_key,
                     required=[],
                     optional=['state', 'year', 'ballot_measure_name', 'ballot_measure_status', 'description', 'page', 'sort', 'state_name', 'state_postal_code', 'year', 'ballot_measure_name', 'ballot_measure_status', 'total_dollars'])

def contributers_name_search(license_key=None, **args):
    """Corresponds to the "contributors.name_search" command.

This method will return a list of all contributor names that match the name you are searching for. You can search for an exact name match, last name or even a sounds like method. Any matched contributors will be returned along with thier sector/industry information and total contributions.

Parameters:
	license_key - Follow the money API key
	contributor_name - this is a required argument - this argument expects the name, or part of the name, of a specific contributor you wish to search for.
	contributor_city - this argument expects the name of the city you wish to limit the search to.
	contributor_state - this argument expects the name of the state that the contributor is in that you wish to limit the search to.
	contributor_zipcode - this argument expects the zip code you wish it limit the search to.
	imsp_sector_code - this argument expects a numerical value representing the sector you wish to limit your search to. When using this argument you can not use the imsp_industry_code.
	imsp_industry_code - this argument expects a numerical value representing the industry you wish to limit your search to. When using this argument you can not use the imsp_sector_code.
	election_state - this argument will expect either the full state name or the postal abbreviation of the state the election is in that is being searched.
	election_year - this argument expects the election year being searched.
	search_type - this argument expects a value of 0, 1 or 2 and defaults to 0. It determines the type of search being done on the contributor name. 0: Do an exact name search; 1: Do a last name search only, or a contributor name starts with search; 2: Do a contributor name sounds like search.
	page - this argument expects a numerical value representing the current page of data to return. The first page, and default value, is 0.
	sort - this argument will expect a list, or single value, of how you wish to have the returned data sorted. The following are valid sort arguments for this method:
		contributor_name - sort in alphabetical order by the contributor name.
		contributor_city - sort in alphabetical order by the city of the contributor.
		contributor_state - sort in alphabetical order by the state of the contributor.
		contributor_zipcode - sort in numerical order by the the zip code of the contributor.
		occupation - sort in alphabetical order by the occuption of the contributor.
		employer - sort in alphabetical order by the employer of the contributor.
		sector_name - sort in alphabetical order by each sector level category name.
		industry_name - sort in alphabetical order by each industry level category name.
		business_name - sort in alphabetical order by each business level category name.
		election_state - sort in alphabetical order by the state of the election.
		year - sort in alphabetical order by the year of the election.
		total_dollars - sort in descending order by the total dollars in each returned record.


Results:
	contributor_name - the contributor name you passed from the argument list.
	contributor_state - the contributor state you passed from the argument list.
	election_state - the election state you passed from the argument list.
	year - the election year you passed from the argument list.
	search_type - the search type value you passed from the argument list.
	sort - the sort arguments you sent, if any
	page - the page you requested
	next_page - tells you if there is another page of data. yes or no
	record_count - the total number of records that were returned
	origin - the source of the data
	process_timestamp - the date and time you ran this query
	update_timestamp - the date and time of the last update to the database
	contributor - elements:
		imsp_contributor_code - the contributor id number, this number is not always static from one update to the next
		contributor_name - the full name of the contributor
		contributor_city - the city of the contributor
		contributor_state - the state of the contributor
		contributor_zipcode - the zip code of the contributor
		occupation - the occupation of the contributor
		employer - the employee name of the contributor
		imsp_sector_code - the sector level category id number
		sector_name - the name of the sector level category
		imsp_industry_code - the industry level category id number
		industry_name - the name of the industry level category
		business_name - the name of the business level category
		election_state - the two character postal code abbreviation of the election state
		year - the election year
		total_contribution_records - the total number of contribution records for this group
		total_dollars - the total of all the contributions for this group

"""

    return run_query('contributors.name_search', 
                     args,
                     license_key,
                     required=['contributor_name'],
                     optional=['contributor_city', 'contributor_state', 'contributor_zipcode', 'imsp_sector_code', 'imsp_industry_code', 'election_state', 'election_year', 'search_type', 'page', 'sort', 'contributor_name', 'contributor_city', 'contributor_state', 'contributor_zipcode', 'occupation', 'employer', 'sector_name', 'industry_name', 'business_name', 'election_state', 'year', 'total_dollars'])
