url = $api_url; $this->token = $api_token; $this->set_scope(); } public function load($force = false) { if ($this->loaded && !$force) return $this; $jenc = $this->mget(); $this->json_set_property($this->json_decode($jenc)); $this->loaded = true; return $this; } public function get($scope) { throw new NotImplementedException("Method not implemented for " . __CLASS__ . ", cant lookup " . $scope); } public function create() { throw new NotImplementedException("Method not implemented for " . __CLASS__ . ", cant create"); } public function patch() { throw new NotImplementedException("Method not implemented for " . __CLASS__ . ", cant create"); } public function delete() { throw new NotImplementedException("Method not implemented for " . __CLASS__ . ", cant create"); } private function json_decode($jenc) { $obj = json_decode($jenc); if (($err = json_last_error()) != JSON_ERROR_NONE) throw new RequestErrorException(json_last_error_msg(), $err); return $obj; } abstract protected function json_set_property($obj); abstract protected function set_scope(); public function __destruct() {} } ?>