class CodedError(Exception):
    def __init__(
        self,
        code,           # type: int
        message,        # type: str
    ):
        # type: (...) -> None

        self.code = code
        self.message = message


class UpdateItemsError(object):
    INVALID_JSON = CodedError(
        code=-1,
        message="data must be a valid json",
    )

    NO_USER_ID = CodedError(
        code=-2,
        message="input json must contain a user_id field",
    )

    NO_ENABLED = CodedError(
        code=-3,
        message="input json must contain an enabled field",
    )

    NO_DISABLED = CodedError(
        code=-4,
        message="input json must contain a disabled field",
    )

    ENABLED_NOT_A_LIST = CodedError(
        code=-5,
        message="enabled field must be a list of integer part codes",
    )

    DISABLED_NOT_A_LIST = CodedError(
        code=-6,
        message="disabled field must be a list of integer part codes",
    )

    ENABLED_NOT_A_LIST_OF_INT = CodedError(
        code=-7,
        message="enabled field must be a list of integer part codes",
    )

    DISABLED_NOT_A_LIST_OF_INT = CodedError(
        code=-8,
        message="enabled field must be a list of integer part codes",
    )

    INVALID_PART_CODE = CodedError(
        code=-9,
        message="",
    )


class RuptureItemsByQuantityError(object):

    INVALID_NUMBER_OF_PARAMS = CodedError(
        code=-1,
        message="Invalid numbers of parameters",
    )

    INVALID_JSON = CodedError(
        code=-2,
        message="Data must be a valid JSON",
    )

    NO_USER_ID = CodedError(
        code=-3,
        message="User ID must not be empty",
    )

    NOT_INTEGER_USER_ID = CodedError(
        code=-4,
        message="User ID must be integer",
    )

    UPDATE_REQUEST_ITEMS_NOT_A_DICT = CodedError(
        code=-5,
        message="Items details must be a dict",
    )

    SET_AND_UNSET_DOES_NOT_EXISTS = CodedError(
        code=-6,
        message="One of set or unset must exists",
    )

    SET_NOT_A_LIST = CodedError(
        code=-7,
        message="Add to rupture by quantity field must be a list of dict",
    )

    UNSET_NOT_A_LIST = CodedError(
        code=-8,
        message="Remove to rupture by quantity field must be a list of dict",
    )

    SET_ITEMS_NOT_DICTS = CodedError(
        code=-9,
        message="Items of set are not all dicts",
    )

    SET_WITHOUT_PRODUCT_CODE = CodedError(
        code=-10,
        message="product_code must be in set items",
    )

    SET_WITHOUT_PRODUCT_QUANTITY = CodedError(
        code=-11,
        message="product_quantity must be in set items",
    )

    UNSET_ITEMS_NOT_DICTS = CodedError(
        code=-12,
        message="Items of unset are not all dicts",
    )

    UNSET_WITHOUT_PRODUCT_CODE = CodedError(
        code=-13,
        message="product_code must be in set items",
    )

    UNSET_WITHOUT_PRODUCT_QUANTITY = CodedError(
        code=-14,
        message="product_quantity must be in set items",
    )
