Overview

Packages

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

Classes

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

Class LegiScan_Process

LegiScan API Database Process Class

Class that processes decoded API payloads from LegiScan_Bulk, LegiScan_Pull or LegiScan_Push into the database. Each process*() function maps to the corresponding API response to INSERT or UPDATE the necessary data.

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_Import
See: LegiScan_Endpoint
See: LegiScan_Worker
Link: https://api.legiscan.com/dl/
Link: https://legiscan.com/legiscan
Located at LegiScan.php
Methods summary
public
# __construct( )

Class constructor, connects to database and caching layers

Class constructor, connects to database and caching layers

Throws

PDOException
public boolean
# processSessionList( array $payload )

Process a session list payload

Process a session list payload

Parameters

$payload
The decoded internal payload representing a session list

Returns

boolean
Indicating the success/failure of session list payload processing

Throws

APIStatusException
PDOException
public boolean
# processSession( array $payload )

Process a single session payload

Process a single session payload

Parameters

$payload
The decoded internal payload representing a session

Returns

boolean
Indicating the success/failure of session payload processing

Throws

APIStatusException
PDOException
public integer[]
# processMasterList( array $payload, integer $import_type = LegiScan::IMPORT_ALL )

Process a master list payload, adding any necessary missing child objects to the missing list

Process a master list payload, adding any necessary missing child objects to the missing list

Parameters

$payload
The decoded internal payload representing a master list
$import_type
The LegiScan::IMPORT_* to control how bills are selected for import

Returns

integer[]
Returns an array of missing/changed bill_id or FALSE on processing errors

Throws

APIStatusException
public mixed[]
# processBill( array $payload )

Process a bill payload, adding any necessary missing child objects to the missing list

Process a bill payload, adding any necessary missing child objects to the missing list

Parameters

$payload
The decoded internal payload representing a bill

Returns

mixed[]
Array of objects : ids that are missing and need to be requested

Throws

APIStatusException
PDOException
public boolean
# processBillText( array $payload )

Process a bill text payload

Process a bill text payload

Parameters

$payload
The decoded internal payload representing a bill text

Returns

boolean
Indicating the success/failure of bill text payload processing

Throws

APIException
APIAccessException
APIStatusException
PDOException
public boolean
# processAmendment( array $payload )

Process an amendment payload

Process an amendment payload

Parameters

$payload
The decoded internal payload representing an amendment

Returns

boolean
Indicating the success/failure of amendment payload processing

Throws

APIException
APIAccessException
APIStatusException
PDOException
public boolean
# processSupplement( array $payload )

Process a supplement payload

Process a supplement payload

Parameters

$payload
The decoded internal payload representing a supplement

Returns

boolean
Indicating the success/failure of supplement payload processing

Throws

APIException
APIAccessException
APIStatusException
PDOException
public integer[]
# processRollCall( array $payload )

Process a roll call payload

Process a roll call payload

Parameters

$payload
The decoded internal payload representing a roll call

Returns

integer[]
Returns a list of missing people_id FALSE on processing errors

Throws

APIStatusException
PDOException
public boolean
# processPerson( array $payload )

Process a person payload

Process a person payload

Parameters

$payload
The decoded internal payload representing a person

Returns

boolean
Indicating the success/failure of person payload processing

Throws

APIStatusException
PDOException
public integer[]
# processSearch( array $payload, integer $import_type = LegiScan::IMPORT_ALL, integer $relevance_cutoff = 0 )

Process a search result and identify bills to be imported

Process a search result and identify bills to be imported

Parameters

$payload
The decoded internal payload representing a search result
$import_type
Control what condition triggers a bill to be flagged for importing
$relevance_cutoff
Results must also match have this relevance score or higher

Returns

integer[]
List of LegiScan bill_ids that qualify for importing
public integer[]
# processMonitorList( array $payload, integer $import_type = LegiScan::IMPORT_ALL )

Process a monitored list payload, adding any necessary missing child objects to the missing list

Process a monitored list payload, adding any necessary missing child objects to the missing list

Parameters

$payload
The decoded internal payload representing a monitored list
$import_type
The LegiScan::IMPORT_* to control how bills are selected for import

Returns

integer[]
Returns an array of missing/changed bill_id or FALSE on processing errors

Throws

APIStatusException
public boolean
# monitor( integer $bill_id, boolean $add = true, boolean $stance = LegiScan::STANCE_WATCH )

Add or remove a bill_id from the ls_monitor list

