diff --git a/Services/FullContact/Stats.php b/Services/FullContact/Stats.php new file mode 100644 index 0000000..6a083a3 --- /dev/null +++ b/Services/FullContact/Stats.php @@ -0,0 +1,48 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 Apache + */ +class Services_FullContact_Stats extends Services_FullContact +{ + protected $_supportedMethods = array('retrieve'); + protected $_resourceUri = '/stats.json'; + + public function retrieve($period = null) + { + if (is_null($period)) { + throw new Services_FullContact_Exception_Base("To retrieve stats, you must supply a period date."); + } + if (self::validatePeriod($period)) { + return $this->_execute(array('period' => $period, 'method' => 'retrieve')); + } + else { + throw new Services_FullContact_Exception_Base("The period date is not well formated. Please provide the following format YYYY-MM."); + } + + } + + public function validatePeriod($date) + { + $format = DateTime::createFromFormat('Y-m', $date); + return $format && $format->format('Y-m') == $date; + } +} \ No newline at end of file