| 123456789101112131415161718192021222324252627282930313233343536373839404142 | 
							- import typing
 
- import collections.abc
 
- from .directory_image import directory_image
 
- from .product import product
 
- from .exception import not_ready_exception
 
- class product_response:
 
-     def __init__(self, images: directory_image) -> None:
 
-         self.__images = images
 
-     @property
 
-     def images(self) -> directory_image:    
 
-         return self.__images
 
-     def single(self, target: product) -> dict:
 
-         if not target.ready:
 
-             raise not_ready_exception(target)
 
-         covers = directory_image.server_path() + "/"
 
-         return {
 
-             "name": target.name,
 
-             "description": target.description,
 
-             "author": target.author,
 
-             "image": covers + self.images.get_full_name(target),
 
-             "thumbnail": covers + self.images.get_thumbnail_name(target),
 
-             "stock_count": target.stock_count,
 
-             "on_stock": target.on_stock,
 
-             "barcode": target.barcode
 
-         }
 
-     def collection(self, targets: typing.Iterable[product]) -> list:
 
-         result = list() 
 
-         for count in targets:
 
-             if not isinstance(count, product):
 
-                 raise TypeError("Product list must contain only products.")
 
-             result.append(self.single(count))
 
-         return result
 
 
  |