/** * Create an agreement from a transientDocumentId, 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 $transientDocumentId * @param $agreementName * @return bool|string * @internal param $signatureType * @internal param $signatureFlow */ public function createFromTransientDocumentId($signerEmail, $message, $transientDocumentId, $agreementName) { $this->agreement = new Agreements($this->getToken(), $this->getTransport()); $fileInfo = new FileInfo(); $fileInfo->transientDocumentId = $transientDocumentId; $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(); }
public function testCancel() { $returnJson = '{ "result": "CANCELLED" }'; $transport = new \Echosign\Transports\GuzzleTransport(); $client = $transport->getClient(); $stream = Stream::factory($returnJson); $mock = new Mock([new Response(200, ['content-type' => 'application/json'], $stream)]); $client->getEmitter()->attach($mock); $agreement = new Agreements('12335', $transport); $info = new \Echosign\RequestBuilders\AgreementStatusUpdateInfo(); $response = $agreement->cancel('12345', $info); $this->assertInstanceOf('Echosign\\Responses\\AgreementStatusUpdateResponse', $response); $this->assertEquals('CANCELLED', $response->getResult()); }