/**
  * Download Pdfs
  *
  * @param $import_key
  */
 public function download($import_key)
 {
     $contracts = $this->getJsonData($import_key);
     foreach ($contracts as $contract) {
         $this->updateContractJsonByID($import_key, $contract->id, ['download_status' => static::PROCESSING]);
         if (empty($contract->pdf_url)) {
             $this->updateContractJsonByID($import_key, $contract->id, ['download_remarks' => trans('Pdf file url is required'), 'download_status' => static::FAILED]);
             continue;
         }
         $file = $this->downloadPdf($import_key, $contract->pdf_url);
         if (is_null($file)) {
             $this->updateContractJsonByID($import_key, $contract->id, ['download_remarks' => trans('File could not be downloaded'), 'download_status' => static::FAILED]);
             continue;
         }
         $fileHash = getFileHash($this->getFilePath($import_key, $file));
         if ($con = $this->contract->getContractByFileHash($fileHash)) {
             $title = sprintf('<a href="%s" target="_blank">%s</a>', route('contract.show', $con->id), str_limit($con->title, 25));
             $this->updateContractJsonByID($import_key, $contract->id, ['download_remarks' => trans('contract.import.exist', ['link' => $title]), 'file' => $file, 'download_status' => static::FAILED]);
             $this->deleteFile($import_key, $file);
             continue;
         }
         $filePath = $this->getFilePath($import_key, $file);
         $this->updateContractJsonByID($import_key, $contract->id, ['file' => $file, 'filehash' => $fileHash, 'file_size' => filesize($filePath), 'download_status' => static::COMPLETED]);
     }
 }
 /**
  * Check for unique file hash
  *
  * @param $file
  * @return bool|Contract
  */
 public function getContractIfFileHashExist($filehash)
 {
     try {
         if ($file = $this->contract->getContractByFileHash($filehash)) {
             return $file;
         }
     } catch (Exception $e) {
         $this->logger->error($e->getMessage());
     }
     return false;
 }