Exemplo n.º 1
0
 /**
  * Get Upload Urls
  *
  * @param recipients - required -
  *          Comma separated email addresses of the recipients.
  *          Maximum 300 email addresses can be provided.
  *          The maximum length of an email address is 128 characters.
  * @param filecount - optional -
  *          The number of files to be sent. Maximum 20 files can be sent at a time.
  * @param subject - optional -
  * 			The subject for the email notification. Maximum 200 characters are allowed in the subject.
  * @param message - optional -
  * 			The message for the email body.
  * 			Maximum 2000 characters are allowed in the message.
  * @param verifyIdentity - optional -
  * 			If true, the recipients are required to login to access the files.
  * @param returnReceipt - optional -
  * 			If true, an email notification is sent to the sender, when someone downloads the file.
  * @param password - optional -
  * 			If set, the recipients are asked to enter the password before they can access the files. The minimum length of the password is 5 characters.
  * @return 	An Upload object with upload URLs or the error code and message thrown by the server.
  * 	 */
 public function getUploadURLs($recipients, $filecount = '', $subject = '', $message = '', $verifyIdentity = '', $returnReceipt = '', $password = '')
 {
     $parameters = array('recipients' => $recipients);
     if ($filecount !== '') {
         $parameters['fileCount'] = $filecount;
     }
     if ($subject !== '') {
         $parameters['subject'] = $subject;
     }
     if ($message !== '') {
         $parameters['message'] = $message;
     }
     if ($verifyIdentity !== '') {
         $parameters['verifyIdentity'] = $verifyIdentity;
     }
     if ($returnReceipt !== '') {
         $parameters['returnReceipt'] = $returnReceipt;
     }
     if ($password !== '') {
         $parameters['password'] = $password;
     }
     $urld = 'dpi/v1/item/send';
     $this->response = $this->_restTransportInstance->sendRequest($urld, $parameters, 'POST', $this->_authToken);
     $responseBody = simplexml_load_string($this->response);
     $returnObject = new Send();
     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)) {
             $itemId = (string) $responseBody->itemId;
             $returnObject->setItemId($itemId);
             $urls = array();
             foreach ($responseBody->uploadUrl as $child) {
                 $urls[] = (string) $child;
             }
             $returnObject->setUploadUrl($urls);
         } else {
             $errorCode = (string) $responseBody->errorStatus->code;
             $errorMessage = (string) $responseBody->errorStatus->message;
             $errorObject = new ErrorStatus($errorCode, $errorMessage);
             $returnObject->setErrorStatus($errorObject);
         }
     }
     return $returnObject;
 }