Overview

Packages

  • LegiScan
    • API
    • Cache
    • Common
    • Exceptions
    • Utility
  • PHP

Classes

  • LegiScan_Bulk
  • LegiScan_Process
  • LegiScan_Pull
  • LegiScan_Push
  • Overview
  • Package
  • Class

Class LegiScan_Pull

LegiScan API Pull Class

Basic pull class to generate API requests and decode responses. Doing something interesting with the results is the job of LegiScan_Process. Each get*() function maps to the corresponding API operation, preparing the request array and processing through LegiScan_Pull::apiRequest().

Package: LegiScan\API
Copyright: 2010-2020 LegiScan LLC
License: https://opensource.org/licenses/BSD-2-Clause
Author: LegiScan API Team api@legiscan.com
See: LegiScan_CommandLine
See: LegiScan_Process
See: LegiScan_Worker
Link: https://api.legiscan.com/dl/
Link: https://legiscan.com/legiscan
Located at LegiScan.php
Methods summary
public
# __construct( string $api_key,… )

Class constructor that nominally validates the API key

Class constructor that nominally validates the API key

Parameters

$api_key,…
(OPTIONAL) Override the api_key from LegiScan::getConfig()

Throws

APIException
public array
# getSessionList( string $state )

Get a session list for a specified state

Get a session list for a specified state

Parameters

$state
State to pull the session list for

Returns

array
The list of state sessions and their corresponding session_id numbers
public array
# getMasterList( integer $session_id )

Get a master list of bills for a specific session_id

Get a master list of bills for a specific session_id

Parameters

$session_id
LegiScan session_id to pull the master list for

Returns

array
The master list of current bills with their corresponding bill_id numbers
public array
# getMasterListRaw( integer $session_id )

Get a master list of bills for a specific session_id optimized for change_hash detection

Get a master list of bills for a specific session_id optimized for change_hash detection

Parameters

$session_id
LegiScan session_id to pull the master list for

Returns

array
The master list of current bills with their corresponding bill_id numbers
public array
# getBill( integer $bill_id )

Get the bill detail record for a specified bill

Get the bill detail record for a specified bill

Parameters

$bill_id
The internal bill id for the requested bill

Returns

array
The record containing a summary of the bill detail information
public array
# getBillText( integer $text_id )

Get a copy of the bill text for the specified document id

Get a copy of the bill text for the specified document id

(Note: doc is base64 encoded)

Parameters

$text_id
The internal bill id for the requested bill text

Returns

array
The bill text record with the actual text and meta type information
public array
# getAmendment( integer $amendment_id )

Get a copy of the bill amendment for the specified amendment id

Get a copy of the bill amendment for the specified amendment id

(Note: doc is base64 encoded)

Parameters

$amendment_id
The internal amendment id for the requested bill amendment

Returns

array
The bill amendment record with the actual amendment and meta type information
public array
# getSupplement( integer $supplement_id )

Get a copy of the bill supplement for the specified supplement id

Get a copy of the bill supplement for the specified supplement id

(Note: doc is base64 encoded)

Parameters

$supplement_id
The internal supplement id for the requested bill supplement

Returns

array
The bill supplement record with the actual supplement and meta type information
public array
# getRollCall( integer $roll_call_id )

Get the roll call record for a specified bill with vote summary and individual legislator vote information

Get the roll call record for a specified bill with vote summary and individual legislator vote information

Parameters

$roll_call_id
The internal LegiScan roll_call_id for the requested vote

Returns

array
A detailed roll call record with individual vote data
public array
# getPerson( integer $people_id )

Get a basic people record for the specified id

Get a basic people record for the specified id

Parameters

$people_id
The internal LegiScan people_id to be retrieved LegiScan_Pull::apiRequest()

Returns

array
The basic sponsor information for the given people_id
public array
# getSearch( array $search )

Performs a search against the LegiScan national legislative database

Performs a search against the LegiScan national legislative database

Parameters

$search

An associative array with the search parameters: state, bill, query, year

Returns

array
A page of search results for the given query parameters

Throws

APIException
public array
# getSearchRaw( array $search )

Performs a raw search against the LegiScan national legislative database

Performs a raw search against the LegiScan national legislative database

Parameters

$search

An associative array with the search parameters: state, bill, query, year

Returns

array
A page of search results for the given query parameters

Throws

APIException
public array
# getDatasetList( array $filter )

Get a list of available datasets with optional filters

Get a list of available datasets with optional filters

Parameters

$filter
Optional state and year filters

Returns

array
The list of datasets available and their corresponding access keys
public array
# getDataset( integer $session_id, string $access_key )

Get a dataset archive payload for a specific session id

Get a dataset archive payload for a specific session id

Parameters

$session_id
The internal LegiScan session_id to be retrieved
$access_key
A valid access key provided in getDatasetList

Returns

array
The dataset payload with the actual zip file and meta information
public array
# getSessionPeople( integer $session_id )

Retrieve a list of people records active in a specific session id

Retrieve a list of people records active in a specific session id

Parameters

$session_id
The internal LegiScan session_id to scan

Returns

array
Collection of LegiScan_Pull::getPerson() equivalent records of those active in session
public array
# getSponsoredList( integer $people_id )

Retrieve a list of bills sponsored by an individual legislator

Retrieve a list of bills sponsored by an individual legislator

Parameters

$people_id

$people The internal LegiScan people_id to look for

Returns

array
Information on the list of sponsored bills
protected mixed[]
# apiRequest( string $op, array $params )

Makes the actual request to the LegiScan API server via cURL

Makes the actual request to the LegiScan API server via cURL

Parameters

$op
The API operation to actually perform
$params

An associative array of the required parameters to perform the needed API operation

Returns

mixed[]
An associative array representing the API response

Throws

APIException
public boolean
# importBillList( array $bills, LegiScan_Process $logic )

Process a bill_id list processing and requesting any necessary missing child objects

Process a bill_id list processing and requesting any necessary missing child objects

Parameters

$bills

$payload List of the LegiScan bill_ids that should be imported

$logic
An instance of LegiScan_Process attached to its database

Returns

boolean
Indicating the success/failure of bill payload processing
public string
# getURL( )

Return the most recent Pull API request URL generated by LegiScan_Pull::apiRequest()

Return the most recent Pull API request URL generated by LegiScan_Pull::apiRequest()

Returns

string
The full request URL
public string
# getRawResponse( )

Return the JSON payload of the most recent Pull API request by LegiScan_Pull::apiRequest()

Return the JSON payload of the most recent Pull API request by LegiScan_Pull::apiRequest()

Returns

string
The JSON data structure
public string
# getCacheFilename( string $op, array $params )

Generate an API cache filename

Generate an API cache filename

Parameters

$op
The API operation hook name
$params
The API paramaters that were part of the call

Returns

string
Filename path fragment for the cache location under cache root
Properties summary
protected string $api_key

LegiScan API key for requests from config.php

LegiScan API key for requests from config.php

#
protected string $response

Raw response from an API call

Raw response from an API call

#
protected mixed[] $payload

Decoded associative array representing the API response

Decoded associative array representing the API response

#
protected LegiScan_Cache_File $cache

Cache layer interface

Cache layer interface

#
protected string $request_url

Most recent Pull API request URL

Most recent Pull API request URL

#
LegiScan API Client API documentation generated by ApiGen