예제 #1
0
 /**
  * Creates or Updates a loan to the LOS
  * @param LoanApplication $application
  * @throws \Exception
  */
 public function upsertLoanToLos(LoanApplication $application)
 {
     try {
         $loId = null;
         $loanOfficer = $application->getLoanOfficer();
         if (isset($loanOfficer)) {
             $loId = $loanOfficer->getLosId();
         }
         $params = array('vendor' => $this->losConnection->getUsername(), 'cust' => $this->losConnection->getLicenseKey(), 'LO' => $loId, 'FNM' => $this->loanToFannieMae($application));
         $request = $this->client->post($this::BASE_SERVICE_URL . '/process1003.ashx', array('Content-Type' => 'text/plain'), $params);
         $factory = new PhpStreamRequestFactory();
         $stream = $factory->fromRequest($request);
         $data = '';
         // Read until the stream is closed
         while (!$stream->feof()) {
             // Read a line from the stream
             $data .= $stream->readLine();
         }
         if (!is_numeric($data)) {
             $params = array('vendor' => $this->losConnection->getUsername(), 'cust' => $this->losConnection->getLicenseKey(), 'LO' => '', 'FNM' => $this->loanToFannieMae($application));
             $request = $this->client->post($this::BASE_SERVICE_URL . '/process1003.ashx', array('Content-Type' => 'text/plain'), $params);
             $stream = $factory->fromRequest($request);
             $data = '';
             // Read until the stream is closed
             while (!$stream->feof()) {
                 // Read a line from the stream
                 $data .= $stream->readLine();
             }
         }
         if (is_numeric($data)) {
             $application->setLosId($data);
             $modifiedDate = new \DateTime();
             $modifiedDate->getTimestamp();
             $application->setLosModified($modifiedDate);
             $application->setLosLoanNumber($data);
             $application->setStatus(1);
             // lookup lo
             if (isset($loId)) {
                 $losLoanOfficer = $this->em->getRepository('SudouxMortgageBundle:LoanOfficer')->findOneBySiteAndLosId($application->getSite(), $loId);
                 $application->setLoanOfficer($losLoanOfficer);
             } else {
                 $application->setLoanOfficer(null);
             }
             $this->em->persist($application);
             $this->em->flush();
         } else {
             $e = new \Exception("Error adding loan - ID: " . $application->getId() . " Exception: " . $data);
             $this->logger->crit($e->getMessage());
             throw $e;
         }
     } catch (\Exception $e) {
         $this->logger->crit($e->getMessage());
         throw $e;
     }
     return $data;
 }
예제 #2
0
 /**
  * 
  * @param LosConnection $losConnection
  * @param \Twig_Environment $twig
  * @param ContainerInterface $container
  */
 public function __construct(LosConnection $losConnection, \Twig_Environment $twig, ContainerInterface $container)
 {
     $this->losConnection = $losConnection;
     $serviceUrl = $losConnection->getServiceUrl();
     if (!isset($serviceUrl)) {
         $serviceUrl = $this::DEFAULT_SERVICE_URL;
     }
     $this->client = new Client($serviceUrl, array('ssl.certificate_authority' => false));
     $this->twig = $twig;
     $this->em = $container->get('doctrine')->getEntityManager();
     $this->container = $container;
     $this->client->setDefaultOption('auth', array($this::USERNAME, $this::PASSWORD, 'Basic'));
     $this->user = array('AuthUser' => array('uri' => $losConnection->getHost(), 'username' => $losConnection->getUsername(), 'password' => $losConnection->getPassword()), 'lostype' => 0, 'apiKey' => $losConnection->getLicenseKey());
     $this->logger = $this->container->get('logger');
 }