# -*- coding: utf-8 -*-
import json

import sysactions
from actions.util import get_ruptured_products_from_remote_order

from .. import logger


@sysactions.action
def get_ruptured_products(pos_id):
    # type: (str) -> str

    try:
        products = {
            "enabledProducts": [],
            "disabledProducts": get_ruptured_products_from_remote_order()
        }

        return json.dumps(products)

    except Exception as e:
        logger.exception('[get_ruptured_products] Exception {}'.format(e))
        sysactions.show_messagebox(pos_id, "$RUPTURE_ERROR", "$INFORMATION")
