Exemple #1
0
 /**
  * Create a library document from a local file, then create a widget for that document. If successful it returns the
  * url to the widget. You can use $this->getResponse() to get the widget object.
  * @param $fileName
  * @param $widgetName
  * @return bool|string
  */
 public function createLibraryDocumentWidgetFromLocalFile($fileName, $widgetName)
 {
     $libraryDocument = new LibraryDocument($this->getToken(), $this->getTransport());
     $libraryDocumentId = $libraryDocument->createFromLocalFile($fileName, basename($fileName), 'DOCUMENT');
     if ($libraryDocumentId === false) {
         $this->response = $libraryDocument->getResponse();
         $this->errorMessages = $libraryDocument->getErrorMessages();
         return false;
     }
     $this->widget = new Widgets($this->getToken(), $this->getTransport());
     $fileInfo = new WidgetFileInfo();
     $fileInfo->setLibraryDocumentId($libraryDocumentId);
     $widgetCreationInfo = new WidgetCreationInfo($widgetName, $this->getSignatureFlow(), $fileInfo);
     $widgetRequest = new WidgetCreationRequest($widgetCreationInfo, new InteractiveOptions());
     try {
         $this->response = $this->widget->create($widgetRequest);
     } catch (JsonApiResponseException $e) {
         $this->errorMessages[$e->getCode()] = sprintf('%s - %s', $e->getApiCode(), $e->getMessage());
         return false;
     } catch (\Exception $e) {
         $this->errorMessages[$e->getCode()] = $e->getMessage();
         return false;
     }
     return $this->response->getUrl();
 }
Exemple #2
0
 /**
  * Create an agreement from a local file, for specified signerEmail with message. It first creates a library
  * document, then creates the agreement. You can use $this->getResponse() to get created agreement. If successful
  * it returns the agreementId.
  * @param $signerEmail
  * @param $message
  * @param $filename
  * @param $agreementName
  * @return bool|string
  */
 public function createLibraryDocumentAgreement($signerEmail, $message, $filename, $agreementName)
 {
     $libraryDocument = new LibraryDocument($this->getToken(), $this->getTransport());
     $libraryDocumentId = $libraryDocument->createFromLocalFile($filename, basename($filename), 'DOCUMENT');
     if ($libraryDocumentId === false) {
         $this->response = $libraryDocument->getResponse();
         $this->errorMessages = $libraryDocument->getErrorMessages();
         return false;
     }
     return $this->createFromLibraryDocumentId($signerEmail, $message, $libraryDocumentId, $agreementName);
 }