/**
  * @param string $extId
  * @param string $token
  * @return GroupEntity
  */
 public function getProductGroupsWithProducts($extId, $token)
 {
     $response = $this->fetchDocument('/v4/installations/' . $extId . '/product-groups?with=products', $token, 'listGroupsWithProducts');
     foreach ($response as &$group) {
         foreach ($group['products'] as &$product) {
             $product = ProductEntity::make($product);
         }
         $group = GroupEntity::make($group);
     }
     return $response;
 }
 /**
  * @author EB, SL
  *
  * @param int $id
  * @return GroupEntity
  * @throws RedirectException
  */
 private function fetchProducts($id)
 {
     try {
         $installation = Installation::findOrFail($id);
         return $this->productGateway->getProductGroupsWithProducts($installation->ext_id, $installation->merchant->token);
     } catch (\Exception $e) {
         if ($e->getMessage() !== 'Products are empty') {
             throw $this->redirectWithException(URL::previous(), $e->getMessage(), $e);
         }
         return GroupEntity::make([]);
     }
 }