|
| 1 | +# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved |
| 2 | + |
| 3 | +from dataclasses import dataclass |
| 4 | +from typing import Any, Mapping, Optional |
| 5 | + |
| 6 | +from lightspark.requests.requester import Requester |
| 7 | + |
| 8 | +from .CurrencyAmount import CurrencyAmount |
| 9 | +from .CurrencyAmount import from_json as CurrencyAmount_from_json |
| 10 | + |
| 11 | + |
| 12 | +@dataclass |
| 13 | +class ChannelSnapshot: |
| 14 | + requester: Requester |
| 15 | + |
| 16 | + local_balance: Optional[CurrencyAmount] |
| 17 | + |
| 18 | + local_unsettled_balance: Optional[CurrencyAmount] |
| 19 | + |
| 20 | + local_channel_reserve: Optional[CurrencyAmount] |
| 21 | + |
| 22 | + |
| 23 | +FRAGMENT = """ |
| 24 | +fragment ChannelSnapshotFragment on ChannelSnapshot { |
| 25 | + __typename |
| 26 | + channel_snapshot_local_balance: local_balance { |
| 27 | + __typename |
| 28 | + currency_amount_original_value: original_value |
| 29 | + currency_amount_original_unit: original_unit |
| 30 | + currency_amount_preferred_currency_unit: preferred_currency_unit |
| 31 | + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded |
| 32 | + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx |
| 33 | + } |
| 34 | + channel_snapshot_local_unsettled_balance: local_unsettled_balance { |
| 35 | + __typename |
| 36 | + currency_amount_original_value: original_value |
| 37 | + currency_amount_original_unit: original_unit |
| 38 | + currency_amount_preferred_currency_unit: preferred_currency_unit |
| 39 | + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded |
| 40 | + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx |
| 41 | + } |
| 42 | + channel_snapshot_local_channel_reserve: local_channel_reserve { |
| 43 | + __typename |
| 44 | + currency_amount_original_value: original_value |
| 45 | + currency_amount_original_unit: original_unit |
| 46 | + currency_amount_preferred_currency_unit: preferred_currency_unit |
| 47 | + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded |
| 48 | + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx |
| 49 | + } |
| 50 | +} |
| 51 | +""" |
| 52 | + |
| 53 | + |
| 54 | +def from_json(requester: Requester, obj: Mapping[str, Any]) -> ChannelSnapshot: |
| 55 | + return ChannelSnapshot( |
| 56 | + requester=requester, |
| 57 | + local_balance=CurrencyAmount_from_json( |
| 58 | + requester, obj["channel_snapshot_local_balance"] |
| 59 | + ) |
| 60 | + if obj["channel_snapshot_local_balance"] |
| 61 | + else None, |
| 62 | + local_unsettled_balance=CurrencyAmount_from_json( |
| 63 | + requester, obj["channel_snapshot_local_unsettled_balance"] |
| 64 | + ) |
| 65 | + if obj["channel_snapshot_local_unsettled_balance"] |
| 66 | + else None, |
| 67 | + local_channel_reserve=CurrencyAmount_from_json( |
| 68 | + requester, obj["channel_snapshot_local_channel_reserve"] |
| 69 | + ) |
| 70 | + if obj["channel_snapshot_local_channel_reserve"] |
| 71 | + else None, |
| 72 | + ) |
0 commit comments