def get_required_int_dict_property(properties: dict, key: str, required_error=None) -> int: """ Get the required dictionary value and cast it to type 'int' :param properties: dict data :param key: key :param required_error: error message if parameter is none :return: int object """ value = DictUtils.get_required_dict_property(properties, key, required_error) status, result = ParseUtils.try_parse_int(value) if status: return result else: raise InvalidParameterError( f'Parameter "{key}" could not be converted to a int')
def get_int_dict_property(properties: dict, key: str, default_value=None) -> int: """ Get the dictionary value and cast it to type 'int' :param properties: dict data :param key: key :param default_value: default value :return: int object """ value = DictUtils.get_dict_property(properties, key) if DictUtils.str_is_null_or_empty(value): value = default_value status, result = ParseUtils.try_parse_int(value) if status: return result else: raise InvalidParameterError( f'Parameter "{key}" could not be converted to a number')