/** * Create a transient document from a local filepath, then create a widget for use with that transient document. This * function returns the url for the widget. You can use $this->getResponse() to get the widget object. * @param $fileName * @param $widgetName * @return bool|string */ public function createTransientWidgetFromLocalFile($fileName, $widgetName) { $transientDocument = new TransientDocument($this->getToken(), $this->getTransport()); $transientDocumentId = $transientDocument->create($fileName); if ($transientDocumentId === false) { $this->response = $transientDocument->getResponse(); $this->errorMessages = $transientDocument->getErrorMessages(); return false; } $this->widget = new Widgets($this->getToken(), $this->getTransport()); $fileInfo = new WidgetFileInfo(); $fileInfo->setTransientDocumentId($transientDocumentId); $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(); }
/** * Create a libraryDocument from a local file. If successful, it returns the libraryDocumentId. You can get the full * libraryDocument object with $this->getResponse() * @param $localFilename * @param $libraryFilename * @param $templateType * @param string $sharingMode * @return bool|string */ public function createFromLocalFile($localFilename, $libraryFilename, $templateType, $sharingMode = 'USER') { // first create a transient document $transientDocument = new TransientDocument($this->getToken(), $this->getTransport()); $transientDocumentId = $transientDocument->create($localFilename); if ($transientDocumentId === false) { $this->response = $transientDocument->getResponse(); $this->errorMessages = $transientDocument->getErrorMessages(); return false; } $this->libraryDocument = new LibraryDocuments($this->getToken(), $this->getTransport()); $fileInfo = new FileInfo(); $fileInfo->setTransientDocumentId($transientDocumentId); $docCreationInfo = new LibraryDocumentCreationInfo($libraryFilename, $templateType, $fileInfo, $sharingMode); $libCreationInfo = new LibraryCreationInfo($docCreationInfo, new InteractiveOptions()); try { $this->response = $this->libraryDocument->create($libCreationInfo); } 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->getLibraryDocumentid(); }
/** * Create an agreement from a local file, for specified signerEmail with message. It first creates a transient * 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 * @internal param $signatureType * @internal param $signatureFlow */ public function createTransientAgreement($signerEmail, $message, $filename, $agreementName) { $transientDocument = new TransientDocument($this->getToken(), $this->getTransport()); $transientDocumentId = $transientDocument->create($filename); if ($transientDocumentId === false) { $this->response = $transientDocument->getResponse(); $this->errorMessages = $transientDocument->getErrorMessages(); return false; } return $this->createFromTransientDocumentId($signerEmail, $message, $transientDocumentId, $agreementName); }