Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix datetime deserialization #5

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lightspark/objects/Account.py
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> Account:
requester=requester,
typename="Account",
id=obj["account_id"],
created_at=obj["account_created_at"],
updated_at=obj["account_updated_at"],
created_at=datetime.fromisoformat(obj["account_created_at"]),
updated_at=datetime.fromisoformat(obj["account_updated_at"]),
name=obj["account_name"],
)
4 changes: 2 additions & 2 deletions lightspark/objects/ApiToken.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> ApiToken:
requester=requester,
typename="ApiToken",
id=obj["api_token_id"],
created_at=obj["api_token_created_at"],
updated_at=obj["api_token_updated_at"],
created_at=datetime.fromisoformat(obj["api_token_created_at"]),
updated_at=datetime.fromisoformat(obj["api_token_updated_at"]),
client_id=obj["api_token_client_id"],
name=obj["api_token_name"],
permissions=parse_enum_list(Permission, obj["api_token_permissions"]),
Expand Down
4 changes: 2 additions & 2 deletions lightspark/objects/Channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> Channel:
requester=requester,
typename="Channel",
id=obj["channel_id"],
created_at=obj["channel_created_at"],
updated_at=obj["channel_updated_at"],
created_at=datetime.fromisoformat(obj["channel_created_at"]),
updated_at=datetime.fromisoformat(obj["channel_updated_at"]),
funding_transaction_id=obj["channel_funding_transaction"]["id"]
if obj["channel_funding_transaction"]
else None,
Expand Down
14 changes: 11 additions & 3 deletions lightspark/objects/ChannelClosingTransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,18 @@ def from_json(
requester=requester,
typename="ChannelClosingTransaction",
id=obj["channel_closing_transaction_id"],
created_at=obj["channel_closing_transaction_created_at"],
updated_at=obj["channel_closing_transaction_updated_at"],
created_at=datetime.fromisoformat(
obj["channel_closing_transaction_created_at"]
),
updated_at=datetime.fromisoformat(
obj["channel_closing_transaction_updated_at"]
),
status=parse_enum(TransactionStatus, obj["channel_closing_transaction_status"]),
resolved_at=obj["channel_closing_transaction_resolved_at"],
resolved_at=datetime.fromisoformat(
obj["channel_closing_transaction_resolved_at"]
)
if obj["channel_closing_transaction_resolved_at"]
else None,
amount=CurrencyAmount_from_json(
requester, obj["channel_closing_transaction_amount"]
),
Expand Down
14 changes: 11 additions & 3 deletions lightspark/objects/ChannelOpeningTransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,18 @@ def from_json(
requester=requester,
typename="ChannelOpeningTransaction",
id=obj["channel_opening_transaction_id"],
created_at=obj["channel_opening_transaction_created_at"],
updated_at=obj["channel_opening_transaction_updated_at"],
created_at=datetime.fromisoformat(
obj["channel_opening_transaction_created_at"]
),
updated_at=datetime.fromisoformat(
obj["channel_opening_transaction_updated_at"]
),
status=parse_enum(TransactionStatus, obj["channel_opening_transaction_status"]),
resolved_at=obj["channel_opening_transaction_resolved_at"],
resolved_at=datetime.fromisoformat(
obj["channel_opening_transaction_resolved_at"]
)
if obj["channel_opening_transaction_resolved_at"]
else None,
amount=CurrencyAmount_from_json(
requester, obj["channel_opening_transaction_amount"]
),
Expand Down
8 changes: 5 additions & 3 deletions lightspark/objects/Deposit.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> Deposit:
requester=requester,
typename="Deposit",
id=obj["deposit_id"],
created_at=obj["deposit_created_at"],
updated_at=obj["deposit_updated_at"],
created_at=datetime.fromisoformat(obj["deposit_created_at"]),
updated_at=datetime.fromisoformat(obj["deposit_updated_at"]),
status=parse_enum(TransactionStatus, obj["deposit_status"]),
resolved_at=obj["deposit_resolved_at"],
resolved_at=datetime.fromisoformat(obj["deposit_resolved_at"])
if obj["deposit_resolved_at"]
else None,
amount=CurrencyAmount_from_json(requester, obj["deposit_amount"]),
transaction_hash=obj["deposit_transaction_hash"],
fees=CurrencyAmount_from_json(requester, obj["deposit_fees"])
Expand Down
4 changes: 2 additions & 2 deletions lightspark/objects/GraphNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> GraphNode:
requester=requester,
typename="GraphNode",
id=obj["graph_node_id"],
created_at=obj["graph_node_created_at"],
updated_at=obj["graph_node_updated_at"],
created_at=datetime.fromisoformat(obj["graph_node_created_at"]),
updated_at=datetime.fromisoformat(obj["graph_node_updated_at"]),
alias=obj["graph_node_alias"],
bitcoin_network=parse_enum(BitcoinNetwork, obj["graph_node_bitcoin_network"]),
color=obj["graph_node_color"],
Expand Down
4 changes: 2 additions & 2 deletions lightspark/objects/Hop.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> Hop:
requester=requester,
typename="Hop",
id=obj["hop_id"],
created_at=obj["hop_created_at"],
updated_at=obj["hop_updated_at"],
created_at=datetime.fromisoformat(obj["hop_created_at"]),
updated_at=datetime.fromisoformat(obj["hop_updated_at"]),
destination_id=obj["hop_destination"]["id"] if obj["hop_destination"] else None,
index=obj["hop_index"],
public_key=obj["hop_public_key"],
Expand Down
8 changes: 5 additions & 3 deletions lightspark/objects/IncomingPayment.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,12 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> IncomingPayment:
requester=requester,
typename="IncomingPayment",
id=obj["incoming_payment_id"],
created_at=obj["incoming_payment_created_at"],
updated_at=obj["incoming_payment_updated_at"],
created_at=datetime.fromisoformat(obj["incoming_payment_created_at"]),
updated_at=datetime.fromisoformat(obj["incoming_payment_updated_at"]),
status=parse_enum(TransactionStatus, obj["incoming_payment_status"]),
resolved_at=obj["incoming_payment_resolved_at"],
resolved_at=datetime.fromisoformat(obj["incoming_payment_resolved_at"])
if obj["incoming_payment_resolved_at"]
else None,
amount=CurrencyAmount_from_json(requester, obj["incoming_payment_amount"]),
transaction_hash=obj["incoming_payment_transaction_hash"],
destination_id=obj["incoming_payment_destination"]["id"],
Expand Down
8 changes: 5 additions & 3 deletions lightspark/objects/IncomingPaymentAttempt.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> IncomingPaymentAt
requester=requester,
typename="IncomingPaymentAttempt",
id=obj["incoming_payment_attempt_id"],
created_at=obj["incoming_payment_attempt_created_at"],
updated_at=obj["incoming_payment_attempt_updated_at"],
created_at=datetime.fromisoformat(obj["incoming_payment_attempt_created_at"]),
updated_at=datetime.fromisoformat(obj["incoming_payment_attempt_updated_at"]),
status=parse_enum(
IncomingPaymentAttemptStatus, obj["incoming_payment_attempt_status"]
),
resolved_at=obj["incoming_payment_attempt_resolved_at"],
resolved_at=datetime.fromisoformat(obj["incoming_payment_attempt_resolved_at"])
if obj["incoming_payment_attempt_resolved_at"]
else None,
amount=CurrencyAmount_from_json(
requester, obj["incoming_payment_attempt_amount"]
),
Expand Down
4 changes: 2 additions & 2 deletions lightspark/objects/Invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> Invoice:
requester=requester,
typename="Invoice",
id=obj["invoice_id"],
created_at=obj["invoice_created_at"],
updated_at=obj["invoice_updated_at"],
created_at=datetime.fromisoformat(obj["invoice_created_at"]),
updated_at=datetime.fromisoformat(obj["invoice_updated_at"]),
data=InvoiceData_from_json(requester, obj["invoice_data"]),
status=parse_enum(PaymentRequestStatus, obj["invoice_status"]),
amount_paid=CurrencyAmount_from_json(requester, obj["invoice_amount_paid"])
Expand Down
4 changes: 2 additions & 2 deletions lightspark/objects/InvoiceData.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> InvoiceData:
bitcoin_network=parse_enum(BitcoinNetwork, obj["invoice_data_bitcoin_network"]),
payment_hash=obj["invoice_data_payment_hash"],
amount=CurrencyAmount_from_json(requester, obj["invoice_data_amount"]),
created_at=obj["invoice_data_created_at"],
expires_at=obj["invoice_data_expires_at"],
created_at=datetime.fromisoformat(obj["invoice_data_created_at"]),
expires_at=datetime.fromisoformat(obj["invoice_data_expires_at"]),
memo=obj["invoice_data_memo"],
destination=Node_from_json(requester, obj["invoice_data_destination"]),
)
24 changes: 15 additions & 9 deletions lightspark/objects/LightningTransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,12 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightningTransact
requester=requester,
typename="IncomingPayment",
id=obj["incoming_payment_id"],
created_at=obj["incoming_payment_created_at"],
updated_at=obj["incoming_payment_updated_at"],
created_at=datetime.fromisoformat(obj["incoming_payment_created_at"]),
updated_at=datetime.fromisoformat(obj["incoming_payment_updated_at"]),
status=parse_enum(TransactionStatus, obj["incoming_payment_status"]),
resolved_at=obj["incoming_payment_resolved_at"],
resolved_at=datetime.fromisoformat(obj["incoming_payment_resolved_at"])
if obj["incoming_payment_resolved_at"]
else None,
amount=CurrencyAmount_from_json(requester, obj["incoming_payment_amount"]),
transaction_hash=obj["incoming_payment_transaction_hash"],
destination_id=obj["incoming_payment_destination"]["id"],
Expand All @@ -456,10 +458,12 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightningTransact
requester=requester,
typename="OutgoingPayment",
id=obj["outgoing_payment_id"],
created_at=obj["outgoing_payment_created_at"],
updated_at=obj["outgoing_payment_updated_at"],
created_at=datetime.fromisoformat(obj["outgoing_payment_created_at"]),
updated_at=datetime.fromisoformat(obj["outgoing_payment_updated_at"]),
status=parse_enum(TransactionStatus, obj["outgoing_payment_status"]),
resolved_at=obj["outgoing_payment_resolved_at"],
resolved_at=datetime.fromisoformat(obj["outgoing_payment_resolved_at"])
if obj["outgoing_payment_resolved_at"]
else None,
amount=CurrencyAmount_from_json(requester, obj["outgoing_payment_amount"]),
transaction_hash=obj["outgoing_payment_transaction_hash"],
origin_id=obj["outgoing_payment_origin"]["id"],
Expand Down Expand Up @@ -501,10 +505,12 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightningTransact
requester=requester,
typename="RoutingTransaction",
id=obj["routing_transaction_id"],
created_at=obj["routing_transaction_created_at"],
updated_at=obj["routing_transaction_updated_at"],
created_at=datetime.fromisoformat(obj["routing_transaction_created_at"]),
updated_at=datetime.fromisoformat(obj["routing_transaction_updated_at"]),
status=parse_enum(TransactionStatus, obj["routing_transaction_status"]),
resolved_at=obj["routing_transaction_resolved_at"],
resolved_at=datetime.fromisoformat(obj["routing_transaction_resolved_at"])
if obj["routing_transaction_resolved_at"]
else None,
amount=CurrencyAmount_from_json(
requester, obj["routing_transaction_amount"]
),
Expand Down
16 changes: 12 additions & 4 deletions lightspark/objects/LightsparkNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,12 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightsparkNode:
requester=requester,
typename="LightsparkNodeWithOSK",
id=obj["lightspark_node_with_o_s_k_id"],
created_at=obj["lightspark_node_with_o_s_k_created_at"],
updated_at=obj["lightspark_node_with_o_s_k_updated_at"],
created_at=datetime.fromisoformat(
obj["lightspark_node_with_o_s_k_created_at"]
),
updated_at=datetime.fromisoformat(
obj["lightspark_node_with_o_s_k_updated_at"]
),
alias=obj["lightspark_node_with_o_s_k_alias"],
bitcoin_network=parse_enum(
BitcoinNetwork, obj["lightspark_node_with_o_s_k_bitcoin_network"]
Expand Down Expand Up @@ -524,8 +528,12 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightsparkNode:
requester=requester,
typename="LightsparkNodeWithRemoteSigning",
id=obj["lightspark_node_with_remote_signing_id"],
created_at=obj["lightspark_node_with_remote_signing_created_at"],
updated_at=obj["lightspark_node_with_remote_signing_updated_at"],
created_at=datetime.fromisoformat(
obj["lightspark_node_with_remote_signing_created_at"]
),
updated_at=datetime.fromisoformat(
obj["lightspark_node_with_remote_signing_updated_at"]
),
alias=obj["lightspark_node_with_remote_signing_alias"],
bitcoin_network=parse_enum(
BitcoinNetwork,
Expand Down
12 changes: 7 additions & 5 deletions lightspark/objects/LightsparkNodeOwner.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightsparkNodeOwn
requester=requester,
typename="Account",
id=obj["account_id"],
created_at=obj["account_created_at"],
updated_at=obj["account_updated_at"],
created_at=datetime.fromisoformat(obj["account_created_at"]),
updated_at=datetime.fromisoformat(obj["account_updated_at"]),
name=obj["account_name"],
)
if obj["__typename"] == "Wallet":
Expand All @@ -104,9 +104,11 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightsparkNodeOwn
requester=requester,
typename="Wallet",
id=obj["wallet_id"],
created_at=obj["wallet_created_at"],
updated_at=obj["wallet_updated_at"],
last_login_at=obj["wallet_last_login_at"],
created_at=datetime.fromisoformat(obj["wallet_created_at"]),
updated_at=datetime.fromisoformat(obj["wallet_updated_at"]),
last_login_at=datetime.fromisoformat(obj["wallet_last_login_at"])
if obj["wallet_last_login_at"]
else None,
balances=Balances_from_json(requester, obj["wallet_balances"])
if obj["wallet_balances"]
else None,
Expand Down
4 changes: 2 additions & 2 deletions lightspark/objects/LightsparkNodeWithOSK.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,8 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightsparkNodeWit
requester=requester,
typename="LightsparkNodeWithOSK",
id=obj["lightspark_node_with_o_s_k_id"],
created_at=obj["lightspark_node_with_o_s_k_created_at"],
updated_at=obj["lightspark_node_with_o_s_k_updated_at"],
created_at=datetime.fromisoformat(obj["lightspark_node_with_o_s_k_created_at"]),
updated_at=datetime.fromisoformat(obj["lightspark_node_with_o_s_k_updated_at"]),
alias=obj["lightspark_node_with_o_s_k_alias"],
bitcoin_network=parse_enum(
BitcoinNetwork, obj["lightspark_node_with_o_s_k_bitcoin_network"]
Expand Down
8 changes: 6 additions & 2 deletions lightspark/objects/LightsparkNodeWithRemoteSigning.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,12 @@ def from_json(
requester=requester,
typename="LightsparkNodeWithRemoteSigning",
id=obj["lightspark_node_with_remote_signing_id"],
created_at=obj["lightspark_node_with_remote_signing_created_at"],
updated_at=obj["lightspark_node_with_remote_signing_updated_at"],
created_at=datetime.fromisoformat(
obj["lightspark_node_with_remote_signing_created_at"]
),
updated_at=datetime.fromisoformat(
obj["lightspark_node_with_remote_signing_updated_at"]
),
alias=obj["lightspark_node_with_remote_signing_alias"],
bitcoin_network=parse_enum(
BitcoinNetwork, obj["lightspark_node_with_remote_signing_bitcoin_network"]
Expand Down
20 changes: 14 additions & 6 deletions lightspark/objects/Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> Node:
requester=requester,
typename="GraphNode",
id=obj["graph_node_id"],
created_at=obj["graph_node_created_at"],
updated_at=obj["graph_node_updated_at"],
created_at=datetime.fromisoformat(obj["graph_node_created_at"]),
updated_at=datetime.fromisoformat(obj["graph_node_updated_at"]),
alias=obj["graph_node_alias"],
bitcoin_network=parse_enum(
BitcoinNetwork, obj["graph_node_bitcoin_network"]
Expand All @@ -333,8 +333,12 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> Node:
requester=requester,
typename="LightsparkNodeWithOSK",
id=obj["lightspark_node_with_o_s_k_id"],
created_at=obj["lightspark_node_with_o_s_k_created_at"],
updated_at=obj["lightspark_node_with_o_s_k_updated_at"],
created_at=datetime.fromisoformat(
obj["lightspark_node_with_o_s_k_created_at"]
),
updated_at=datetime.fromisoformat(
obj["lightspark_node_with_o_s_k_updated_at"]
),
alias=obj["lightspark_node_with_o_s_k_alias"],
bitcoin_network=parse_enum(
BitcoinNetwork, obj["lightspark_node_with_o_s_k_bitcoin_network"]
Expand Down Expand Up @@ -392,8 +396,12 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> Node:
requester=requester,
typename="LightsparkNodeWithRemoteSigning",
id=obj["lightspark_node_with_remote_signing_id"],
created_at=obj["lightspark_node_with_remote_signing_created_at"],
updated_at=obj["lightspark_node_with_remote_signing_updated_at"],
created_at=datetime.fromisoformat(
obj["lightspark_node_with_remote_signing_created_at"]
),
updated_at=datetime.fromisoformat(
obj["lightspark_node_with_remote_signing_updated_at"]
),
alias=obj["lightspark_node_with_remote_signing_alias"],
bitcoin_network=parse_enum(
BitcoinNetwork,
Expand Down
Loading