from production.box import RecalledOrderStampBox
from production.treebuilder import BoxConfiguration

from ._BoxBuilder import BoxBuilder


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

    def build(self, config):
        # type: (BoxConfiguration) -> RecalledOrderStampBoxBuilder
        filter_tag = config.extra_config["FilterTag"] if "FilterTag" in config.extra_config else "done"
        ignore_prod_state_config = config.extra_config.get("IgnoreProdState")
        ignore_prod_state = ignore_prod_state_config.lower() == "true" if ignore_prod_state_config else False

        return RecalledOrderStampBox(
            config.name,
            config.sons,
            filter_tag,
            ignore_prod_state,
            self.get_logger(config)
        )
