/** * Get Item Info * * @param itemId - required - * Item id * @return An Item object with details like itemId, expiration date, file details etc. * or the error code and message returned by the server. * */ public function getItemInfo($itemId) { $parameters = array(); $urld = 'dpi/v1/item/' . $itemId; $this->response = $this->_restTransportInstance->sendRequest($urld, $parameters, 'GET', $this->_authToken); $responseBody = simplexml_load_string($this->response); $returnObject = new Item(); if ($responseBody === false) { $errorCode = 'N/A'; $errorMessage = 'The server has encountered an error, please try again.'; $errorObject = new ErrorStatus($errorCode, $errorMessage); $returnObject->setErrorStatus($errorObject); } else { if (empty($responseBody->errorStatus)) { $create = (string) $responseBody->create; $returnObject->setCreate($create); $expiration = (string) $responseBody->expiration; $returnObject->setExpiration($expiration); $id = (string) $responseBody->id; $returnObject->setId($id); $subject = (string) $responseBody->subject; $returnObject->setSubject($subject); $message = (string) $responseBody->message; $returnObject->setMessage($message); $recipients = (string) $responseBody->recipients; $returnObject->setRecipients(explode(",", $recipients)); $theFiles = array(); $filesTag = $responseBody->file; if (!empty($filesTag)) { foreach ($responseBody->file as $currentFile) { if ($currentFile->count() > 0) { $file = new File(); $file->setDownloadUrl((string) $currentFile->downloadUrl); $file->setDownloads((string) $currentFile->downloads); $file->setId((string) $currentFile->id); $file->setName((string) $currentFile->name); $file->setPasswordProtect((string) $currentFile->passwordProtect); $file->setReturnReceipt((string) $currentFile->returnReceipt); $file->setSize((string) $currentFile->size); $file->setVerifyIdentity((string) $currentFile->verifyIdentity); $tracking = array(); $trackTag = $currentFile->tracking; if (!empty($trackTag)) { foreach ($currentFile->tracking as $currentTrack) { if ($currentTrack->count() > 0) { $track = new Tracking(); $track->setEmail((string) $currentTrack->email); $track->setWhen((string) $currentTrack->when); array_push($tracking, $track); } } $file->setTracking($tracking); } array_push($theFiles, $file); } } $returnObject->setFiles($theFiles); } } else { $errorCode = (string) $responseBody->errorStatus->code; $errorMessage = (string) $responseBody->errorStatus->message; $errorObject = new ErrorStatus($errorCode, $errorMessage); $returnObject->setErrorStatus($errorObject); } } return $returnObject; }