/**
  * @param string $extId
  * @param string $productGroup
  * @param string $token
  * @return array
  * @author SL
  */
 public function getProductsInGroup($extId, $productGroup, $token)
 {
     $response = $this->fetchDocument('/v4/installations/' . $extId . '/product-groups/' . $productGroup . '/products', $token, 'getProductsByGroup');
     $products = [];
     foreach ($response as $product) {
         $products[] = ProductEntity::make($product);
     }
     return $products;
 }
 /**
  * @author EB, WN
  * @param array $products
  * @return $this
  */
 public function setProducts(array $products)
 {
     $this->products = [];
     foreach ($products as $product) {
         if (is_array($product)) {
             $this->addProduct(ProductEntity::make($product));
             continue;
         }
         if ($product instanceof ProductEntity) {
             $this->addProduct($product);
         }
     }
     return $this;
 }
 /**
  * @authpr EB
  * @param string $id
  * @param Installation $installation
  * @param ProductEntity $product
  * @param float $min
  * @param float $max
  * @return ProductLimit
  * @throws \Exception
  */
 private function storeProductLimit($id, Installation $installation, ProductEntity $product, $min, $max)
 {
     try {
         $limit = ProductLimit::where(['product' => $id, 'installation_id' => $installation->id])->first();
         if ($limit == null) {
             throw new ModelNotFoundException();
         }
     } catch (\Exception $e) {
         $limit = new ProductLimit();
     }
     $limit->installation_id = $installation->id;
     $limit->product = $product->getId();
     $limit->min_deposit_percentage = $min;
     $limit->max_deposit_percentage = $max;
     if (!$limit->save()) {
         throw new \Exception('Problem saving limit [' . $id . '] for Installation [' . $installation->id . ']');
     }
     return $limit;
 }