/** * @author WN, EB * @param string $email * @param Location $location * @param OrderEntity $orderEntity * @param ProductsEntity $productsEntity * @param ApplicantEntity $applicantEntity * @param User $requester * @return Application * @throws Exception */ public function initialiseAssistedApplication($email, Location $location, OrderEntity $orderEntity, ProductsEntity $productsEntity, ApplicantEntity $applicantEntity, User $requester) { $applicationParams = ['email' => $email, 'installation' => $location->installation->ext_id, 'order' => $orderEntity->toArray(), 'products' => $productsEntity->toArray(true), 'fulfilment' => ['method' => 'collection', 'location' => $location->reference], 'applicant' => $applicantEntity->toArray()]; $application = ApplicationEntity::make($applicationParams); $this->logInfo('IniAssistedApp: Application reference[' . $orderEntity->getReference() . '] ready to be initialised', ['application' => $application->toArray()]); try { $newApplication = $this->applicationGateway->initialiseAssistedApplication($application, $location->installation->merchant->token); $this->logInfo('IniAssistedApp: Application reference[' . $orderEntity->getReference() . '] successfully initialised at provider with ID[' . $newApplication->getId() . ']'); $app = $this->createNewLocal($newApplication, $location->installation->id, $requester->id, $location->id); $this->logInfo('IniAssistedApp: Application reference[' . $orderEntity->getReference() . '] successfully stored in the local system'); return $app; } catch (\Exception $e) { $this->logError('IniAssistedApp: ' . $e->getMessage()); throw new Exception($e->getMessage()); } }
/** * @author WN * @param int $id * @param string $token * @return ApplicationEntity * @throws SdkException */ public function getApplication($id, $token) { return ApplicationEntity::make($this->fetchDocument('/v4/applications/' . $id, $token, 'Application')); }