2017 © Pedro Peláez
 

library php-represent

A PHP library for http://represent.opennorth.ca/

image

seanmcn/php-represent

A PHP library for http://represent.opennorth.ca/

  • Monday, April 30, 2018
  • by Seanmcn
  • Repository
  • 1 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 7 % Grown

The README.md

PHP Represent

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

A PHP library for http://represent.opennorth.ca/, (*2)

Find the elected officials and electoral districts for any Canadian address or postal code, at all levels of government, (*3)

Install

Install using composer:, (*4)

"require": {
  "seanmcn/php-represent": "1.*"
}

Alternatively you could just download the package and load it in yourself., (*5)

Example Usage

$represent = new PHPRepresent\API();
$represent->getAll('boundaries', ['sets' => ['toronto-wards', 'ottawa-wards']]);

API Documentation

Library Documentation

get($path, $params, $throttle);

Returns a single result or one page of results from API path and parameters provided., (*6)

Parameters: - $path - The API Path of your request. - $params - $_GET variables you want to append to the request. Allows supplying multiple values per key by array or comma seperated. - $throttle - Default TRUE. Option to ignore the API rate limit., (*7)

Example Usage:, (*8)

$represent = new PHPRepresent\API();
$path = 'boundaries';
$params = ['sets' => ['toronto-wards', 'ottawa-wards']];
$represent->get($path, $params);

getAll($path, $params);

Returns all results from API path and parameters provided., (*9)

Parameters: - $path - The API Path of your request. - $params - $_GET variables you want to append to the request. Allows supplying multiple values per key by array or comma seperated., (*10)

Example Usage:, (*11)

$represent = new PHPRepresent\API();
$path = 'boundaries';
$params = ['sets' => 'toronto-wards,ottawa-wards'];
$represent->getAll($path, $params);

postcode($postcode);

Find representatives and boundaries by postal code., (*12)

Parameters: - $postcode - Post code to find representatives and boundaries for., (*13)

Example Usage:, (*14)

$represent = new PHPRepresent\API();
$represent->postcode('L5G4L3');

boundarySets($name, $params);

Return boundary sets which are groups of electoral districts, like BC provincial districts or Toronto wards., (*15)

Parameters: - $name - Optional, if provided will return the singular boundary set. - $params - $_GET variables you want to append to the request. Allows supplying multiple values per key by array or comma seperated., (*16)

Example Usage:, (*17)

$represent = new PHPRepresent\API();
$represent->boundarySets();

boundaries($boundarySet, $name, $representatives, $params)

Return boundaries of electoral districts, can be proved a set like toronto-wards for boundaries of a singular set., (*18)

All Parameters are optional however $name requires you provide $boundarySet and $representatives requires you provided both $boundarySet and $name, (*19)

Parameters: - $boundarySet - Optional, if provided returns boundaries from a singular boundary set - $name - Optional, if provided will return a singular boundary - $representatives - Optional, if provided will return representatives for the boundary. - $params - Optional, $_GET variables you want to append to the request. Allows supplying multiple values per key by array or comma seperated., (*20)

Example Usage:, (*21)

$represent = new PHPRepresent\API();
// One Set
$represent->boundaries('toronto-wards');
// Multiple Sets
$represent->boundaries(null, null, false,  ['sets' => ['toronto-wards', 'ottawa-wards']]);

representativeSets($set);

Returns all or a singular representative set., (*22)

A representative set is a group of elected officials, like the House of Commons or Toronto City Council., (*23)

Parameters: - $set - Optional, if provided will return the singular represenative set., (*24)

Example Usage:, (*25)

$represent = new PHPRepresent\API();
$represent->representativeSets('north-dumfries-township-council');

representatives($set, $params);

Returns a list of representatives., (*26)

Parameters: - $set - Optional, if provided will return the represenatives for a singular set. - $params - Optional, $_GET variables you want to append to the request. Allows supplying multiple values per key by array or comma seperated., (*27)

Example Usage:, (*28)

$represent = new PHPRepresent\API();
$represent->representatives('house-of-commons');

elections($election);

Returns a list of elections or a singular election., (*29)

This doesn't have any data right now so I am usnure if this is working correctly., (*30)

Parameters: - $election - Optional, if provided will return the a singular election based on provided ID., (*31)

Example Usage:, (*32)

$represent = new PHPRepresent\API();
$represent->elections();

candidates($election, $params);

Returns a list of all candidates for all elections or all candidates for a singular election, (*33)

This doesn't have any data right now so I am unsure if this is working correctly., (*34)

Parameters: - $election - Optional, if provided will return the candidates for a singular election. - $params - Optional, $_GET variables you want to append to the request. Allows supplying multiple values per key by array or comma seperated., (*35)

Example Usage:, (*36)

$represent = new PHPRepresent\API();
$represent->candidates();

setInsecure();

Option to disable using HTTPS, if for example you are having certificate problems while testing this out., (*37)

Note: You really shouldn't use this in Production, (*38)

Example Usage:, (*39)

$represent = new PHPRepresent\API();
$represent->setInsecure();
$represent->boundaries('toronto-wards');

setRateLimit($limit);

Option to set the rate limit (per minute) to whatever you choose. The default rate limit is 60 requests per minute., (*40)

Note: Don't change this unless you have agreed upon a higher rate limit with Open North otherwise you're going to get HTTP 503 errors, (*41)

Example Usage:, (*42)

$represent = new PHPRepresent\API();
$represent->setRateLimit(42);
$represent->boundaries('ottawa-wards');

The Versions

30/04 2018

dev-master

9999999-dev https://github.com/seanmcn/php-represent

A PHP library for http://represent.opennorth.ca/

  Sources   Download

GPL-3.0+

The Requires

  • php ^5.4|^7.0

 

The Development Requires

by Sean McNamara

api php library canada represent opennorth politics

06/04 2016

v1.0

1.0.0.0 https://github.com/seanmcn/php-represent

A PHP library for http://represent.opennorth.ca/

  Sources   Download

GPL-3.0+

The Requires

  • php ^5.4|^7.0

 

The Development Requires

by Sean McNamara

api php library canada represent opennorth politics