from api.order import get_order_service
from application.domain import OrderManager, SaleLine  # noqa


class MsgBusOrderManager(OrderManager):

    def recall_order(self, pos_id, order_id):
        order_service = get_order_service(pos_id=pos_id)
        order_service.recall_order(order_id=order_id)

    def store_order(self, pos_id):
        order_service = get_order_service(pos_id=pos_id)
        order_service.store_order()

    def get_current_order_state(self, pos_id):
        order_service = get_order_service(pos_id=pos_id)

        order_picture = order_service.get_order_picture()
        if order_picture is not None:
            return order_picture.get("state")
        return None
