/** * 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(); }
public function testCreate() { $fileInfo = new FileInfo(); $fileInfo->setDocumentURL('test.pdf', 'http://www.yahoo.com', 'application/pdf'); $doc = new DocumentCreationInfo($fileInfo, 'test', 'ESIGN', 'SENDER_SIGNATURE_NOT_REQUIRED'); $doc->setCallBackInfo('http://localhost'); $output = $doc->toArray(); $this->assertEquals('test', $output['name']); $this->assertEquals('http://localhost', $output['callbackInfo']); $this->assertEquals(1, count($output['fileInfos'])); }
/** * Create an agreement from a file hosted on a remote server, for specified signerEmail with message. You can use * $this->getResponse() to get created agreement. If successful it returns the agreementId. * @param $signerEmail * @param $message * @param $fileName * @param $url * @param $agreementName * @return bool|string * @internal param $signatureType * @internal param $signatureFlow */ public function createFromUrl($signerEmail, $message, $fileName, $url, $agreementName) { $this->agreement = new Agreements($this->getToken(), $this->getTransport()); $fileInfo = new FileInfo(); $fileInfo->setDocumentURL($fileName, $url); $docCreationInfo = new DocumentCreationInfo($fileInfo, $agreementName, $this->getSignatureType(), $this->getSignatureFlow()); $docCreationInfo->setMessage($message)->addRecipient('SIGNER', $signerEmail); $agreementCreationInfo = new AgreementCreationInfo($docCreationInfo, new InteractiveOptions()); try { $this->response = $this->agreement->create($agreementCreationInfo); } 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->getAgreementId(); }