From e256a716965ca13a77d6805a842e7d07417bc48d Mon Sep 17 00:00:00 2001 From: _run Date: Thu, 20 Jun 2024 20:05:31 +0500 Subject: [PATCH] Added de_json classes for types --- telebot/types.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/telebot/types.py b/telebot/types.py index fe92a6ff0..5d69af0ff 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -10123,6 +10123,12 @@ class RevenueWithdrawalStatePending(RevenueWithdrawalState): def __init__(self, type, **kwargs): self.type: str = type + @classmethod + def de_json(cls, json_string): + if json_string is None: return None + obj = cls.check_json(json_string) + return cls(**obj) + class RevenueWithdrawalStateSucceeded(RevenueWithdrawalState): """ @@ -10148,6 +10154,13 @@ def __init__(self, type, date, url, **kwargs): self.date: int = date self.url: str = url + @classmethod + def de_json(cls, json_string): + if json_string is None: return None + obj = cls.check_json(json_string) + return cls(**obj) + + class RevenueWithdrawalStateFailed(RevenueWithdrawalState): """ @@ -10165,6 +10178,12 @@ class RevenueWithdrawalStateFailed(RevenueWithdrawalState): def __init__(self, type, **kwargs): self.type: str = type + @classmethod + def de_json(cls, json_string): + if json_string is None: return None + obj = cls.check_json(json_string) + return cls(**obj) + class TransactionPartner(JsonDeserializable): """ @@ -10214,6 +10233,15 @@ def __init__(self, type, withdrawal_state=None, **kwargs): self.type: str = type self.withdrawal_state: Optional[RevenueWithdrawalState] = withdrawal_state + @classmethod + def de_json(cls, json_string): + if json_string is None: return None + obj = cls.check_json(json_string) + if 'withdrawal_state' in obj: + obj['withdrawal_state'] = RevenueWithdrawalState.de_json(obj['withdrawal_state']) + return cls(**obj) + + class TransactionPartnerUser(TransactionPartner): """ @@ -10234,6 +10262,14 @@ class TransactionPartnerUser(TransactionPartner): def __init__(self, type, user, **kwargs): self.type: str = type self.user: User = user + + @classmethod + def de_json(cls, json_string): + if json_string is None: return None + obj = cls.check_json(json_string) + obj['user'] = User.de_json(obj['user']) + return cls(**obj) + class TransactionPartnerOther(TransactionPartner): """ @@ -10251,6 +10287,13 @@ class TransactionPartnerOther(TransactionPartner): def __init__(self, type, **kwargs): self.type: str = type + @classmethod + def de_json(cls, json_string): + if json_string is None: return None + obj = cls.check_json(json_string) + return cls(**obj) + + class StarTransaction(JsonDeserializable): """