/** * Perform an 'item' request for the CheckfrontModule.package_category_id() category with 'packages' option set on. * * @param null $startDate * @param null $endDate * @param array $filters * @return CheckfrontAPIPackagesResponse */ public function listPackages($startDate = null, $endDate = null, array $filters = array()) { static $cache = array(); $cacheKey = md5(implode('|', array($startDate, $endDate, implode('|', $filters)))); if (!isset($cache[$cacheKey])) { $params = self::request_params(__FUNCTION__, array('category_id' => CheckfrontModule::package_category_id(), 'packages' => true), $this->buildDates($startDate, $endDate), $filters); $cache[$cacheKey] = CheckfrontAPIPackagesResponse::create($this()->api(new CheckfrontAPIRequest("item", $params))); } return $cache[$cacheKey]; }
/** * REturn a list of packages as an ID => Title map suitable for using in a dropdown list. * * @param CheckfrontAPIPackageResponse $apiResponse * * @return array */ protected function getAvailablePackagesMap(CheckfrontAPIPackagesResponse $apiResponse) { $options = array(); if ($packages = $apiResponse->getPackages()) { foreach ($packages as $package) { $options[$package->ItemID] = $package->Title; } } return $options; }