/** * Update a resource * * @param \Jaspersoft\Dto\Resource\Resource $resource Resource object fully describing updated resource * @param boolean $overwrite Replace existing resource even if type differs? * @return \Jaspersoft\Dto\Resource\Resource */ public function updateResource(Resource $resource, $overwrite = false) { $url = self::makeUrl(null, $resource->uri); $body = $resource->toJSON(); $url .= '?' . Util::query_suffix(array("overwrite" => $overwrite)); // Isolate the class name, lowercase it, and provide it as a filetype in the headers $type = explode('\\', get_class($resource)); $file_type = 'application/repository.' . lcfirst(end($type)) . '+json'; $data = $this->service->prepAndSend($url, array(201, 200), 'PUT', $body, true, $file_type, 'application/json'); return $resource::createFromJSON(json_decode($data, true), get_class($resource)); }