/** * @param mixed $offset * @return bool indicating if the resource at this offset exists * @throws InvalidAPIResponseException * @throws NoResponseException */ public function exists($offset) { $url = $this->_cache['subs'][$this->_dynamicSub]['path']; // replace all dynamic path parts foreach ($this->_pathParams as $name => $value) { $url = str_replace($name, $value, $url); } // insert offset in the request $url = str_replace($this->_dynamicSub, $offset, $url) . '?'; // get request try { $res = GET::request($url, $this->_auth); } catch (NoResponseException $e) { if (substr($e, 0, 4) == 'http') { throw $e; } else { return false; } } // check if object exists if (is_object($res)) { if (isset($res->status) && ($res->status->code == 404 || $res->status->code == 500)) { return false; } else { return true; } } else { return false; } }
static function ToFloat($i) { return floatval(GET::FetchIndex($i)); }
/** * @return object representing the resource returned by this endpoint * @throws ActiveRoleRequiredException * @throws InvalidAPIResponseException * @throws NoResponseException * @throws OperationNotAvailableException * @throws ParameterRequiredException * @throws UnauthorizedException */ public function get() { if (in_array('GET', $this->_cache['operations'])) { if ($this->valid('GET')) { $url = $this->getQueryUrl('GET'); // check if we need to add the page parameter if (isset($this->_currentPage)) { $url .= 'page=' . $this->_currentPage . '&'; } // check if we need to add the per_page parameter if (isset($this->_perPage)) { $url .= 'per_page=' . $this->_perPage . '&'; } // try to load $res = GET::request($url, $this->_auth); // validate response if (isset($res->status) && isset($res->status->code) && isset($res->status->message)) { $this->proceedStatus($res->status); } else { return $res; } } else { throw new ParameterRequiredException('There are one or more required parameters missing for a GET request'); } } else { throw new OperationNotAvailableException("Operation GET is not available."); } }