from __future__ import annotations from enum import IntEnum class ViberErrorCode(IntEnum): OK = 0 INVALID_URL = 1 INVALID_AUTH_TOKEN = 2 BAD_DATA = 3 MISSING_DATA = 4 RECEIVER_NOT_REGISTERED = 5 RECEIVER_NOT_SUBSCRIBED = 6 PUBLIC_ACCOUNT_BLOCKED = 7 PUBLIC_ACCOUNT_NOT_FOUND = 8 PUBLIC_ACCOUNT_SUSPENDED = 9 WEBHOOK_NOT_SET = 10 RECEIVER_NO_SUITABLE_DEVICE = 11 TOO_MANY_REQUESTS = 12 API_VERSION_NOT_SUPPORTED = 13 INCOMPATIBLE_WITH_VERSION = 14 PUBLIC_ACCOUNT_NOT_AUTHORIZED = 15 INCHAT_REPLY_MESSAGE_NOT_ALLOWED = 16 PUBLIC_ACCOUNT_IS_NOT_INLINE = 17 NO_PUBLIC_CHAT = 18 CANNOT_SEND_BROADCAST = 19 BROADCAST_NOT_ALLOWED = 20 RATE_LIMIT_EXCEEDED = 49 GENERAL = 50 @classmethod def is_retryable(cls, code: int) -> bool: return code in ( cls.TOO_MANY_REQUESTS, cls.RATE_LIMIT_EXCEEDED, cls.GENERAL, ) @classmethod def is_auth_error(cls, code: int) -> bool: return code in ( cls.INVALID_AUTH_TOKEN, cls.PUBLIC_ACCOUNT_NOT_AUTHORIZED, )