X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FSunlight.php;h=a6cf20d31c5992549b0a632e5cf87e4deba1d193;hb=eda3ad41c0fd310d8f8a2158ed4a72867cad772d;hp=a4ab7c0cbf3c0cc7cea70865e4984bc90da82ed0;hpb=6628866da4eb17b8ff190928d8afdbee11526ae6;p=civicrm-core.git diff --git a/CRM/Utils/Sunlight.php b/CRM/Utils/Sunlight.php index a4ab7c0cbf..a6cf20d31c 100644 --- a/CRM/Utils/Sunlight.php +++ b/CRM/Utils/Sunlight.php @@ -36,6 +36,12 @@ class CRM_Utils_Sunlight { static $_apiURL = 'http://api.sunlightlabs.com/'; static $_apiKey = NULL; + /** + * @param $uri + * + * @return SimpleXMLElement + * @throws Exception + */ static function makeAPICall($uri) { require_once 'HTTP/Request.php'; $params = array( @@ -57,6 +63,11 @@ class CRM_Utils_Sunlight { return simplexml_load_string($string); } + /** + * @param $zipcode + * + * @return array + */ static function getCityState($zipcode) { $key = self::$_apiKey; $uri = "places.getCityStateFromZip.php?zip={$zipcode}&apikey={$key}&output=xml"; @@ -65,6 +76,11 @@ class CRM_Utils_Sunlight { return array($xml->city, $xml->state); } + /** + * @param $peopleID + * + * @return array + */ static function getDetailedInfo($peopleID) { $key = self::$_apiKey; $uri = "people.getPersonInfo.php?id={$peopleID}&apikey={$key}&output=xml"; @@ -94,6 +110,11 @@ class CRM_Utils_Sunlight { return $result; } + /** + * @param $uri + * + * @return array + */ static function getPeopleInfo($uri) { $xml = self::makeAPICall($uri); @@ -104,6 +125,12 @@ class CRM_Utils_Sunlight { return $result; } + /** + * @param $city + * @param $state + * + * @return array|null + */ static function getRepresentativeInfo($city, $state) { if (!$city || !$state @@ -116,6 +143,11 @@ class CRM_Utils_Sunlight { return self::getPeopleInfo($uri); } + /** + * @param $state + * + * @return array|null + */ static function getSenatorInfo($state) { if (!$state) { return NULL; @@ -126,6 +158,13 @@ class CRM_Utils_Sunlight { return self::getPeopleInfo($uri); } + /** + * @param $city + * @param $state + * @param null $zipcode + * + * @return array + */ static function getInfo($city, $state, $zipcode = NULL) { if ($zipcode) { list($city, $state) = self::getCityState($zipcode);