from production.box import SaleTypeFilterBox
from production.treebuilder import BoxConfiguration

from ._BoxBuilder import BoxBuilder


class SaleTypeFilterBoxBuilder(BoxBuilder):
    def __init__(self, loggers):
        super(SaleTypeFilterBoxBuilder, self).__init__(loggers)

    def build(
        self,       # type: SaleTypeFilterBoxBuilder
        config,     # type: BoxConfiguration
    ):
        # type: (...) -> SaleTypeFilterBox

        return SaleTypeFilterBox(
            name=config.name,
            sons=config.sons,
            sale_types=self.get_extra(config, "AllowedSaleTypes", None),
            logger=self.get_logger(config),
        )
