/**
  * Upload missing files to upstream service
  *
  * @param $clientDocuments
  * @param callable $fileDetailCallback
  * @throws DocumentUploader\Exception\InvalidDetailType
  */
 private function addMissing($clientDocuments, Closure $fileDetailCallback)
 {
     //        $upstreamDocuments = $this->clientContext->getDocuments(array(
     //            'referencingApplicationUuId' => $this->application->getReferencingApplicationUuId(),
     //        ));
     // Look for documents in the upload that aren't in IRIS
     // These should be added to IRIS.
     /** @var FormInterface $clientDocument */
     foreach ($clientDocuments as $clientDocument) {
         // Get the uploaded file
         /** @var UploadedFile $uploadedFile */
         $uploadedFileData = $clientDocument->getData();
         $uploadedFile = $uploadedFileData['fileItem'];
         if ($uploadedFile) {
             //                if (!$this->matchUpstreamDocument($uploadedFile->getClientOriginalName(), $upstreamDocuments)) {
             // File not found in IRIS, add the file
             $fileDetail = array();
             if (null !== $fileDetailCallback) {
                 $fileDetailResponse = $fileDetailCallback(array('uploadedFile' => $uploadedFile, 'application' => $this->application));
                 if (null !== $fileDetailResponse && !is_array($fileDetailResponse)) {
                     // Invalid response
                     throw new InvalidDetailType(sprintf('Response of type %s is invalid. Expected null or array.', get_class($fileDetailResponse)));
                 }
                 $fileDetail = $fileDetailResponse;
             }
             $fileName = !empty($fileDetail['uploadedFile']) && is_string($fileDetail['uploadedFile']) ? $fileDetail['uploadedFile'] : $uploadedFile->getClientOriginalName();
             $fileName = rtrim($fileName, $uploadedFile->getClientOriginalExtension());
             $fileName = $this->getSlugifier()->slugify($fileName, '_') . '.' . strtolower($uploadedFile->getClientOriginalExtension());
             $description = !empty($fileDetail['description']) && is_string($fileDetail['description']) ? $fileDetail['description'] : '';
             $this->clientContext->uploadDocument(array('referencingApplicationUuId' => $this->application->getReferencingApplicationUuId(), 'fileName' => $fileName, 'description' => $description, 'file' => $uploadedFile->getPathname(), 'categoryId' => DocumentCategoryOptions::MISCELLANEOUS));
             //                }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 protected function initialise()
 {
     $this->addClient('agent', function (array $parameters) {
         return \Barbondev\IRISSDK\System\Agent\SystemAgentClient::factory($parameters);
     })->addClient('landlord', function (array $parameters) {
         return \Barbondev\IRISSDK\System\Landlord\SystemLandlordClient::factory($parameters);
     })->addClient('systemApplication', function (array $parameters) {
         return \Barbondev\IRISSDK\SystemApplication\SystemApplication\SystemApplicationClient::factory($parameters);
     })->addClient('tat', function (array $parameters) {
         return \Barbondev\IRISSDK\SystemApplication\Tat\TatClient::factory($parameters);
     })->addClient('addressFinder', function (array $parameters) {
         return \Barbondev\IRISSDK\Utility\AddressFinder\AddressFinderClient::factory($parameters);
     })->addClient('document', function (array $parameters) {
         return \Barbondev\IRISSDK\Utility\Document\DocumentClient::factory($parameters);
     })->addClient('rentAffordability', function (array $parameters) {
         return \Barbondev\IRISSDK\Utility\RentAffordability\RentAffordabilityClient::factory($parameters);
     })->addClient('lookup', function (array $parameters) {
         return \Barbondev\IRISSDK\System\Lookup\LookupClient::factory($parameters);
     });
 }
 /**
  * Get Agent Scheme Number from different process
  *
  * @param SystemApplicationClient clientContext 
  * @param string linkRef
  * @return string
  */
 public function getAgentSchemeNumberByLinkRef(SystemApplicationClient $clientContext, $linkRef)
 {
     $response = $clientContext->getAgentBranch(array('linkRef' => $linkRef));
     return $response['agentSchemeNumber'];
 }