/** * Unarchives a document. */ public static function unarchive($id) { Api::request('PATCH', 'document/' . $id . '/', ['archived' => false]); }
throw new Exceptions\AuthenticationException(); case 429: throw new Exceptions\ThrottledException(); default: throw new Exceptions\ApiException($response->getStatusCode(), $response->getBody()); } } /** * Internal function for first-time setup of the class. * * Performs first-time setup for static properties of this class. Do not call this method, it will be automatically * called as soon as this file is loaded. */ public static function boot() { // Check if this is Laravel; if so, automatically set the credentials from the configuration file. if (function_exists('config')) { // Laravel 5 and up self::credentials(config('legalesign.userid'), config('legalesign.secret')); } elseif (class_exists('\\Config')) { // Laravel 4.2 and below self::credentials(\Config::get('legalesign.userid'), \Config::get('legalesign.secret')); } // Set up the base Guzzle object to use for all requests. We won't hardcode the Authorization header here, // because the credentials will only be set for Laravel. We'll generate that header each time any request is // made. self::$api = new Client(); } } Api::boot();
/** * 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); }