public static function createJob(ResourceDescriptor $folder) { $timecode = md5(microtime()); $result = new Job(); $result->baseOutputFilename = 'test' . $timecode; $result->repositoryDestination['folderURI'] = $folder->getUriString(); $result->repositoryDestination['overwriteFiles'] = 'false'; $result->repositoryDestination['sequentialFilenames'] = 'false'; $result->description = 'test' . $timecode; $result->label = 'test' . $timecode; $result->outputFormats['outputFormat'][] = 'PDF'; $result->outputFormats['outputFormat'][] = 'XLS'; $result->outputFormats['outputFormat'][] = 'RTF'; $result->source['reportUnitURI'] = '/reports/samples/AllAccounts'; $result->simpleTrigger['recurrenceInterval'] = '1'; $result->simpleTrigger['recurrenceIntervalUnit'] = 'DAY'; $result->simpleTrigger['occurrenceCount'] = '2'; $result->simpleTrigger['startDate'] = '2025-01-26T00:00:00-07:00'; $result->simpleTrigger['timezone'] = 'America/Los_Angeles'; return $result; }
/** * Update a resource that is already in existence by providing a new ResourceDescriptor defining the object at the URI provided. * * @param string $path - The path to the resource you wish to change * @param ResourceDescriptor $rd - a ResourceDescriptor object that correlates to the object you wish to modify (with the changes) * @param string $file - full file path to the image you wish to upload * @throws RESTRequestException * @return bool - based on success of function */ public function postResource($path, ResourceDescriptor $rd, $file = null) { $url = $this->restUrl . '/resource' . $path; $statusCode = null; if (!empty($file)) { $data = $this->multipartRequestSend($url, 200, 'POST_MP', $rd->toXML(), array($rd->getUriString(), $file), true); $statusCode = $data[0]; } else { $data = $this->prepAndSend($url, array(200), 'POST', $rd->toXML(), null, true); if ($data) { return true; } } if ($statusCode !== 200) { throw new RESTRequestException('Unexpected HTTP code returned: ' . $statusCode); } else { return true; } return false; }
/** * This function creates the XML recursively through this object and all children objects within. */ private function newXML() { $result = new \SimpleXMLElement('<resourceDescriptor></resourceDescriptor>'); foreach ($this->_rootAttributes as $k => $v) { if (!empty($v)) { $result->addAttribute($k, $v); } } if (!empty($this->label)) { $result->addChild('label', $this->label); } if (!empty($this->description)) { $result->addChild('description', $this->description); } if (!empty($this->creationDate)) { $result->addChild('creationDate', $this->creationDate); } if (count($this->children) > 0) { foreach ($this->children as $child) { ResourceDescriptor::sxml_append($result, $child->newXML()); } } if (count($this->properties) > 0) { foreach ($this->properties as $property) { ResourceDescriptor::sxml_append($result, $property->newXML()); } } return $result; }