from typing import (
    Any,
    List,
)

from production.command import CommandType
from production.box import ViewBox
from production.model.request import ChangeProdStateRequest

from ._CommandProcessor import CommandProcessor


class SetOrderStateProcessor(CommandProcessor):
    def __init__(self, view_boxes):
        # type: (List[ViewBox]) -> None

        super(SetOrderStateProcessor, self).__init__(view_boxes)

    def parse_data(
        self,        # type: SetOrderStateProcessor
        data,        # type: List
        event_type,  # type: Any
    ):
        parts = data.split('\0')
        return ChangeProdStateRequest(
            order_id=parts[0],
            view=parts[1],
            state=parts[2],
            pickup_info=parts[3],
        )

    def get_command_type(self):
        return CommandType.change_prod_state
