|
| 1 | +# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved |
| 2 | + |
| 3 | +from dataclasses import dataclass |
| 4 | +from typing import Any, List, Mapping |
| 5 | + |
| 6 | +from lightspark.requests.requester import Requester |
| 7 | + |
| 8 | +from .Withdrawal import Withdrawal |
| 9 | +from .Withdrawal import from_json as Withdrawal_from_json |
| 10 | + |
| 11 | + |
| 12 | +@dataclass |
| 13 | +class WithdrawalRequestToWithdrawalsConnection: |
| 14 | + requester: Requester |
| 15 | + |
| 16 | + count: int |
| 17 | + """The total count of objects in this connection, using the current filters. It is different from the number of objects returned in the current page (in the `entities` field).""" |
| 18 | + |
| 19 | + entities: List[Withdrawal] |
| 20 | + """The withdrawals for the current page of this connection.""" |
| 21 | + |
| 22 | + def to_json(self) -> Mapping[str, Any]: |
| 23 | + return { |
| 24 | + "withdrawal_request_to_withdrawals_connection_count": self.count, |
| 25 | + "withdrawal_request_to_withdrawals_connection_entities": [ |
| 26 | + e.to_json() for e in self.entities |
| 27 | + ], |
| 28 | + } |
| 29 | + |
| 30 | + |
| 31 | +FRAGMENT = """ |
| 32 | +fragment WithdrawalRequestToWithdrawalsConnectionFragment on WithdrawalRequestToWithdrawalsConnection { |
| 33 | + __typename |
| 34 | + withdrawal_request_to_withdrawals_connection_count: count |
| 35 | + withdrawal_request_to_withdrawals_connection_entities: entities { |
| 36 | + id |
| 37 | + } |
| 38 | +} |
| 39 | +""" |
| 40 | + |
| 41 | + |
| 42 | +def from_json( |
| 43 | + requester: Requester, obj: Mapping[str, Any] |
| 44 | +) -> WithdrawalRequestToWithdrawalsConnection: |
| 45 | + return WithdrawalRequestToWithdrawalsConnection( |
| 46 | + requester=requester, |
| 47 | + count=obj["withdrawal_request_to_withdrawals_connection_count"], |
| 48 | + entities=list( |
| 49 | + map( |
| 50 | + # pylint: disable=unnecessary-lambda |
| 51 | + lambda e: Withdrawal_from_json(requester, e), |
| 52 | + obj["withdrawal_request_to_withdrawals_connection_entities"], |
| 53 | + ) |
| 54 | + ), |
| 55 | + ) |
0 commit comments