Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function getProducts($rentGuaranteeOfferingType, $propertyLettingType)
 {
     $parameters = array('rentGuaranteeOfferingType' => (int) $rentGuaranteeOfferingType, 'propertyLettingType' => (int) $propertyLettingType);
     // Always merge context parameters as this cache is unique per agent branch
     $cacheKey = $this->buildCacheKey(array_merge($parameters, $this->context->getParameters()));
     if ($this->cache->has($cacheKey)) {
         return $this->cache->get($cacheKey);
     }
     /** @var \Guzzle\Common\Collection $products */
     $products = $this->context->getProductClient()->getProducts($parameters);
     $this->cache->set($cacheKey, $products, 500);
     // Longer TTL for products
     return $products;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function getProductPrice($agentSchemeNumber, $productId, $propertyLetType, $rentGuaranteeOfferingType, $shareOfRent, $policyLengthInMonths)
 {
     $parameters = array('productId' => (int) $productId, 'agentSchemeNumber' => (int) $agentSchemeNumber, 'propertyLetType' => (int) $propertyLetType, 'rentGuaranteeOfferingType' => (int) $rentGuaranteeOfferingType, 'shareOfRent' => (double) $shareOfRent, 'policyLengthInMonths' => (int) ($policyLengthInMonths ?: 0), 'guarantorSequenceNumber' => (int) 0, 'isRenewal' => (int) false);
     // Always merge context parameters as this cache is unique per agent branch
     $cacheKey = $this->buildCacheKey(array_merge($parameters, $this->context->getParameters()));
     if ($this->cache->has($cacheKey)) {
         return $this->cache->get($cacheKey);
     }
     /** @var \Barbondev\IRISSDK\IndividualApplication\Product\Model\ProductPrice $productPrice */
     try {
         $productPrice = $this->context->getProductClient()->getProductPrice($parameters);
     } catch (NotFoundException $e) {
         throw new ProductPriceNotFoundException(sprintf('Product price not found using parameters: ', print_r($parameters, true)));
     }
     $this->cache->set($cacheKey, $productPrice, 120);
     // Short TTL for this cache
     return $productPrice;
 }