Add or remove a bill_id from the ls_monitor list

Parameters

$bill_id
The bill_id to add or remove
$add
Add to list when true, remove when false
$stance
Stance on the bill from Watch, Support, Oppose

Returns

boolean
Indicating the success/failure of manipulating ignore list
public boolean
# ignore( integer $bill_id, boolean $add = true )

Add or remove a bill_id from the ls_ignore list

Add or remove a bill_id from the ls_ignore list

Parameters

$bill_id
The bill_id to add or remove
$add
Add to list when true, remove when false

Returns

boolean
Indicating the success/failure of manipulating ignore list
public boolean|integer
# checkExists( string $table, integer $id, boolean $skip_cache = false )

Check to see if a key exists in a table, results are cached via LegiScan_Cache_Memory

Check to see if a key exists in a table, results are cached via LegiScan_Cache_Memory

Parameters

$table
Base name of the table to check
$id
Key id to check for
$skip_cache
Bypass cache and do direct lookup

Returns

boolean|integer
Returns FALSE if does not exist, otherwise the $id is returned
private PDOStatement
# makeSQLStatement( string $type, string $table, array[] $updates, array[] $keys )

Create a PDO statatement for INSERT/UPDATE and bound values ready for execute()

Create a PDO statatement for INSERT/UPDATE and bound values ready for execute()

Parameters

$type
Type of SQL statement to generate
$table
Table name
$updates
Array of field => array(value, type) pairs for updates
$keys
Arry of field => array(value, type) pairs for table key(s)

Returns

PDOStatement
PDO prepared and bound statement
private mixed[]
# billInit( )

Create a skeleton data structure that will be filled by LegiScan_Process::loadBill()

Create a skeleton data structure that will be filled by LegiScan_Process::loadBill()

Returns

mixed[]
The blank bill data structure
public mixed[]
# loadBill( integer $bill_id )

Recreate a data structure that mimics the getBill payload for comparison when updating existing bills

Recreate a data structure that mimics the getBill payload for comparison when updating existing bills

Parameters

$bill_id
The bill_id to load

Returns

mixed[]
The data structure representing a bill
public boolean
# request( string $object, integer $id )

Add an object:id pair to the missing list while preventing duplications

Add an object:id pair to the missing list while preventing duplications

Parameters

$object
The name of the type of object being requested
$id
The object LegiScan ID of the requested object

Returns

boolean
Indicating the success/failure of adding to the missing list
public array
# getMissing( )

Get the list of missing objects, if any, from the most recent process run

Get the list of missing objects, if any, from the most recent process run

Returns

array
The structured list of missing objects
public boolean
# resetMissing( )

Reset the list of missing objects

Reset the list of missing objects

Returns

boolean
Indicating success/failure of the reset
public PDO
# getDB( )

Return the DB handle so others can play if needed

Return the DB handle so others can play if needed

Returns

PDO
Database PDO handle
private string|null
# dbDate( string $date )

Massage '0000-00-00' date to NULL when operating under PostgreSQL

Massage '0000-00-00' date to NULL when operating under PostgreSQL

Parameters

$date
The date to massage

Returns

string|null
The massaged and relaxed date
public array[]
# getStateList( )

Get a list of state table records for ALL substitutions

Get a list of state table records for ALL substitutions

Returns

array[]
Array of state table rows
public boolean
# middlewareSignal( string $object, integer $id )

Send a signal to the middleware that data has changed so appropriate steps can be taken

Send a signal to the middleware that data has changed so appropriate steps can be taken

Parameters

$object
The type of object
$id
The object ID

Returns

boolean
Indicating the success/failure of sending signal
public string
# getCacheFilename( string $object, integer $id )

Generate a document cache filename path fragment

Generate a document cache filename path fragment

Parameters

$object
The type of document object
$id
The document object ID

Returns

string
Filename path fragment for the location under the document cache directory
Properties summary
protected array[] $missing

Array of object ids that are missing and should be requested

Array of object ids that are missing and should be requested

#
protected PDO $db

PDO Database object handle

PDO Database object handle

#
protected LegiScan_Cache_File $cache

LegiScan document cache object handle

LegiScan document cache object handle

#
protected LegiScan_Cache_Memory $memcache

LegiScan memory cache object handle

LegiScan memory cache object handle

#
private boolean $massage

Should dates be massaged for PostgreSQL in case of '0000-00-00'

Should dates be massaged for PostgreSQL in case of '0000-00-00'

#
LegiScan API Client API documentation generated by ApiGen