88
99from .CurrencyAmount import CurrencyAmount
1010from .CurrencyAmount import from_json as CurrencyAmount_from_json
11+ from .Entity import Entity
1112
1213
1314@dataclass
14- class ChannelSnapshot :
15+ class ChannelSnapshot ( Entity ) :
1516 requester : Requester
1617
17- channel_id : str
18+ id : str
19+ """The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string."""
1820
19- timestamp : datetime
21+ created_at : datetime
22+ """The date and time when the entity was first created."""
23+
24+ updated_at : datetime
25+ """The date and time when the entity was last updated."""
2026
2127 local_balance : Optional [CurrencyAmount ]
2228
2329 local_unsettled_balance : Optional [CurrencyAmount ]
2430
25- local_channel_reserve : Optional [CurrencyAmount ]
26-
2731 remote_balance : Optional [CurrencyAmount ]
2832
2933 remote_unsettled_balance : Optional [CurrencyAmount ]
3034
35+ channel_id : str
36+
37+ local_channel_reserve : Optional [CurrencyAmount ]
38+
39+ timestamp : datetime
40+ """The timestamp that was used to query the snapshot of the channel"""
41+ typename : str
42+
3143 def to_json (self ) -> Mapping [str , Any ]:
3244 return {
33- "channel_snapshot_channel" : {"id" : self .channel_id },
34- "channel_snapshot_timestamp" : self .timestamp .isoformat (),
45+ "__typename" : "ChannelSnapshot" ,
46+ "channel_snapshot_id" : self .id ,
47+ "channel_snapshot_created_at" : self .created_at .isoformat (),
48+ "channel_snapshot_updated_at" : self .updated_at .isoformat (),
3549 "channel_snapshot_local_balance" : self .local_balance .to_json ()
3650 if self .local_balance
3751 else None ,
3852 "channel_snapshot_local_unsettled_balance" : self .local_unsettled_balance .to_json ()
3953 if self .local_unsettled_balance
4054 else None ,
41- "channel_snapshot_local_channel_reserve" : self .local_channel_reserve .to_json ()
42- if self .local_channel_reserve
43- else None ,
4455 "channel_snapshot_remote_balance" : self .remote_balance .to_json ()
4556 if self .remote_balance
4657 else None ,
4758 "channel_snapshot_remote_unsettled_balance" : self .remote_unsettled_balance .to_json ()
4859 if self .remote_unsettled_balance
4960 else None ,
61+ "channel_snapshot_channel" : {"id" : self .channel_id },
62+ "channel_snapshot_local_channel_reserve" : self .local_channel_reserve .to_json ()
63+ if self .local_channel_reserve
64+ else None ,
65+ "channel_snapshot_timestamp" : self .timestamp .isoformat (),
5066 }
5167
5268
5369FRAGMENT = """
5470fragment ChannelSnapshotFragment on ChannelSnapshot {
5571 __typename
56- channel_snapshot_channel: channel {
57- id
58- }
59- channel_snapshot_timestamp: timestamp
72+ channel_snapshot_id: id
73+ channel_snapshot_created_at: created_at
74+ channel_snapshot_updated_at: updated_at
6075 channel_snapshot_local_balance: local_balance {
6176 __typename
6277 currency_amount_original_value: original_value
@@ -73,39 +88,45 @@ def to_json(self) -> Mapping[str, Any]:
7388 currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
7489 currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
7590 }
76- channel_snapshot_local_channel_reserve: local_channel_reserve {
91+ channel_snapshot_remote_balance: remote_balance {
7792 __typename
7893 currency_amount_original_value: original_value
7994 currency_amount_original_unit: original_unit
8095 currency_amount_preferred_currency_unit: preferred_currency_unit
8196 currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
8297 currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
8398 }
84- channel_snapshot_remote_balance: remote_balance {
99+ channel_snapshot_remote_unsettled_balance: remote_unsettled_balance {
85100 __typename
86101 currency_amount_original_value: original_value
87102 currency_amount_original_unit: original_unit
88103 currency_amount_preferred_currency_unit: preferred_currency_unit
89104 currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
90105 currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
91106 }
92- channel_snapshot_remote_unsettled_balance: remote_unsettled_balance {
107+ channel_snapshot_channel: channel {
108+ id
109+ }
110+ channel_snapshot_local_channel_reserve: local_channel_reserve {
93111 __typename
94112 currency_amount_original_value: original_value
95113 currency_amount_original_unit: original_unit
96114 currency_amount_preferred_currency_unit: preferred_currency_unit
97115 currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
98116 currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
99117 }
118+ channel_snapshot_timestamp: timestamp
100119}
101120"""
102121
103122
104123def from_json (requester : Requester , obj : Mapping [str , Any ]) -> ChannelSnapshot :
105124 return ChannelSnapshot (
106125 requester = requester ,
107- channel_id = obj ["channel_snapshot_channel" ]["id" ],
108- timestamp = datetime .fromisoformat (obj ["channel_snapshot_timestamp" ]),
126+ typename = "ChannelSnapshot" ,
127+ id = obj ["channel_snapshot_id" ],
128+ created_at = datetime .fromisoformat (obj ["channel_snapshot_created_at" ]),
129+ updated_at = datetime .fromisoformat (obj ["channel_snapshot_updated_at" ]),
109130 local_balance = CurrencyAmount_from_json (
110131 requester , obj ["channel_snapshot_local_balance" ]
111132 )
@@ -116,11 +137,6 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> ChannelSnapshot:
116137 )
117138 if obj ["channel_snapshot_local_unsettled_balance" ]
118139 else None ,
119- local_channel_reserve = CurrencyAmount_from_json (
120- requester , obj ["channel_snapshot_local_channel_reserve" ]
121- )
122- if obj ["channel_snapshot_local_channel_reserve" ]
123- else None ,
124140 remote_balance = CurrencyAmount_from_json (
125141 requester , obj ["channel_snapshot_remote_balance" ]
126142 )
@@ -131,4 +147,11 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> ChannelSnapshot:
131147 )
132148 if obj ["channel_snapshot_remote_unsettled_balance" ]
133149 else None ,
150+ channel_id = obj ["channel_snapshot_channel" ]["id" ],
151+ local_channel_reserve = CurrencyAmount_from_json (
152+ requester , obj ["channel_snapshot_local_channel_reserve" ]
153+ )
154+ if obj ["channel_snapshot_local_channel_reserve" ]
155+ else None ,
156+ timestamp = datetime .fromisoformat (obj ["channel_snapshot_timestamp" ]),
134157 )
0 commit comments