/** * Gets the download URL. * * @return string The URL at which the PDF can be downloaded */ public function getPdf() { if (!$this->downloadReady) { return null; } return Api::requestRaw('get', 'pdf/' . $this->id . '/')->getBody(); }
/** * Runs the final request, and returns a Document object. * * @param array $with Additional data to send to the API. * @return Document Created document for signing */ protected function doRequest($with = []) { $data = array_merge($this->generateLegalesignRequestParams(), $with); $response = Legalesign\Api::requestRaw('POST', 'document/', $data); // Get the document's ID, which is in the URL Legalesign redirects to after a successful creation. $apiEntityUrl = $response->getHeader('Location')[0]; $id = call_user_func(function ($parts) { return $parts[count($parts) - 2]; }, explode('/', $apiEntityUrl)); return Legalesign\Document::find($id); }