diff --git a/lightspark/__init__.py b/lightspark/__init__.py index 55b50cc..c1991ad 100644 --- a/lightspark/__init__.py +++ b/lightspark/__init__.py @@ -3,19 +3,20 @@ import lightspark.utils from lightspark.lightspark_client import * from lightspark.objects.Account import Account -from lightspark.objects.AccountToApiTokensConnection import AccountToApiTokensConnection -from lightspark.objects.AccountToChannelsConnection import AccountToChannelsConnection -from lightspark.objects.AccountToNodesConnection import AccountToNodesConnection -from lightspark.objects.AccountToPaymentRequestsConnection import ( - AccountToPaymentRequestsConnection, -) -from lightspark.objects.AccountToTransactionsConnection import ( - AccountToTransactionsConnection, -) -from lightspark.objects.AccountToWalletsConnection import AccountToWalletsConnection -from lightspark.objects.AccountToWithdrawalRequestsConnection import ( - AccountToWithdrawalRequestsConnection, -) +from lightspark.objects.AccountToApiTokensConnection import \ + AccountToApiTokensConnection +from lightspark.objects.AccountToChannelsConnection import \ + AccountToChannelsConnection +from lightspark.objects.AccountToNodesConnection import \ + AccountToNodesConnection +from lightspark.objects.AccountToPaymentRequestsConnection import \ + AccountToPaymentRequestsConnection +from lightspark.objects.AccountToTransactionsConnection import \ + AccountToTransactionsConnection +from lightspark.objects.AccountToWalletsConnection import \ + AccountToWalletsConnection +from lightspark.objects.AccountToWithdrawalRequestsConnection import \ + AccountToWithdrawalRequestsConnection from lightspark.objects.ApiToken import ApiToken from lightspark.objects.AuditLogActor import AuditLogActor from lightspark.objects.Balances import Balances @@ -24,51 +25,60 @@ from lightspark.objects.CancelInvoiceInput import CancelInvoiceInput from lightspark.objects.CancelInvoiceOutput import CancelInvoiceOutput from lightspark.objects.Channel import Channel -from lightspark.objects.ChannelClosingTransaction import ChannelClosingTransaction +from lightspark.objects.ChannelClosingTransaction import \ + ChannelClosingTransaction from lightspark.objects.ChannelFees import ChannelFees -from lightspark.objects.ChannelOpeningTransaction import ChannelOpeningTransaction +from lightspark.objects.ChannelOpeningTransaction import \ + ChannelOpeningTransaction from lightspark.objects.ChannelSnapshot import ChannelSnapshot from lightspark.objects.ChannelStatus import ChannelStatus -from lightspark.objects.ChannelToTransactionsConnection import ( - ChannelToTransactionsConnection, -) +from lightspark.objects.ChannelToTransactionsConnection import \ + ChannelToTransactionsConnection from lightspark.objects.ClaimUmaInvitationInput import ClaimUmaInvitationInput -from lightspark.objects.ClaimUmaInvitationOutput import ClaimUmaInvitationOutput -from lightspark.objects.ClaimUmaInvitationWithIncentivesInput import ( - ClaimUmaInvitationWithIncentivesInput, -) -from lightspark.objects.ClaimUmaInvitationWithIncentivesOutput import ( - ClaimUmaInvitationWithIncentivesOutput, -) +from lightspark.objects.ClaimUmaInvitationOutput import \ + ClaimUmaInvitationOutput +from lightspark.objects.ClaimUmaInvitationWithIncentivesInput import \ + ClaimUmaInvitationWithIncentivesInput +from lightspark.objects.ClaimUmaInvitationWithIncentivesOutput import \ + ClaimUmaInvitationWithIncentivesOutput from lightspark.objects.ComplianceProvider import ComplianceProvider from lightspark.objects.Connection import Connection from lightspark.objects.CreateApiTokenInput import CreateApiTokenInput from lightspark.objects.CreateApiTokenOutput import CreateApiTokenOutput -from lightspark.objects.CreateInvitationWithIncentivesInput import ( - CreateInvitationWithIncentivesInput, -) -from lightspark.objects.CreateInvitationWithIncentivesOutput import ( - CreateInvitationWithIncentivesOutput, -) +from lightspark.objects.CreateInvitationWithIncentivesInput import \ + CreateInvitationWithIncentivesInput +from lightspark.objects.CreateInvitationWithIncentivesOutput import \ + CreateInvitationWithIncentivesOutput from lightspark.objects.CreateInvoiceInput import CreateInvoiceInput from lightspark.objects.CreateInvoiceOutput import CreateInvoiceOutput from lightspark.objects.CreateLnurlInvoiceInput import CreateLnurlInvoiceInput -from lightspark.objects.CreateNodeWalletAddressInput import CreateNodeWalletAddressInput -from lightspark.objects.CreateNodeWalletAddressOutput import ( - CreateNodeWalletAddressOutput, -) -from lightspark.objects.CreateTestModeInvoiceInput import CreateTestModeInvoiceInput -from lightspark.objects.CreateTestModeInvoiceOutput import CreateTestModeInvoiceOutput -from lightspark.objects.CreateTestModePaymentInput import CreateTestModePaymentInput -from lightspark.objects.CreateTestModePaymentoutput import CreateTestModePaymentoutput -from lightspark.objects.CreateUmaInvitationInput import CreateUmaInvitationInput -from lightspark.objects.CreateUmaInvitationOutput import CreateUmaInvitationOutput +from lightspark.objects.CreateNodeWalletAddressInput import \ + CreateNodeWalletAddressInput +from lightspark.objects.CreateNodeWalletAddressOutput import \ + CreateNodeWalletAddressOutput +from lightspark.objects.CreateOfferInput import CreateOfferInput +from lightspark.objects.CreateOfferOutput import CreateOfferOutput +from lightspark.objects.CreateTestModeInvoiceInput import \ + CreateTestModeInvoiceInput +from lightspark.objects.CreateTestModeInvoiceOutput import \ + CreateTestModeInvoiceOutput +from lightspark.objects.CreateTestModePaymentInput import \ + CreateTestModePaymentInput +from lightspark.objects.CreateTestModePaymentoutput import \ + CreateTestModePaymentoutput +from lightspark.objects.CreateUmaInvitationInput import \ + CreateUmaInvitationInput +from lightspark.objects.CreateUmaInvitationOutput import \ + CreateUmaInvitationOutput from lightspark.objects.CreateUmaInvoiceInput import CreateUmaInvoiceInput from lightspark.objects.CurrencyAmount import CurrencyAmount +from lightspark.objects.CurrencyAmountInput import CurrencyAmountInput from lightspark.objects.CurrencyUnit import CurrencyUnit from lightspark.objects.DailyLiquidityForecast import DailyLiquidityForecast -from lightspark.objects.DeclineToSignMessagesInput import DeclineToSignMessagesInput -from lightspark.objects.DeclineToSignMessagesOutput import DeclineToSignMessagesOutput +from lightspark.objects.DeclineToSignMessagesInput import \ + DeclineToSignMessagesInput +from lightspark.objects.DeclineToSignMessagesOutput import \ + DeclineToSignMessagesOutput from lightspark.objects.DeleteApiTokenInput import DeleteApiTokenInput from lightspark.objects.DeleteApiTokenOutput import DeleteApiTokenOutput from lightspark.objects.Deposit import Deposit @@ -82,91 +92,80 @@ from lightspark.objects.Hop import Hop from lightspark.objects.HtlcAttemptFailureCode import HtlcAttemptFailureCode from lightspark.objects.IdAndSignature import IdAndSignature -from lightspark.objects.IncentivesIneligibilityReason import ( - IncentivesIneligibilityReason, -) +from lightspark.objects.IncentivesIneligibilityReason import \ + IncentivesIneligibilityReason from lightspark.objects.IncentivesStatus import IncentivesStatus from lightspark.objects.IncomingPayment import IncomingPayment from lightspark.objects.IncomingPaymentAttempt import IncomingPaymentAttempt -from lightspark.objects.IncomingPaymentAttemptStatus import IncomingPaymentAttemptStatus -from lightspark.objects.IncomingPaymentsForInvoiceQueryInput import ( - IncomingPaymentsForInvoiceQueryInput, -) -from lightspark.objects.IncomingPaymentsForInvoiceQueryOutput import ( - IncomingPaymentsForInvoiceQueryOutput, -) -from lightspark.objects.IncomingPaymentsForPaymentHashQueryInput import ( - IncomingPaymentsForPaymentHashQueryInput, -) -from lightspark.objects.IncomingPaymentsForPaymentHashQueryOutput import ( - IncomingPaymentsForPaymentHashQueryOutput, -) -from lightspark.objects.IncomingPaymentToAttemptsConnection import ( - IncomingPaymentToAttemptsConnection, -) +from lightspark.objects.IncomingPaymentAttemptStatus import \ + IncomingPaymentAttemptStatus +from lightspark.objects.IncomingPaymentsForInvoiceQueryInput import \ + IncomingPaymentsForInvoiceQueryInput +from lightspark.objects.IncomingPaymentsForInvoiceQueryOutput import \ + IncomingPaymentsForInvoiceQueryOutput +from lightspark.objects.IncomingPaymentsForPaymentHashQueryInput import \ + IncomingPaymentsForPaymentHashQueryInput +from lightspark.objects.IncomingPaymentsForPaymentHashQueryOutput import \ + IncomingPaymentsForPaymentHashQueryOutput +from lightspark.objects.IncomingPaymentToAttemptsConnection import \ + IncomingPaymentToAttemptsConnection from lightspark.objects.Invoice import Invoice from lightspark.objects.InvoiceData import InvoiceData -from lightspark.objects.InvoiceForPaymentHashInput import InvoiceForPaymentHashInput -from lightspark.objects.InvoiceForPaymentHashOutput import InvoiceForPaymentHashOutput +from lightspark.objects.InvoiceForPaymentHashInput import \ + InvoiceForPaymentHashInput +from lightspark.objects.InvoiceForPaymentHashOutput import \ + InvoiceForPaymentHashOutput from lightspark.objects.InvoiceType import InvoiceType -from lightspark.objects.LightningFeeEstimateForInvoiceInput import ( - LightningFeeEstimateForInvoiceInput, -) -from lightspark.objects.LightningFeeEstimateForNodeInput import ( - LightningFeeEstimateForNodeInput, -) -from lightspark.objects.LightningFeeEstimateOutput import LightningFeeEstimateOutput -from lightspark.objects.LightningPaymentDirection import LightningPaymentDirection +from lightspark.objects.LightningFeeEstimateForInvoiceInput import \ + LightningFeeEstimateForInvoiceInput +from lightspark.objects.LightningFeeEstimateForNodeInput import \ + LightningFeeEstimateForNodeInput +from lightspark.objects.LightningFeeEstimateOutput import \ + LightningFeeEstimateOutput +from lightspark.objects.LightningPaymentDirection import \ + LightningPaymentDirection from lightspark.objects.LightningTransaction import LightningTransaction from lightspark.objects.LightsparkNode import LightsparkNode from lightspark.objects.LightsparkNodeOwner import LightsparkNodeOwner from lightspark.objects.LightsparkNodeStatus import LightsparkNodeStatus -from lightspark.objects.LightsparkNodeToChannelsConnection import ( - LightsparkNodeToChannelsConnection, -) -from lightspark.objects.LightsparkNodeToDailyLiquidityForecastsConnection import ( - LightsparkNodeToDailyLiquidityForecastsConnection, -) +from lightspark.objects.LightsparkNodeToChannelsConnection import \ + LightsparkNodeToChannelsConnection +from lightspark.objects.LightsparkNodeToDailyLiquidityForecastsConnection import \ + LightsparkNodeToDailyLiquidityForecastsConnection from lightspark.objects.LightsparkNodeWithOSK import LightsparkNodeWithOSK -from lightspark.objects.LightsparkNodeWithRemoteSigning import ( - LightsparkNodeWithRemoteSigning, -) -from lightspark.objects.MultiSigAddressValidationParameters import ( - MultiSigAddressValidationParameters, -) +from lightspark.objects.LightsparkNodeWithRemoteSigning import \ + LightsparkNodeWithRemoteSigning +from lightspark.objects.MultiSigAddressValidationParameters import \ + MultiSigAddressValidationParameters from lightspark.objects.Node import Node from lightspark.objects.NodeAddress import NodeAddress from lightspark.objects.NodeAddressType import NodeAddressType -from lightspark.objects.NodeToAddressesConnection import NodeToAddressesConnection +from lightspark.objects.NodeToAddressesConnection import \ + NodeToAddressesConnection +from lightspark.objects.Offer import Offer +from lightspark.objects.OfferData import OfferData from lightspark.objects.OnChainFeeTarget import OnChainFeeTarget from lightspark.objects.OnChainTransaction import OnChainTransaction from lightspark.objects.OutgoingPayment import OutgoingPayment from lightspark.objects.OutgoingPaymentAttempt import OutgoingPaymentAttempt -from lightspark.objects.OutgoingPaymentAttemptStatus import OutgoingPaymentAttemptStatus -from lightspark.objects.OutgoingPaymentAttemptToHopsConnection import ( - OutgoingPaymentAttemptToHopsConnection, -) -from lightspark.objects.OutgoingPaymentForIdempotencyKeyInput import ( - OutgoingPaymentForIdempotencyKeyInput, -) -from lightspark.objects.OutgoingPaymentForIdempotencyKeyOutput import ( - OutgoingPaymentForIdempotencyKeyOutput, -) -from lightspark.objects.OutgoingPaymentsForInvoiceQueryInput import ( - OutgoingPaymentsForInvoiceQueryInput, -) -from lightspark.objects.OutgoingPaymentsForInvoiceQueryOutput import ( - OutgoingPaymentsForInvoiceQueryOutput, -) -from lightspark.objects.OutgoingPaymentsForPaymentHashQueryInput import ( - OutgoingPaymentsForPaymentHashQueryInput, -) -from lightspark.objects.OutgoingPaymentsForPaymentHashQueryOutput import ( - OutgoingPaymentsForPaymentHashQueryOutput, -) -from lightspark.objects.OutgoingPaymentToAttemptsConnection import ( - OutgoingPaymentToAttemptsConnection, -) +from lightspark.objects.OutgoingPaymentAttemptStatus import \ + OutgoingPaymentAttemptStatus +from lightspark.objects.OutgoingPaymentAttemptToHopsConnection import \ + OutgoingPaymentAttemptToHopsConnection +from lightspark.objects.OutgoingPaymentForIdempotencyKeyInput import \ + OutgoingPaymentForIdempotencyKeyInput +from lightspark.objects.OutgoingPaymentForIdempotencyKeyOutput import \ + OutgoingPaymentForIdempotencyKeyOutput +from lightspark.objects.OutgoingPaymentsForInvoiceQueryInput import \ + OutgoingPaymentsForInvoiceQueryInput +from lightspark.objects.OutgoingPaymentsForInvoiceQueryOutput import \ + OutgoingPaymentsForInvoiceQueryOutput +from lightspark.objects.OutgoingPaymentsForPaymentHashQueryInput import \ + OutgoingPaymentsForPaymentHashQueryInput +from lightspark.objects.OutgoingPaymentsForPaymentHashQueryOutput import \ + OutgoingPaymentsForPaymentHashQueryOutput +from lightspark.objects.OutgoingPaymentToAttemptsConnection import \ + OutgoingPaymentToAttemptsConnection from lightspark.objects.PageInfo import PageInfo from lightspark.objects.PayInvoiceInput import PayInvoiceInput from lightspark.objects.PayInvoiceOutput import PayInvoiceOutput @@ -175,37 +174,42 @@ from lightspark.objects.PaymentRequest import PaymentRequest from lightspark.objects.PaymentRequestData import PaymentRequestData from lightspark.objects.PaymentRequestStatus import PaymentRequestStatus +from lightspark.objects.PayOfferInput import PayOfferInput +from lightspark.objects.PayOfferOutput import PayOfferOutput +from lightspark.objects.PayTestModeInvoiceInput import PayTestModeInvoiceInput from lightspark.objects.PayUmaInvoiceInput import PayUmaInvoiceInput from lightspark.objects.Permission import Permission from lightspark.objects.PostTransactionData import PostTransactionData from lightspark.objects.RegionCode import RegionCode from lightspark.objects.RegisterPaymentInput import RegisterPaymentInput from lightspark.objects.RegisterPaymentOutput import RegisterPaymentOutput -from lightspark.objects.ReleaseChannelPerCommitmentSecretInput import ( - ReleaseChannelPerCommitmentSecretInput, -) -from lightspark.objects.ReleaseChannelPerCommitmentSecretOutput import ( - ReleaseChannelPerCommitmentSecretOutput, -) -from lightspark.objects.ReleasePaymentPreimageInput import ReleasePaymentPreimageInput -from lightspark.objects.ReleasePaymentPreimageOutput import ReleasePaymentPreimageOutput -from lightspark.objects.RemoteSigningSubEventType import RemoteSigningSubEventType +from lightspark.objects.ReleaseChannelPerCommitmentSecretInput import \ + ReleaseChannelPerCommitmentSecretInput +from lightspark.objects.ReleaseChannelPerCommitmentSecretOutput import \ + ReleaseChannelPerCommitmentSecretOutput +from lightspark.objects.ReleasePaymentPreimageInput import \ + ReleasePaymentPreimageInput +from lightspark.objects.ReleasePaymentPreimageOutput import \ + ReleasePaymentPreimageOutput +from lightspark.objects.RemoteSigningSubEventType import \ + RemoteSigningSubEventType from lightspark.objects.RequestInitiator import RequestInitiator from lightspark.objects.RequestWithdrawalInput import RequestWithdrawalInput from lightspark.objects.RequestWithdrawalOutput import RequestWithdrawalOutput from lightspark.objects.RichText import RichText from lightspark.objects.RiskRating import RiskRating from lightspark.objects.RoutingTransaction import RoutingTransaction -from lightspark.objects.RoutingTransactionFailureReason import ( - RoutingTransactionFailureReason, -) +from lightspark.objects.RoutingTransactionFailureReason import \ + RoutingTransactionFailureReason from lightspark.objects.ScreenNodeInput import ScreenNodeInput from lightspark.objects.ScreenNodeOutput import ScreenNodeOutput from lightspark.objects.Secret import Secret from lightspark.objects.SendPaymentInput import SendPaymentInput from lightspark.objects.SendPaymentOutput import SendPaymentOutput -from lightspark.objects.SetInvoicePaymentHashInput import SetInvoicePaymentHashInput -from lightspark.objects.SetInvoicePaymentHashOutput import SetInvoicePaymentHashOutput +from lightspark.objects.SetInvoicePaymentHashInput import \ + SetInvoicePaymentHashInput +from lightspark.objects.SetInvoicePaymentHashOutput import \ + SetInvoicePaymentHashOutput from lightspark.objects.Signable import Signable from lightspark.objects.SignablePayload import SignablePayload from lightspark.objects.SignablePayloadStatus import SignablePayloadStatus @@ -218,41 +222,37 @@ from lightspark.objects.TransactionStatus import TransactionStatus from lightspark.objects.TransactionType import TransactionType from lightspark.objects.UmaInvitation import UmaInvitation -from lightspark.objects.UpdateChannelPerCommitmentPointInput import ( - UpdateChannelPerCommitmentPointInput, -) -from lightspark.objects.UpdateChannelPerCommitmentPointOutput import ( - UpdateChannelPerCommitmentPointOutput, -) -from lightspark.objects.UpdateNodeSharedSecretInput import UpdateNodeSharedSecretInput -from lightspark.objects.UpdateNodeSharedSecretOutput import UpdateNodeSharedSecretOutput +from lightspark.objects.UpdateChannelPerCommitmentPointInput import \ + UpdateChannelPerCommitmentPointInput +from lightspark.objects.UpdateChannelPerCommitmentPointOutput import \ + UpdateChannelPerCommitmentPointOutput +from lightspark.objects.UpdateNodeSharedSecretInput import \ + UpdateNodeSharedSecretInput +from lightspark.objects.UpdateNodeSharedSecretOutput import \ + UpdateNodeSharedSecretOutput from lightspark.objects.Wallet import Wallet from lightspark.objects.WalletStatus import WalletStatus -from lightspark.objects.WalletToPaymentRequestsConnection import ( - WalletToPaymentRequestsConnection, -) -from lightspark.objects.WalletToTransactionsConnection import ( - WalletToTransactionsConnection, -) -from lightspark.objects.WalletToWithdrawalRequestsConnection import ( - WalletToWithdrawalRequestsConnection, -) +from lightspark.objects.WalletToPaymentRequestsConnection import \ + WalletToPaymentRequestsConnection +from lightspark.objects.WalletToTransactionsConnection import \ + WalletToTransactionsConnection +from lightspark.objects.WalletToWithdrawalRequestsConnection import \ + WalletToWithdrawalRequestsConnection from lightspark.objects.WebhookEventType import WebhookEventType from lightspark.objects.Withdrawal import Withdrawal -from lightspark.objects.WithdrawalFeeEstimateInput import WithdrawalFeeEstimateInput -from lightspark.objects.WithdrawalFeeEstimateOutput import WithdrawalFeeEstimateOutput +from lightspark.objects.WithdrawalFeeEstimateInput import \ + WithdrawalFeeEstimateInput +from lightspark.objects.WithdrawalFeeEstimateOutput import \ + WithdrawalFeeEstimateOutput from lightspark.objects.WithdrawalMode import WithdrawalMode from lightspark.objects.WithdrawalRequest import WithdrawalRequest from lightspark.objects.WithdrawalRequestStatus import WithdrawalRequestStatus -from lightspark.objects.WithdrawalRequestToChannelClosingTransactionsConnection import ( - WithdrawalRequestToChannelClosingTransactionsConnection, -) -from lightspark.objects.WithdrawalRequestToChannelOpeningTransactionsConnection import ( - WithdrawalRequestToChannelOpeningTransactionsConnection, -) -from lightspark.objects.WithdrawalRequestToWithdrawalsConnection import ( - WithdrawalRequestToWithdrawalsConnection, -) +from lightspark.objects.WithdrawalRequestToChannelClosingTransactionsConnection import \ + WithdrawalRequestToChannelClosingTransactionsConnection +from lightspark.objects.WithdrawalRequestToChannelOpeningTransactionsConnection import \ + WithdrawalRequestToChannelOpeningTransactionsConnection +from lightspark.objects.WithdrawalRequestToWithdrawalsConnection import \ + WithdrawalRequestToWithdrawalsConnection from lightspark.remote_signing import * from lightspark.version import __version__ from lightspark.webhooks import SIGNATURE_HEADER, WebhookEvent diff --git a/lightspark/objects/Account.py b/lightspark/objects/Account.py index 3c4b809..694d0c0 100644 --- a/lightspark/objects/Account.py +++ b/lightspark/objects/Account.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,36 +8,34 @@ from lightspark.requests.requester import Requester from .AccountToApiTokensConnection import AccountToApiTokensConnection -from .AccountToApiTokensConnection import ( - from_json as AccountToApiTokensConnection_from_json, -) +from .AccountToApiTokensConnection import \ + from_json as AccountToApiTokensConnection_from_json from .AccountToChannelsConnection import AccountToChannelsConnection -from .AccountToChannelsConnection import ( - from_json as AccountToChannelsConnection_from_json, -) +from .AccountToChannelsConnection import \ + from_json as AccountToChannelsConnection_from_json from .AccountToNodesConnection import AccountToNodesConnection -from .AccountToNodesConnection import from_json as AccountToNodesConnection_from_json -from .AccountToPaymentRequestsConnection import AccountToPaymentRequestsConnection -from .AccountToPaymentRequestsConnection import ( - from_json as AccountToPaymentRequestsConnection_from_json, -) +from .AccountToNodesConnection import \ + from_json as AccountToNodesConnection_from_json +from .AccountToPaymentRequestsConnection import \ + AccountToPaymentRequestsConnection +from .AccountToPaymentRequestsConnection import \ + from_json as AccountToPaymentRequestsConnection_from_json from .AccountToTransactionsConnection import AccountToTransactionsConnection -from .AccountToTransactionsConnection import ( - from_json as AccountToTransactionsConnection_from_json, -) +from .AccountToTransactionsConnection import \ + from_json as AccountToTransactionsConnection_from_json from .AccountToWalletsConnection import AccountToWalletsConnection -from .AccountToWalletsConnection import ( - from_json as AccountToWalletsConnection_from_json, -) -from .AccountToWithdrawalRequestsConnection import AccountToWithdrawalRequestsConnection -from .AccountToWithdrawalRequestsConnection import ( - from_json as AccountToWithdrawalRequestsConnection_from_json, -) +from .AccountToWalletsConnection import \ + from_json as AccountToWalletsConnection_from_json +from .AccountToWithdrawalRequestsConnection import \ + AccountToWithdrawalRequestsConnection +from .AccountToWithdrawalRequestsConnection import \ + from_json as AccountToWithdrawalRequestsConnection_from_json from .BitcoinNetwork import BitcoinNetwork from .BlockchainBalance import BlockchainBalance from .BlockchainBalance import from_json as BlockchainBalance_from_json from .CurrencyAmount import CurrencyAmount from .CurrencyAmount import from_json as CurrencyAmount_from_json +from .CurrencyAmountInput import CurrencyAmountInput from .Entity import Entity from .LightsparkNodeOwner import LightsparkNodeOwner from .TransactionFailures import TransactionFailures @@ -64,9 +63,7 @@ class Account(LightsparkNodeOwner, Entity): """The name of this account.""" typename: str - def get_api_tokens( - self, first: Optional[int] = None, after: Optional[str] = None - ) -> AccountToApiTokensConnection: + def get_api_tokens(self, first: Optional[int]= None, after: Optional[str]= None) -> AccountToApiTokensConnection: json = self.requester.execute_graphql( """ query FetchAccountToApiTokensConnection($entity_id: ID!, $first: Int, $after: String) { @@ -97,16 +94,12 @@ def get_api_tokens( } } """, - {"entity_id": self.id, "first": first, "after": after}, + {"entity_id": self.id, "first": first, "after": after} ) connection = json["entity"]["api_tokens"] return AccountToApiTokensConnection_from_json(self.requester, connection) - def get_blockchain_balance( - self, - bitcoin_networks: Optional[List[BitcoinNetwork]] = None, - node_ids: Optional[List[str]] = None, - ) -> Optional[BlockchainBalance]: + def get_blockchain_balance(self, bitcoin_networks: Optional[List[BitcoinNetwork]]= None, node_ids: Optional[List[str]]= None) -> Optional[BlockchainBalance]: json = self.requester.execute_graphql( """ query FetchAccountBlockchainBalance($entity_id: ID!, $bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!]) { @@ -167,24 +160,12 @@ def get_blockchain_balance( } } """, - { - "entity_id": self.id, - "bitcoin_networks": bitcoin_networks, - "node_ids": node_ids, - }, + {"entity_id": self.id, "bitcoin_networks": bitcoin_networks, "node_ids": node_ids} ) connection = json["entity"]["blockchain_balance"] - return ( - BlockchainBalance_from_json(self.requester, connection) - if connection - else None - ) + return BlockchainBalance_from_json(self.requester, connection) if connection else None - def get_conductivity( - self, - bitcoin_networks: Optional[List[BitcoinNetwork]] = None, - node_ids: Optional[List[str]] = None, - ) -> Optional[int]: + def get_conductivity(self, bitcoin_networks: Optional[List[BitcoinNetwork]]= None, node_ids: Optional[List[str]]= None) -> Optional[int]: json = self.requester.execute_graphql( """ query FetchAccountConductivity($entity_id: ID!, $bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!]) { @@ -195,20 +176,12 @@ def get_conductivity( } } """, - { - "entity_id": self.id, - "bitcoin_networks": bitcoin_networks, - "node_ids": node_ids, - }, + {"entity_id": self.id, "bitcoin_networks": bitcoin_networks, "node_ids": node_ids} ) connection = json["entity"]["conductivity"] return connection - def get_local_balance( - self, - bitcoin_networks: Optional[List[BitcoinNetwork]] = None, - node_ids: Optional[List[str]] = None, - ) -> Optional[CurrencyAmount]: + def get_local_balance(self, bitcoin_networks: Optional[List[BitcoinNetwork]]= None, node_ids: Optional[List[str]]= None) -> Optional[CurrencyAmount]: json = self.requester.execute_graphql( """ query FetchAccountLocalBalance($entity_id: ID!, $bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!]) { @@ -226,24 +199,12 @@ def get_local_balance( } } """, - { - "entity_id": self.id, - "bitcoin_networks": bitcoin_networks, - "node_ids": node_ids, - }, + {"entity_id": self.id, "bitcoin_networks": bitcoin_networks, "node_ids": node_ids} ) connection = json["entity"]["local_balance"] - return ( - CurrencyAmount_from_json(self.requester, connection) if connection else None - ) + return CurrencyAmount_from_json(self.requester, connection) if connection else None - def get_nodes( - self, - first: Optional[int] = None, - bitcoin_networks: Optional[List[BitcoinNetwork]] = None, - node_ids: Optional[List[str]] = None, - after: Optional[str] = None, - ) -> AccountToNodesConnection: + def get_nodes(self, first: Optional[int]= None, bitcoin_networks: Optional[List[BitcoinNetwork]]= None, node_ids: Optional[List[str]]= None, after: Optional[str]= None) -> AccountToNodesConnection: json = self.requester.execute_graphql( """ query FetchAccountToNodesConnection($entity_id: ID!, $first: Int, $bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!], $after: String) { @@ -526,22 +487,12 @@ def get_nodes( } } """, - { - "entity_id": self.id, - "first": first, - "bitcoin_networks": bitcoin_networks, - "node_ids": node_ids, - "after": after, - }, + {"entity_id": self.id, "first": first, "bitcoin_networks": bitcoin_networks, "node_ids": node_ids, "after": after} ) connection = json["entity"]["nodes"] return AccountToNodesConnection_from_json(self.requester, connection) - def get_remote_balance( - self, - bitcoin_networks: Optional[List[BitcoinNetwork]] = None, - node_ids: Optional[List[str]] = None, - ) -> Optional[CurrencyAmount]: + def get_remote_balance(self, bitcoin_networks: Optional[List[BitcoinNetwork]]= None, node_ids: Optional[List[str]]= None) -> Optional[CurrencyAmount]: json = self.requester.execute_graphql( """ query FetchAccountRemoteBalance($entity_id: ID!, $bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!]) { @@ -559,24 +510,12 @@ def get_remote_balance( } } """, - { - "entity_id": self.id, - "bitcoin_networks": bitcoin_networks, - "node_ids": node_ids, - }, + {"entity_id": self.id, "bitcoin_networks": bitcoin_networks, "node_ids": node_ids} ) connection = json["entity"]["remote_balance"] - return ( - CurrencyAmount_from_json(self.requester, connection) if connection else None - ) + return CurrencyAmount_from_json(self.requester, connection) if connection else None - def get_uptime_percentage( - self, - after_date: Optional[datetime] = None, - before_date: Optional[datetime] = None, - bitcoin_networks: Optional[List[BitcoinNetwork]] = None, - node_ids: Optional[List[str]] = None, - ) -> Optional[int]: + def get_uptime_percentage(self, after_date: Optional[datetime]= None, before_date: Optional[datetime]= None, bitcoin_networks: Optional[List[BitcoinNetwork]]= None, node_ids: Optional[List[str]]= None) -> Optional[int]: json = self.requester.execute_graphql( """ query FetchAccountUptimePercentage($entity_id: ID!, $after_date: DateTime, $before_date: DateTime, $bitcoin_networks: [BitcoinNetwork!], $node_ids: [ID!]) { @@ -587,26 +526,12 @@ def get_uptime_percentage( } } """, - { - "entity_id": self.id, - "after_date": after_date, - "before_date": before_date, - "bitcoin_networks": bitcoin_networks, - "node_ids": node_ids, - }, + {"entity_id": self.id, "after_date": after_date, "before_date": before_date, "bitcoin_networks": bitcoin_networks, "node_ids": node_ids} ) connection = json["entity"]["uptime_percentage"] return connection - def get_channels( - self, - bitcoin_network: BitcoinNetwork, - lightning_node_id: Optional[str] = None, - after_date: Optional[datetime] = None, - before_date: Optional[datetime] = None, - first: Optional[int] = None, - after: Optional[str] = None, - ) -> AccountToChannelsConnection: + def get_channels(self, bitcoin_network: BitcoinNetwork, lightning_node_id: Optional[str]= None, after_date: Optional[datetime]= None, before_date: Optional[datetime]= None, first: Optional[int]= None, after: Optional[str]= None) -> AccountToChannelsConnection: json = self.requester.execute_graphql( """ query FetchAccountToChannelsConnection($entity_id: ID!, $bitcoin_network: BitcoinNetwork!, $lightning_node_id: ID, $after_date: DateTime, $before_date: DateTime, $first: Int, $after: String) { @@ -721,37 +646,18 @@ def get_channels( } } """, - { - "entity_id": self.id, - "bitcoin_network": bitcoin_network, - "lightning_node_id": lightning_node_id, - "after_date": after_date, - "before_date": before_date, - "first": first, - "after": after, - }, + {"entity_id": self.id, "bitcoin_network": bitcoin_network, "lightning_node_id": lightning_node_id, "after_date": after_date, "before_date": before_date, "first": first, "after": after} ) connection = json["entity"]["channels"] return AccountToChannelsConnection_from_json(self.requester, connection) - def get_transactions( - self, - first: Optional[int] = None, - after: Optional[str] = None, - types: Optional[List[TransactionType]] = None, - after_date: Optional[datetime] = None, - before_date: Optional[datetime] = None, - bitcoin_network: Optional[BitcoinNetwork] = None, - lightning_node_id: Optional[str] = None, - statuses: Optional[List[TransactionStatus]] = None, - exclude_failures: Optional[TransactionFailures] = None, - ) -> AccountToTransactionsConnection: + def get_transactions(self, first: Optional[int]= None, after: Optional[str]= None, types: Optional[List[TransactionType]]= None, after_date: Optional[datetime]= None, before_date: Optional[datetime]= None, bitcoin_network: Optional[BitcoinNetwork]= None, lightning_node_id: Optional[str]= None, statuses: Optional[List[TransactionStatus]]= None, exclude_failures: Optional[TransactionFailures]= None, max_amount: Optional[CurrencyAmountInput]= None, min_amount: Optional[CurrencyAmountInput]= None) -> AccountToTransactionsConnection: json = self.requester.execute_graphql( """ -query FetchAccountToTransactionsConnection($entity_id: ID!, $first: Int, $after: String, $types: [TransactionType!], $after_date: DateTime, $before_date: DateTime, $bitcoin_network: BitcoinNetwork, $lightning_node_id: ID, $statuses: [TransactionStatus!], $exclude_failures: TransactionFailures) { +query FetchAccountToTransactionsConnection($entity_id: ID!, $first: Int, $after: String, $types: [TransactionType!], $after_date: DateTime, $before_date: DateTime, $bitcoin_network: BitcoinNetwork, $lightning_node_id: ID, $statuses: [TransactionStatus!], $exclude_failures: TransactionFailures, $max_amount: CurrencyAmountInput, $min_amount: CurrencyAmountInput) { entity(id: $entity_id) { ... on Account { - transactions(, first: $first, after: $after, types: $types, after_date: $after_date, before_date: $before_date, bitcoin_network: $bitcoin_network, lightning_node_id: $lightning_node_id, statuses: $statuses, exclude_failures: $exclude_failures) { + transactions(, first: $first, after: $after, types: $types, after_date: $after_date, before_date: $before_date, bitcoin_network: $bitcoin_network, lightning_node_id: $lightning_node_id, statuses: $statuses, exclude_failures: $exclude_failures, max_amount: $max_amount, min_amount: $min_amount) { __typename account_to_transactions_connection_count: count account_to_transactions_connection_page_info: page_info { @@ -1340,37 +1246,18 @@ def get_transactions( } } """, - { - "entity_id": self.id, - "first": first, - "after": after, - "types": types, - "after_date": after_date, - "before_date": before_date, - "bitcoin_network": bitcoin_network, - "lightning_node_id": lightning_node_id, - "statuses": statuses, - "exclude_failures": exclude_failures, - }, + {"entity_id": self.id, "first": first, "after": after, "types": types, "after_date": after_date, "before_date": before_date, "bitcoin_network": bitcoin_network, "lightning_node_id": lightning_node_id, "statuses": statuses, "exclude_failures": exclude_failures, "max_amount": max_amount, "min_amount": min_amount} ) connection = json["entity"]["transactions"] return AccountToTransactionsConnection_from_json(self.requester, connection) - def get_payment_requests( - self, - first: Optional[int] = None, - after: Optional[str] = None, - after_date: Optional[datetime] = None, - before_date: Optional[datetime] = None, - bitcoin_network: Optional[BitcoinNetwork] = None, - lightning_node_id: Optional[str] = None, - ) -> AccountToPaymentRequestsConnection: + def get_payment_requests(self, first: Optional[int]= None, after: Optional[str]= None, after_date: Optional[datetime]= None, before_date: Optional[datetime]= None, bitcoin_network: Optional[BitcoinNetwork]= None, lightning_node_id: Optional[str]= None, max_amount: Optional[CurrencyAmountInput]= None, min_amount: Optional[CurrencyAmountInput]= None) -> AccountToPaymentRequestsConnection: json = self.requester.execute_graphql( """ -query FetchAccountToPaymentRequestsConnection($entity_id: ID!, $first: Int, $after: String, $after_date: DateTime, $before_date: DateTime, $bitcoin_network: BitcoinNetwork, $lightning_node_id: ID) { +query FetchAccountToPaymentRequestsConnection($entity_id: ID!, $first: Int, $after: String, $after_date: DateTime, $before_date: DateTime, $bitcoin_network: BitcoinNetwork, $lightning_node_id: ID, $max_amount: CurrencyAmountInput, $min_amount: CurrencyAmountInput) { entity(id: $entity_id) { ... on Account { - payment_requests(, first: $first, after: $after, after_date: $after_date, before_date: $before_date, bitcoin_network: $bitcoin_network, lightning_node_id: $lightning_node_id) { + payment_requests(, first: $first, after: $after, after_date: $after_date, before_date: $before_date, bitcoin_network: $bitcoin_network, lightning_node_id: $lightning_node_id, max_amount: $max_amount, min_amount: $min_amount) { __typename account_to_payment_requests_connection_count: count account_to_payment_requests_connection_page_info: page_info { @@ -1696,36 +1583,18 @@ def get_payment_requests( } } """, - { - "entity_id": self.id, - "first": first, - "after": after, - "after_date": after_date, - "before_date": before_date, - "bitcoin_network": bitcoin_network, - "lightning_node_id": lightning_node_id, - }, + {"entity_id": self.id, "first": first, "after": after, "after_date": after_date, "before_date": before_date, "bitcoin_network": bitcoin_network, "lightning_node_id": lightning_node_id, "max_amount": max_amount, "min_amount": min_amount} ) connection = json["entity"]["payment_requests"] return AccountToPaymentRequestsConnection_from_json(self.requester, connection) - def get_withdrawal_requests( - self, - first: Optional[int] = None, - after: Optional[str] = None, - bitcoin_networks: Optional[List[BitcoinNetwork]] = None, - statuses: Optional[List[WithdrawalRequestStatus]] = None, - node_ids: Optional[List[str]] = None, - idempotency_keys: Optional[List[str]] = None, - after_date: Optional[datetime] = None, - before_date: Optional[datetime] = None, - ) -> AccountToWithdrawalRequestsConnection: + def get_withdrawal_requests(self, first: Optional[int]= None, after: Optional[str]= None, bitcoin_networks: Optional[List[BitcoinNetwork]]= None, statuses: Optional[List[WithdrawalRequestStatus]]= None, node_ids: Optional[List[str]]= None, idempotency_keys: Optional[List[str]]= None, after_date: Optional[datetime]= None, before_date: Optional[datetime]= None, max_amount: Optional[CurrencyAmountInput]= None, min_amount: Optional[CurrencyAmountInput]= None) -> AccountToWithdrawalRequestsConnection: json = self.requester.execute_graphql( """ -query FetchAccountToWithdrawalRequestsConnection($entity_id: ID!, $first: Int, $after: String, $bitcoin_networks: [BitcoinNetwork!], $statuses: [WithdrawalRequestStatus!], $node_ids: [ID!], $idempotency_keys: [String!], $after_date: DateTime, $before_date: DateTime) { +query FetchAccountToWithdrawalRequestsConnection($entity_id: ID!, $first: Int, $after: String, $bitcoin_networks: [BitcoinNetwork!], $statuses: [WithdrawalRequestStatus!], $node_ids: [ID!], $idempotency_keys: [String!], $after_date: DateTime, $before_date: DateTime, $max_amount: CurrencyAmountInput, $min_amount: CurrencyAmountInput) { entity(id: $entity_id) { ... on Account { - withdrawal_requests(, first: $first, after: $after, bitcoin_networks: $bitcoin_networks, statuses: $statuses, node_ids: $node_ids, idempotency_keys: $idempotency_keys, after_date: $after_date, before_date: $before_date) { + withdrawal_requests(, first: $first, after: $after, bitcoin_networks: $bitcoin_networks, statuses: $statuses, node_ids: $node_ids, idempotency_keys: $idempotency_keys, after_date: $after_date, before_date: $before_date, max_amount: $max_amount, min_amount: $min_amount) { __typename account_to_withdrawal_requests_connection_count: count account_to_withdrawal_requests_connection_page_info: page_info { @@ -1795,29 +1664,12 @@ def get_withdrawal_requests( } } """, - { - "entity_id": self.id, - "first": first, - "after": after, - "bitcoin_networks": bitcoin_networks, - "statuses": statuses, - "node_ids": node_ids, - "idempotency_keys": idempotency_keys, - "after_date": after_date, - "before_date": before_date, - }, + {"entity_id": self.id, "first": first, "after": after, "bitcoin_networks": bitcoin_networks, "statuses": statuses, "node_ids": node_ids, "idempotency_keys": idempotency_keys, "after_date": after_date, "before_date": before_date, "max_amount": max_amount, "min_amount": min_amount} ) connection = json["entity"]["withdrawal_requests"] - return AccountToWithdrawalRequestsConnection_from_json( - self.requester, connection - ) + return AccountToWithdrawalRequestsConnection_from_json(self.requester, connection) - def get_wallets( - self, - first: Optional[int] = None, - after: Optional[str] = None, - third_party_ids: Optional[List[str]] = None, - ) -> AccountToWalletsConnection: + def get_wallets(self, first: Optional[int]= None, after: Optional[str]= None, third_party_ids: Optional[List[str]]= None) -> AccountToWalletsConnection: json = self.requester.execute_graphql( """ query FetchAccountToWalletsConnection($entity_id: ID!, $first: Int, $after: String, $third_party_ids: [String!]) { @@ -1877,16 +1729,12 @@ def get_wallets( } } """, - { - "entity_id": self.id, - "first": first, - "after": after, - "third_party_ids": third_party_ids, - }, + {"entity_id": self.id, "first": first, "after": after, "third_party_ids": third_party_ids} ) connection = json["entity"]["wallets"] return AccountToWalletsConnection_from_json(self.requester, connection) + def to_json(self) -> Mapping[str, Any]: return { "__typename": "Account", @@ -1894,9 +1742,12 @@ def to_json(self) -> Mapping[str, Any]: "account_created_at": self.created_at.isoformat(), "account_updated_at": self.updated_at.isoformat(), "account_name": self.name, + } + + FRAGMENT = """ fragment AccountFragment on Account { __typename @@ -1908,12 +1759,13 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> Account: return Account( - requester=requester, - typename="Account", - id=obj["account_id"], + requester=requester, typename="Account", id=obj["account_id"], created_at=datetime.fromisoformat(obj["account_created_at"]), updated_at=datetime.fromisoformat(obj["account_updated_at"]), name=obj["account_name"], - ) + + ) + diff --git a/lightspark/objects/AccountToApiTokensConnection.py b/lightspark/objects/AccountToApiTokensConnection.py index 35682e0..a006a4d 100644 --- a/lightspark/objects/AccountToApiTokensConnection.py +++ b/lightspark/objects/AccountToApiTokensConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -14,6 +15,7 @@ @dataclass class AccountToApiTokensConnection(Connection): + requester: Requester count: int @@ -26,17 +28,19 @@ class AccountToApiTokensConnection(Connection): """The API tokens for the current page of this connection.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "AccountToApiTokensConnection", "account_to_api_tokens_connection_count": self.count, "account_to_api_tokens_connection_page_info": self.page_info.to_json(), - "account_to_api_tokens_connection_entities": [ - e.to_json() for e in self.entities - ], + "account_to_api_tokens_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment AccountToApiTokensConnectionFragment on AccountToApiTokensConnection { __typename @@ -55,21 +59,14 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> AccountToApiTokensConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> AccountToApiTokensConnection: return AccountToApiTokensConnection( - requester=requester, - typename="AccountToApiTokensConnection", - count=obj["account_to_api_tokens_connection_count"], - page_info=PageInfo_from_json( - requester, obj["account_to_api_tokens_connection_page_info"] - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: ApiToken_from_json(requester, e), - obj["account_to_api_tokens_connection_entities"], - ) - ), - ) + requester=requester, typename="AccountToApiTokensConnection", count=obj["account_to_api_tokens_connection_count"], + page_info=PageInfo_from_json(requester, obj["account_to_api_tokens_connection_page_info"]), + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: ApiToken_from_json(requester, e), obj["account_to_api_tokens_connection_entities"])), + + ) + diff --git a/lightspark/objects/AccountToChannelsConnection.py b/lightspark/objects/AccountToChannelsConnection.py index 9e9493a..370b97a 100644 --- a/lightspark/objects/AccountToChannelsConnection.py +++ b/lightspark/objects/AccountToChannelsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -14,6 +15,7 @@ @dataclass class AccountToChannelsConnection(Connection): + requester: Requester count: int @@ -26,17 +28,19 @@ class AccountToChannelsConnection(Connection): """The channels for the current page of this connection.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "AccountToChannelsConnection", "account_to_channels_connection_count": self.count, "account_to_channels_connection_page_info": self.page_info.to_json(), - "account_to_channels_connection_entities": [ - e.to_json() for e in self.entities - ], + "account_to_channels_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment AccountToChannelsConnectionFragment on AccountToChannelsConnection { __typename @@ -55,21 +59,14 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> AccountToChannelsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> AccountToChannelsConnection: return AccountToChannelsConnection( - requester=requester, - typename="AccountToChannelsConnection", - count=obj["account_to_channels_connection_count"], - page_info=PageInfo_from_json( - requester, obj["account_to_channels_connection_page_info"] - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: Channel_from_json(requester, e), - obj["account_to_channels_connection_entities"], - ) - ), - ) + requester=requester, typename="AccountToChannelsConnection", count=obj["account_to_channels_connection_count"], + page_info=PageInfo_from_json(requester, obj["account_to_channels_connection_page_info"]), + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: Channel_from_json(requester, e), obj["account_to_channels_connection_entities"])), + + ) + diff --git a/lightspark/objects/AccountToNodesConnection.py b/lightspark/objects/AccountToNodesConnection.py index b896548..8ddc341 100644 --- a/lightspark/objects/AccountToNodesConnection.py +++ b/lightspark/objects/AccountToNodesConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -28,17 +29,19 @@ class AccountToNodesConnection(Connection): """The nodes for the current page of this connection.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "AccountToNodesConnection", "account_to_nodes_connection_count": self.count, "account_to_nodes_connection_page_info": self.page_info.to_json(), - "account_to_nodes_connection_entities": [ - e.to_json() for e in self.entities - ], + "account_to_nodes_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment AccountToNodesConnectionFragment on AccountToNodesConnection { __typename @@ -57,19 +60,14 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> AccountToNodesConnection: return AccountToNodesConnection( - requester=requester, - typename="AccountToNodesConnection", - count=obj["account_to_nodes_connection_count"], - page_info=PageInfo_from_json( - requester, obj["account_to_nodes_connection_page_info"] - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: LightsparkNode_from_json(requester, e), - obj["account_to_nodes_connection_entities"], - ) - ), - ) + requester=requester, typename="AccountToNodesConnection", count=obj["account_to_nodes_connection_count"], + page_info=PageInfo_from_json(requester, obj["account_to_nodes_connection_page_info"]), + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: LightsparkNode_from_json(requester, e), obj["account_to_nodes_connection_entities"])), + + ) + diff --git a/lightspark/objects/AccountToPaymentRequestsConnection.py b/lightspark/objects/AccountToPaymentRequestsConnection.py index 723a53d..f4ca2b0 100644 --- a/lightspark/objects/AccountToPaymentRequestsConnection.py +++ b/lightspark/objects/AccountToPaymentRequestsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -14,6 +15,7 @@ @dataclass class AccountToPaymentRequestsConnection(Connection): + requester: Requester count: int @@ -26,17 +28,19 @@ class AccountToPaymentRequestsConnection(Connection): """The payment requests for the current page of this connection.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "AccountToPaymentRequestsConnection", "account_to_payment_requests_connection_count": self.count, "account_to_payment_requests_connection_page_info": self.page_info.to_json(), - "account_to_payment_requests_connection_entities": [ - e.to_json() for e in self.entities - ], + "account_to_payment_requests_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment AccountToPaymentRequestsConnectionFragment on AccountToPaymentRequestsConnection { __typename @@ -55,21 +59,14 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> AccountToPaymentRequestsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> AccountToPaymentRequestsConnection: return AccountToPaymentRequestsConnection( - requester=requester, - typename="AccountToPaymentRequestsConnection", - count=obj["account_to_payment_requests_connection_count"], - page_info=PageInfo_from_json( - requester, obj["account_to_payment_requests_connection_page_info"] - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: PaymentRequest_from_json(requester, e), - obj["account_to_payment_requests_connection_entities"], - ) - ), - ) + requester=requester, typename="AccountToPaymentRequestsConnection", count=obj["account_to_payment_requests_connection_count"], + page_info=PageInfo_from_json(requester, obj["account_to_payment_requests_connection_page_info"]), + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: PaymentRequest_from_json(requester, e), obj["account_to_payment_requests_connection_entities"])), + + ) + diff --git a/lightspark/objects/AccountToTransactionsConnection.py b/lightspark/objects/AccountToTransactionsConnection.py index 8604b19..289cb28 100644 --- a/lightspark/objects/AccountToTransactionsConnection.py +++ b/lightspark/objects/AccountToTransactionsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -16,6 +17,7 @@ @dataclass class AccountToTransactionsConnection(Connection): + requester: Requester count: int @@ -37,28 +39,22 @@ class AccountToTransactionsConnection(Connection): """The transactions for the current page of this connection.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "AccountToTransactionsConnection", "account_to_transactions_connection_count": self.count, "account_to_transactions_connection_page_info": self.page_info.to_json(), - "account_to_transactions_connection_profit_loss": ( - self.profit_loss.to_json() if self.profit_loss else None - ), - "account_to_transactions_connection_average_fee_earned": ( - self.average_fee_earned.to_json() if self.average_fee_earned else None - ), - "account_to_transactions_connection_total_amount_transacted": ( - self.total_amount_transacted.to_json() - if self.total_amount_transacted - else None - ), - "account_to_transactions_connection_entities": [ - e.to_json() for e in self.entities - ], + "account_to_transactions_connection_profit_loss": self.profit_loss.to_json() if self.profit_loss else None, + "account_to_transactions_connection_average_fee_earned": self.average_fee_earned.to_json() if self.average_fee_earned else None, + "account_to_transactions_connection_total_amount_transacted": self.total_amount_transacted.to_json() if self.total_amount_transacted else None, + "account_to_transactions_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment AccountToTransactionsConnectionFragment on AccountToTransactionsConnection { __typename @@ -101,43 +97,17 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> AccountToTransactionsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> AccountToTransactionsConnection: return AccountToTransactionsConnection( - requester=requester, - typename="AccountToTransactionsConnection", - count=obj["account_to_transactions_connection_count"], - page_info=PageInfo_from_json( - requester, obj["account_to_transactions_connection_page_info"] - ), - profit_loss=( - CurrencyAmount_from_json( - requester, obj["account_to_transactions_connection_profit_loss"] - ) - if obj["account_to_transactions_connection_profit_loss"] - else None - ), - average_fee_earned=( - CurrencyAmount_from_json( - requester, obj["account_to_transactions_connection_average_fee_earned"] - ) - if obj["account_to_transactions_connection_average_fee_earned"] - else None - ), - total_amount_transacted=( - CurrencyAmount_from_json( - requester, - obj["account_to_transactions_connection_total_amount_transacted"], - ) - if obj["account_to_transactions_connection_total_amount_transacted"] - else None - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: Transaction_from_json(requester, e), - obj["account_to_transactions_connection_entities"], - ) - ), - ) + requester=requester, typename="AccountToTransactionsConnection", count=obj["account_to_transactions_connection_count"], + page_info=PageInfo_from_json(requester, obj["account_to_transactions_connection_page_info"]), + profit_loss=CurrencyAmount_from_json(requester, obj["account_to_transactions_connection_profit_loss"]) if obj["account_to_transactions_connection_profit_loss"] else None, + average_fee_earned=CurrencyAmount_from_json(requester, obj["account_to_transactions_connection_average_fee_earned"]) if obj["account_to_transactions_connection_average_fee_earned"] else None, + total_amount_transacted=CurrencyAmount_from_json(requester, obj["account_to_transactions_connection_total_amount_transacted"]) if obj["account_to_transactions_connection_total_amount_transacted"] else None, + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: Transaction_from_json(requester, e), obj["account_to_transactions_connection_entities"])), + + ) + diff --git a/lightspark/objects/AccountToWalletsConnection.py b/lightspark/objects/AccountToWalletsConnection.py index 73a7b45..0218b91 100644 --- a/lightspark/objects/AccountToWalletsConnection.py +++ b/lightspark/objects/AccountToWalletsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -14,6 +15,7 @@ @dataclass class AccountToWalletsConnection(Connection): + requester: Requester count: int @@ -26,17 +28,19 @@ class AccountToWalletsConnection(Connection): """The wallets for the current page of this connection.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "AccountToWalletsConnection", "account_to_wallets_connection_count": self.count, "account_to_wallets_connection_page_info": self.page_info.to_json(), - "account_to_wallets_connection_entities": [ - e.to_json() for e in self.entities - ], + "account_to_wallets_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment AccountToWalletsConnectionFragment on AccountToWalletsConnection { __typename @@ -55,21 +59,14 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> AccountToWalletsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> AccountToWalletsConnection: return AccountToWalletsConnection( - requester=requester, - typename="AccountToWalletsConnection", - count=obj["account_to_wallets_connection_count"], - page_info=PageInfo_from_json( - requester, obj["account_to_wallets_connection_page_info"] - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: Wallet_from_json(requester, e), - obj["account_to_wallets_connection_entities"], - ) - ), - ) + requester=requester, typename="AccountToWalletsConnection", count=obj["account_to_wallets_connection_count"], + page_info=PageInfo_from_json(requester, obj["account_to_wallets_connection_page_info"]), + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: Wallet_from_json(requester, e), obj["account_to_wallets_connection_entities"])), + + ) + diff --git a/lightspark/objects/AccountToWithdrawalRequestsConnection.py b/lightspark/objects/AccountToWithdrawalRequestsConnection.py index 924d5d8..ae19022 100644 --- a/lightspark/objects/AccountToWithdrawalRequestsConnection.py +++ b/lightspark/objects/AccountToWithdrawalRequestsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -28,17 +29,19 @@ class AccountToWithdrawalRequestsConnection(Connection): """The withdrawal requests for the current page of this connection.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "AccountToWithdrawalRequestsConnection", "account_to_withdrawal_requests_connection_count": self.count, "account_to_withdrawal_requests_connection_page_info": self.page_info.to_json(), - "account_to_withdrawal_requests_connection_entities": [ - e.to_json() for e in self.entities - ], + "account_to_withdrawal_requests_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment AccountToWithdrawalRequestsConnectionFragment on AccountToWithdrawalRequestsConnection { __typename @@ -57,21 +60,14 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> AccountToWithdrawalRequestsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> AccountToWithdrawalRequestsConnection: return AccountToWithdrawalRequestsConnection( - requester=requester, - typename="AccountToWithdrawalRequestsConnection", - count=obj["account_to_withdrawal_requests_connection_count"], - page_info=PageInfo_from_json( - requester, obj["account_to_withdrawal_requests_connection_page_info"] - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: WithdrawalRequest_from_json(requester, e), - obj["account_to_withdrawal_requests_connection_entities"], - ) - ), - ) + requester=requester, typename="AccountToWithdrawalRequestsConnection", count=obj["account_to_withdrawal_requests_connection_count"], + page_info=PageInfo_from_json(requester, obj["account_to_withdrawal_requests_connection_page_info"]), + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: WithdrawalRequest_from_json(requester, e), obj["account_to_withdrawal_requests_connection_entities"])), + + ) + diff --git a/lightspark/objects/ApiToken.py b/lightspark/objects/ApiToken.py index 2b0aa31..1998e06 100644 --- a/lightspark/objects/ApiToken.py +++ b/lightspark/objects/ApiToken.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -40,6 +41,7 @@ class ApiToken(AuditLogActor, Entity): """Whether the api token has been deleted.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "ApiToken", @@ -50,9 +52,12 @@ def to_json(self) -> Mapping[str, Any]: "api_token_name": self.name, "api_token_permissions": [e.value for e in self.permissions], "api_token_is_deleted": self.is_deleted, + } + + FRAGMENT = """ fragment ApiTokenFragment on ApiToken { __typename @@ -67,15 +72,16 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> ApiToken: return ApiToken( - requester=requester, - typename="ApiToken", - id=obj["api_token_id"], + requester=requester, typename="ApiToken", id=obj["api_token_id"], 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"]), is_deleted=obj["api_token_is_deleted"], - ) + + ) + diff --git a/lightspark/objects/AuditLogActor.py b/lightspark/objects/AuditLogActor.py index 661ce7d..3f478ca 100644 --- a/lightspark/objects/AuditLogActor.py +++ b/lightspark/objects/AuditLogActor.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -28,15 +29,19 @@ class AuditLogActor(Entity): """The date and time when the entity was last updated.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": self.typename, "audit_log_actor_id": self.id, "audit_log_actor_created_at": self.created_at.isoformat(), "audit_log_actor_updated_at": self.updated_at.isoformat(), + } + + FRAGMENT = """ fragment AuditLogActorFragment on AuditLogActor { __typename @@ -54,24 +59,20 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> AuditLogActor: if obj["__typename"] == "ApiToken": - # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel from lightspark.objects.ApiToken import ApiToken - return ApiToken( - requester=requester, - typename="ApiToken", - id=obj["api_token_id"], + requester=requester, typename="ApiToken", id=obj["api_token_id"], 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"]), is_deleted=obj["api_token_is_deleted"], + ) graphql_typename = obj["__typename"] - raise LightsparkException( - "UNKNOWN_INTERFACE", - f"Couldn't find a concrete type for interface AuditLogActor corresponding to the typename={graphql_typename}", - ) + raise LightsparkException("UNKNOWN_INTERFACE", f"Couldn't find a concrete type for interface AuditLogActor corresponding to the typename={graphql_typename}") diff --git a/lightspark/objects/Balances.py b/lightspark/objects/Balances.py index b2c4bfc..e5069f8 100644 --- a/lightspark/objects/Balances.py +++ b/lightspark/objects/Balances.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,7 +11,7 @@ @dataclass -class Balances: +class Balances(): """This is an object representing the balance associated with your Lightspark account. You can retrieve this object to see your balance, which can be broken down into several different categorizations.""" requester: Requester @@ -30,14 +31,19 @@ class Balances: It represents the amount currently available to withdraw and is usually equal to the `owned_balance` but it does not include in-flight operations (which would likely succeed and therefore likely make your withdrawal fail).""" + + def to_json(self) -> Mapping[str, Any]: return { "balances_owned_balance": self.owned_balance.to_json(), "balances_available_to_send_balance": self.available_to_send_balance.to_json(), "balances_available_to_withdraw_balance": self.available_to_withdraw_balance.to_json(), + } + + FRAGMENT = """ fragment BalancesFragment on Balances { __typename @@ -69,16 +75,12 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> Balances: return Balances( - requester=requester, - owned_balance=CurrencyAmount_from_json( - requester, obj["balances_owned_balance"] - ), - available_to_send_balance=CurrencyAmount_from_json( - requester, obj["balances_available_to_send_balance"] - ), - available_to_withdraw_balance=CurrencyAmount_from_json( - requester, obj["balances_available_to_withdraw_balance"] - ), - ) + requester=requester, owned_balance=CurrencyAmount_from_json(requester, obj["balances_owned_balance"]), + available_to_send_balance=CurrencyAmount_from_json(requester, obj["balances_available_to_send_balance"]), + available_to_withdraw_balance=CurrencyAmount_from_json(requester, obj["balances_available_to_withdraw_balance"]), + + ) + diff --git a/lightspark/objects/BitcoinNetwork.py b/lightspark/objects/BitcoinNetwork.py index c7e8638..116d297 100644 --- a/lightspark/objects/BitcoinNetwork.py +++ b/lightspark/objects/BitcoinNetwork.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -16,3 +17,4 @@ class BitcoinNetwork(Enum): """A test version of the Bitcoin Blockchain, maintained by a centralized organization. Not in use at Lightspark.""" TESTNET = "TESTNET" """A test version of the Bitcoin Blockchain, publicly available.""" + diff --git a/lightspark/objects/BlockchainBalance.py b/lightspark/objects/BlockchainBalance.py index 92d23fd..bce92e4 100644 --- a/lightspark/objects/BlockchainBalance.py +++ b/lightspark/objects/BlockchainBalance.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,7 +11,7 @@ @dataclass -class BlockchainBalance: +class BlockchainBalance(): """This is an object representing a detailed breakdown of the balance for a Lightspark Node.""" requester: Requester @@ -33,29 +34,22 @@ class BlockchainBalance: available_balance: Optional[CurrencyAmount] """Funds available for creating channels or withdrawing.""" + + def to_json(self) -> Mapping[str, Any]: return { - "blockchain_balance_total_balance": ( - self.total_balance.to_json() if self.total_balance else None - ), - "blockchain_balance_confirmed_balance": ( - self.confirmed_balance.to_json() if self.confirmed_balance else None - ), - "blockchain_balance_unconfirmed_balance": ( - self.unconfirmed_balance.to_json() if self.unconfirmed_balance else None - ), - "blockchain_balance_locked_balance": ( - self.locked_balance.to_json() if self.locked_balance else None - ), - "blockchain_balance_required_reserve": ( - self.required_reserve.to_json() if self.required_reserve else None - ), - "blockchain_balance_available_balance": ( - self.available_balance.to_json() if self.available_balance else None - ), + "blockchain_balance_total_balance": self.total_balance.to_json() if self.total_balance else None, + "blockchain_balance_confirmed_balance": self.confirmed_balance.to_json() if self.confirmed_balance else None, + "blockchain_balance_unconfirmed_balance": self.unconfirmed_balance.to_json() if self.unconfirmed_balance else None, + "blockchain_balance_locked_balance": self.locked_balance.to_json() if self.locked_balance else None, + "blockchain_balance_required_reserve": self.required_reserve.to_json() if self.required_reserve else None, + "blockchain_balance_available_balance": self.available_balance.to_json() if self.available_balance else None, + } + + FRAGMENT = """ fragment BlockchainBalanceFragment on BlockchainBalance { __typename @@ -111,47 +105,15 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> BlockchainBalance: return BlockchainBalance( - requester=requester, - total_balance=( - CurrencyAmount_from_json(requester, obj["blockchain_balance_total_balance"]) - if obj["blockchain_balance_total_balance"] - else None - ), - confirmed_balance=( - CurrencyAmount_from_json( - requester, obj["blockchain_balance_confirmed_balance"] - ) - if obj["blockchain_balance_confirmed_balance"] - else None - ), - unconfirmed_balance=( - CurrencyAmount_from_json( - requester, obj["blockchain_balance_unconfirmed_balance"] - ) - if obj["blockchain_balance_unconfirmed_balance"] - else None - ), - locked_balance=( - CurrencyAmount_from_json( - requester, obj["blockchain_balance_locked_balance"] - ) - if obj["blockchain_balance_locked_balance"] - else None - ), - required_reserve=( - CurrencyAmount_from_json( - requester, obj["blockchain_balance_required_reserve"] - ) - if obj["blockchain_balance_required_reserve"] - else None - ), - available_balance=( - CurrencyAmount_from_json( - requester, obj["blockchain_balance_available_balance"] - ) - if obj["blockchain_balance_available_balance"] - else None - ), - ) + requester=requester, total_balance=CurrencyAmount_from_json(requester, obj["blockchain_balance_total_balance"]) if obj["blockchain_balance_total_balance"] else None, + confirmed_balance=CurrencyAmount_from_json(requester, obj["blockchain_balance_confirmed_balance"]) if obj["blockchain_balance_confirmed_balance"] else None, + unconfirmed_balance=CurrencyAmount_from_json(requester, obj["blockchain_balance_unconfirmed_balance"]) if obj["blockchain_balance_unconfirmed_balance"] else None, + locked_balance=CurrencyAmount_from_json(requester, obj["blockchain_balance_locked_balance"]) if obj["blockchain_balance_locked_balance"] else None, + required_reserve=CurrencyAmount_from_json(requester, obj["blockchain_balance_required_reserve"]) if obj["blockchain_balance_required_reserve"] else None, + available_balance=CurrencyAmount_from_json(requester, obj["blockchain_balance_available_balance"]) if obj["blockchain_balance_available_balance"] else None, + + ) + diff --git a/lightspark/objects/CancelInvoiceInput.py b/lightspark/objects/CancelInvoiceInput.py index 35a8bba..4a5fb3a 100644 --- a/lightspark/objects/CancelInvoiceInput.py +++ b/lightspark/objects/CancelInvoiceInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,18 +6,29 @@ @dataclass -class CancelInvoiceInput: +class CancelInvoiceInput(): """The unique identifier of the Invoice that should be cancelled. The invoice is supposed to be open, not settled and not expired.""" + invoice_id: str + + + def to_json(self) -> Mapping[str, Any]: return { "cancel_invoice_input_invoice_id": self.invoice_id, + } + + + + def from_json(obj: Mapping[str, Any]) -> CancelInvoiceInput: return CancelInvoiceInput( invoice_id=obj["cancel_invoice_input_invoice_id"], - ) + + ) + diff --git a/lightspark/objects/CancelInvoiceOutput.py b/lightspark/objects/CancelInvoiceOutput.py index cf2d0a1..69031e7 100644 --- a/lightspark/objects/CancelInvoiceOutput.py +++ b/lightspark/objects/CancelInvoiceOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,19 +8,25 @@ @dataclass -class CancelInvoiceOutput: +class CancelInvoiceOutput(): """The Invoice that was cancelled. If the invoice was already cancelled, the same invoice is returned.""" requester: Requester invoice_id: str + + + def to_json(self) -> Mapping[str, Any]: return { - "cancel_invoice_output_invoice": {"id": self.invoice_id}, + "cancel_invoice_output_invoice": { "id": self.invoice_id }, + } + + FRAGMENT = """ fragment CancelInvoiceOutputFragment on CancelInvoiceOutput { __typename @@ -30,8 +37,10 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> CancelInvoiceOutput: return CancelInvoiceOutput( - requester=requester, - invoice_id=obj["cancel_invoice_output_invoice"]["id"], - ) + requester=requester, invoice_id=obj["cancel_invoice_output_invoice"]["id"], + + ) + diff --git a/lightspark/objects/Channel.py b/lightspark/objects/Channel.py index 453887c..0ae6678 100644 --- a/lightspark/objects/Channel.py +++ b/lightspark/objects/Channel.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -11,9 +12,8 @@ from .ChannelFees import from_json as ChannelFees_from_json from .ChannelStatus import ChannelStatus from .ChannelToTransactionsConnection import ChannelToTransactionsConnection -from .ChannelToTransactionsConnection import ( - from_json as ChannelToTransactionsConnection_from_json, -) +from .ChannelToTransactionsConnection import \ + from_json as ChannelToTransactionsConnection_from_json from .CurrencyAmount import CurrencyAmount from .CurrencyAmount import from_json as CurrencyAmount_from_json from .Entity import Entity @@ -81,11 +81,7 @@ class Channel(Entity): """The unique identifier of the channel on Lightning Network, which is the location in the chain that the channel was confirmed. The format is ::.""" typename: str - def get_uptime_percentage( - self, - after_date: Optional[datetime] = None, - before_date: Optional[datetime] = None, - ) -> Optional[int]: + def get_uptime_percentage(self, after_date: Optional[datetime]= None, before_date: Optional[datetime]= None) -> Optional[int]: json = self.requester.execute_graphql( """ query FetchChannelUptimePercentage($entity_id: ID!, $after_date: DateTime, $before_date: DateTime) { @@ -96,21 +92,12 @@ def get_uptime_percentage( } } """, - { - "entity_id": self.id, - "after_date": after_date, - "before_date": before_date, - }, + {"entity_id": self.id, "after_date": after_date, "before_date": before_date} ) connection = json["entity"]["uptime_percentage"] return connection - def get_transactions( - self, - types: Optional[List[TransactionType]] = None, - after_date: Optional[datetime] = None, - before_date: Optional[datetime] = None, - ) -> ChannelToTransactionsConnection: + def get_transactions(self, types: Optional[List[TransactionType]]= None, after_date: Optional[datetime]= None, before_date: Optional[datetime]= None) -> ChannelToTransactionsConnection: json = self.requester.execute_graphql( """ query FetchChannelToTransactionsConnection($entity_id: ID!, $types: [TransactionType!], $after_date: DateTime, $before_date: DateTime) { @@ -148,64 +135,39 @@ def get_transactions( } } """, - { - "entity_id": self.id, - "types": types, - "after_date": after_date, - "before_date": before_date, - }, + {"entity_id": self.id, "types": types, "after_date": after_date, "before_date": before_date} ) connection = json["entity"]["transactions"] return ChannelToTransactionsConnection_from_json(self.requester, connection) + def to_json(self) -> Mapping[str, Any]: return { "__typename": "Channel", "channel_id": self.id, "channel_created_at": self.created_at.isoformat(), "channel_updated_at": self.updated_at.isoformat(), - "channel_funding_transaction": ( - {"id": self.funding_transaction_id} - if self.funding_transaction_id - else None - ), + "channel_funding_transaction": { "id": self.funding_transaction_id } if self.funding_transaction_id else None, "channel_capacity": self.capacity.to_json() if self.capacity else None, - "channel_local_balance": ( - self.local_balance.to_json() if self.local_balance else None - ), - "channel_local_unsettled_balance": ( - self.local_unsettled_balance.to_json() - if self.local_unsettled_balance - else None - ), - "channel_remote_balance": ( - self.remote_balance.to_json() if self.remote_balance else None - ), - "channel_remote_unsettled_balance": ( - self.remote_unsettled_balance.to_json() - if self.remote_unsettled_balance - else None - ), - "channel_unsettled_balance": ( - self.unsettled_balance.to_json() if self.unsettled_balance else None - ), - "channel_total_balance": ( - self.total_balance.to_json() if self.total_balance else None - ), + "channel_local_balance": self.local_balance.to_json() if self.local_balance else None, + "channel_local_unsettled_balance": self.local_unsettled_balance.to_json() if self.local_unsettled_balance else None, + "channel_remote_balance": self.remote_balance.to_json() if self.remote_balance else None, + "channel_remote_unsettled_balance": self.remote_unsettled_balance.to_json() if self.remote_unsettled_balance else None, + "channel_unsettled_balance": self.unsettled_balance.to_json() if self.unsettled_balance else None, + "channel_total_balance": self.total_balance.to_json() if self.total_balance else None, "channel_status": self.status.value if self.status else None, "channel_estimated_force_closure_wait_minutes": self.estimated_force_closure_wait_minutes, - "channel_commit_fee": ( - self.commit_fee.to_json() if self.commit_fee else None - ), + "channel_commit_fee": self.commit_fee.to_json() if self.commit_fee else None, "channel_fees": self.fees.to_json() if self.fees else None, - "channel_remote_node": ( - {"id": self.remote_node_id} if self.remote_node_id else None - ), - "channel_local_node": {"id": self.local_node_id}, + "channel_remote_node": { "id": self.remote_node_id } if self.remote_node_id else None, + "channel_local_node": { "id": self.local_node_id }, "channel_short_channel_id": self.short_channel_id, + } + + FRAGMENT = """ fragment ChannelFragment on Channel { __typename @@ -304,70 +266,28 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> Channel: return Channel( - requester=requester, - typename="Channel", - id=obj["channel_id"], + requester=requester, typename="Channel", id=obj["channel_id"], 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 - ), - capacity=( - CurrencyAmount_from_json(requester, obj["channel_capacity"]) - if obj["channel_capacity"] - else None - ), - local_balance=( - CurrencyAmount_from_json(requester, obj["channel_local_balance"]) - if obj["channel_local_balance"] - else None - ), - local_unsettled_balance=( - CurrencyAmount_from_json(requester, obj["channel_local_unsettled_balance"]) - if obj["channel_local_unsettled_balance"] - else None - ), - remote_balance=( - CurrencyAmount_from_json(requester, obj["channel_remote_balance"]) - if obj["channel_remote_balance"] - else None - ), - remote_unsettled_balance=( - CurrencyAmount_from_json(requester, obj["channel_remote_unsettled_balance"]) - if obj["channel_remote_unsettled_balance"] - else None - ), - unsettled_balance=( - CurrencyAmount_from_json(requester, obj["channel_unsettled_balance"]) - if obj["channel_unsettled_balance"] - else None - ), - total_balance=( - CurrencyAmount_from_json(requester, obj["channel_total_balance"]) - if obj["channel_total_balance"] - else None - ), - status=parse_enum_optional(ChannelStatus, obj["channel_status"]), - estimated_force_closure_wait_minutes=obj[ - "channel_estimated_force_closure_wait_minutes" - ], - commit_fee=( - CurrencyAmount_from_json(requester, obj["channel_commit_fee"]) - if obj["channel_commit_fee"] - else None - ), - fees=( - ChannelFees_from_json(requester, obj["channel_fees"]) - if obj["channel_fees"] - else None - ), - remote_node_id=( - obj["channel_remote_node"]["id"] if obj["channel_remote_node"] else None - ), + funding_transaction_id=obj["channel_funding_transaction"]["id"] if obj["channel_funding_transaction"] else None, + capacity=CurrencyAmount_from_json(requester, obj["channel_capacity"]) if obj["channel_capacity"] else None, + local_balance=CurrencyAmount_from_json(requester, obj["channel_local_balance"]) if obj["channel_local_balance"] else None, + local_unsettled_balance=CurrencyAmount_from_json(requester, obj["channel_local_unsettled_balance"]) if obj["channel_local_unsettled_balance"] else None, + remote_balance=CurrencyAmount_from_json(requester, obj["channel_remote_balance"]) if obj["channel_remote_balance"] else None, + remote_unsettled_balance=CurrencyAmount_from_json(requester, obj["channel_remote_unsettled_balance"]) if obj["channel_remote_unsettled_balance"] else None, + unsettled_balance=CurrencyAmount_from_json(requester, obj["channel_unsettled_balance"]) if obj["channel_unsettled_balance"] else None, + total_balance=CurrencyAmount_from_json(requester, obj["channel_total_balance"]) if obj["channel_total_balance"] else None, + + status=parse_enum_optional(ChannelStatus, obj['channel_status']), + estimated_force_closure_wait_minutes=obj["channel_estimated_force_closure_wait_minutes"], + commit_fee=CurrencyAmount_from_json(requester, obj["channel_commit_fee"]) if obj["channel_commit_fee"] else None, + fees=ChannelFees_from_json(requester, obj["channel_fees"]) if obj["channel_fees"] else None, + remote_node_id=obj["channel_remote_node"]["id"] if obj["channel_remote_node"] else None, local_node_id=obj["channel_local_node"]["id"], short_channel_id=obj["channel_short_channel_id"], - ) + + ) + diff --git a/lightspark/objects/ChannelClosingTransaction.py b/lightspark/objects/ChannelClosingTransaction.py index b43e972..501689b 100644 --- a/lightspark/objects/ChannelClosingTransaction.py +++ b/lightspark/objects/ChannelClosingTransaction.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -61,6 +62,7 @@ class ChannelClosingTransaction(OnChainTransaction, Transaction, Entity): """If known, the channel this transaction is closing.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "ChannelClosingTransaction", @@ -68,24 +70,21 @@ def to_json(self) -> Mapping[str, Any]: "channel_closing_transaction_created_at": self.created_at.isoformat(), "channel_closing_transaction_updated_at": self.updated_at.isoformat(), "channel_closing_transaction_status": self.status.value, - "channel_closing_transaction_resolved_at": ( - self.resolved_at.isoformat() if self.resolved_at else None - ), + "channel_closing_transaction_resolved_at": self.resolved_at.isoformat() if self.resolved_at else None, "channel_closing_transaction_amount": self.amount.to_json(), "channel_closing_transaction_transaction_hash": self.transaction_hash, - "channel_closing_transaction_fees": ( - self.fees.to_json() if self.fees else None - ), + "channel_closing_transaction_fees": self.fees.to_json() if self.fees else None, "channel_closing_transaction_block_hash": self.block_hash, "channel_closing_transaction_block_height": self.block_height, "channel_closing_transaction_destination_addresses": self.destination_addresses, "channel_closing_transaction_num_confirmations": self.num_confirmations, - "channel_closing_transaction_channel": ( - {"id": self.channel_id} if self.channel_id else None - ), + "channel_closing_transaction_channel": { "id": self.channel_id } if self.channel_id else None, + } + + FRAGMENT = """ fragment ChannelClosingTransactionFragment on ChannelClosingTransaction { __typename @@ -122,41 +121,23 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> ChannelClosingTransaction: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> ChannelClosingTransaction: return ChannelClosingTransaction( - requester=requester, - typename="ChannelClosingTransaction", - id=obj["channel_closing_transaction_id"], - 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=( - 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"] - ), + requester=requester, typename="ChannelClosingTransaction", id=obj["channel_closing_transaction_id"], + 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=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"]), transaction_hash=obj["channel_closing_transaction_transaction_hash"], - fees=( - CurrencyAmount_from_json(requester, obj["channel_closing_transaction_fees"]) - if obj["channel_closing_transaction_fees"] - else None - ), + fees=CurrencyAmount_from_json(requester, obj["channel_closing_transaction_fees"]) if obj["channel_closing_transaction_fees"] else None, block_hash=obj["channel_closing_transaction_block_hash"], block_height=obj["channel_closing_transaction_block_height"], destination_addresses=obj["channel_closing_transaction_destination_addresses"], num_confirmations=obj["channel_closing_transaction_num_confirmations"], - channel_id=( - obj["channel_closing_transaction_channel"]["id"] - if obj["channel_closing_transaction_channel"] - else None - ), - ) + channel_id=obj["channel_closing_transaction_channel"]["id"] if obj["channel_closing_transaction_channel"] else None, + + ) + diff --git a/lightspark/objects/ChannelFees.py b/lightspark/objects/ChannelFees.py index c9bcba2..a3c10b5 100644 --- a/lightspark/objects/ChannelFees.py +++ b/lightspark/objects/ChannelFees.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,22 +11,29 @@ @dataclass -class ChannelFees: +class ChannelFees(): """This represents the fee policies set for a channel on the Lightning Network.""" requester: Requester base_fee: Optional[CurrencyAmount] + fee_rate_per_mil: Optional[int] + + + def to_json(self) -> Mapping[str, Any]: return { "channel_fees_base_fee": self.base_fee.to_json() if self.base_fee else None, "channel_fees_fee_rate_per_mil": self.fee_rate_per_mil, + } + + FRAGMENT = """ fragment ChannelFeesFragment on ChannelFees { __typename @@ -42,13 +50,11 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> ChannelFees: return ChannelFees( - requester=requester, - base_fee=( - CurrencyAmount_from_json(requester, obj["channel_fees_base_fee"]) - if obj["channel_fees_base_fee"] - else None - ), + requester=requester, base_fee=CurrencyAmount_from_json(requester, obj["channel_fees_base_fee"]) if obj["channel_fees_base_fee"] else None, fee_rate_per_mil=obj["channel_fees_fee_rate_per_mil"], - ) + + ) + diff --git a/lightspark/objects/ChannelOpeningTransaction.py b/lightspark/objects/ChannelOpeningTransaction.py index 40fa1a6..7300079 100644 --- a/lightspark/objects/ChannelOpeningTransaction.py +++ b/lightspark/objects/ChannelOpeningTransaction.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -61,6 +62,7 @@ class ChannelOpeningTransaction(OnChainTransaction, Transaction, Entity): """If known, the channel this transaction is opening.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "ChannelOpeningTransaction", @@ -68,24 +70,21 @@ def to_json(self) -> Mapping[str, Any]: "channel_opening_transaction_created_at": self.created_at.isoformat(), "channel_opening_transaction_updated_at": self.updated_at.isoformat(), "channel_opening_transaction_status": self.status.value, - "channel_opening_transaction_resolved_at": ( - self.resolved_at.isoformat() if self.resolved_at else None - ), + "channel_opening_transaction_resolved_at": self.resolved_at.isoformat() if self.resolved_at else None, "channel_opening_transaction_amount": self.amount.to_json(), "channel_opening_transaction_transaction_hash": self.transaction_hash, - "channel_opening_transaction_fees": ( - self.fees.to_json() if self.fees else None - ), + "channel_opening_transaction_fees": self.fees.to_json() if self.fees else None, "channel_opening_transaction_block_hash": self.block_hash, "channel_opening_transaction_block_height": self.block_height, "channel_opening_transaction_destination_addresses": self.destination_addresses, "channel_opening_transaction_num_confirmations": self.num_confirmations, - "channel_opening_transaction_channel": ( - {"id": self.channel_id} if self.channel_id else None - ), + "channel_opening_transaction_channel": { "id": self.channel_id } if self.channel_id else None, + } + + FRAGMENT = """ fragment ChannelOpeningTransactionFragment on ChannelOpeningTransaction { __typename @@ -122,41 +121,23 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> ChannelOpeningTransaction: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> ChannelOpeningTransaction: return ChannelOpeningTransaction( - requester=requester, - typename="ChannelOpeningTransaction", - id=obj["channel_opening_transaction_id"], - 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=( - 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"] - ), + requester=requester, typename="ChannelOpeningTransaction", id=obj["channel_opening_transaction_id"], + 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=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"]), transaction_hash=obj["channel_opening_transaction_transaction_hash"], - fees=( - CurrencyAmount_from_json(requester, obj["channel_opening_transaction_fees"]) - if obj["channel_opening_transaction_fees"] - else None - ), + fees=CurrencyAmount_from_json(requester, obj["channel_opening_transaction_fees"]) if obj["channel_opening_transaction_fees"] else None, block_hash=obj["channel_opening_transaction_block_hash"], block_height=obj["channel_opening_transaction_block_height"], destination_addresses=obj["channel_opening_transaction_destination_addresses"], num_confirmations=obj["channel_opening_transaction_num_confirmations"], - channel_id=( - obj["channel_opening_transaction_channel"]["id"] - if obj["channel_opening_transaction_channel"] - else None - ), - ) + channel_id=obj["channel_opening_transaction_channel"]["id"] if obj["channel_opening_transaction_channel"] else None, + + ) + diff --git a/lightspark/objects/ChannelSnapshot.py b/lightspark/objects/ChannelSnapshot.py index 8e52ca0..7ce4832 100644 --- a/lightspark/objects/ChannelSnapshot.py +++ b/lightspark/objects/ChannelSnapshot.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -13,6 +14,7 @@ @dataclass class ChannelSnapshot(Entity): + requester: Requester id: str @@ -25,56 +27,51 @@ class ChannelSnapshot(Entity): """The date and time when the entity was last updated.""" local_balance: Optional[CurrencyAmount] + local_unsettled_balance: Optional[CurrencyAmount] + remote_balance: Optional[CurrencyAmount] + remote_unsettled_balance: Optional[CurrencyAmount] + status: Optional[str] + channel_id: str + local_channel_reserve: Optional[CurrencyAmount] + timestamp: datetime """The timestamp that was used to query the snapshot of the channel""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "ChannelSnapshot", "channel_snapshot_id": self.id, "channel_snapshot_created_at": self.created_at.isoformat(), "channel_snapshot_updated_at": self.updated_at.isoformat(), - "channel_snapshot_local_balance": ( - self.local_balance.to_json() if self.local_balance else None - ), - "channel_snapshot_local_unsettled_balance": ( - self.local_unsettled_balance.to_json() - if self.local_unsettled_balance - else None - ), - "channel_snapshot_remote_balance": ( - self.remote_balance.to_json() if self.remote_balance else None - ), - "channel_snapshot_remote_unsettled_balance": ( - self.remote_unsettled_balance.to_json() - if self.remote_unsettled_balance - else None - ), + "channel_snapshot_local_balance": self.local_balance.to_json() if self.local_balance else None, + "channel_snapshot_local_unsettled_balance": self.local_unsettled_balance.to_json() if self.local_unsettled_balance else None, + "channel_snapshot_remote_balance": self.remote_balance.to_json() if self.remote_balance else None, + "channel_snapshot_remote_unsettled_balance": self.remote_unsettled_balance.to_json() if self.remote_unsettled_balance else None, "channel_snapshot_status": self.status, - "channel_snapshot_channel": {"id": self.channel_id}, - "channel_snapshot_local_channel_reserve": ( - self.local_channel_reserve.to_json() - if self.local_channel_reserve - else None - ), + "channel_snapshot_channel": { "id": self.channel_id }, + "channel_snapshot_local_channel_reserve": self.local_channel_reserve.to_json() if self.local_channel_reserve else None, "channel_snapshot_timestamp": self.timestamp.isoformat(), + } + + FRAGMENT = """ fragment ChannelSnapshotFragment on ChannelSnapshot { __typename @@ -130,45 +127,20 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> ChannelSnapshot: return ChannelSnapshot( - requester=requester, - typename="ChannelSnapshot", - id=obj["channel_snapshot_id"], + requester=requester, typename="ChannelSnapshot", id=obj["channel_snapshot_id"], created_at=datetime.fromisoformat(obj["channel_snapshot_created_at"]), updated_at=datetime.fromisoformat(obj["channel_snapshot_updated_at"]), - local_balance=( - CurrencyAmount_from_json(requester, obj["channel_snapshot_local_balance"]) - if obj["channel_snapshot_local_balance"] - else None - ), - local_unsettled_balance=( - CurrencyAmount_from_json( - requester, obj["channel_snapshot_local_unsettled_balance"] - ) - if obj["channel_snapshot_local_unsettled_balance"] - else None - ), - remote_balance=( - CurrencyAmount_from_json(requester, obj["channel_snapshot_remote_balance"]) - if obj["channel_snapshot_remote_balance"] - else None - ), - remote_unsettled_balance=( - CurrencyAmount_from_json( - requester, obj["channel_snapshot_remote_unsettled_balance"] - ) - if obj["channel_snapshot_remote_unsettled_balance"] - else None - ), + local_balance=CurrencyAmount_from_json(requester, obj["channel_snapshot_local_balance"]) if obj["channel_snapshot_local_balance"] else None, + local_unsettled_balance=CurrencyAmount_from_json(requester, obj["channel_snapshot_local_unsettled_balance"]) if obj["channel_snapshot_local_unsettled_balance"] else None, + remote_balance=CurrencyAmount_from_json(requester, obj["channel_snapshot_remote_balance"]) if obj["channel_snapshot_remote_balance"] else None, + remote_unsettled_balance=CurrencyAmount_from_json(requester, obj["channel_snapshot_remote_unsettled_balance"]) if obj["channel_snapshot_remote_unsettled_balance"] else None, status=obj["channel_snapshot_status"], channel_id=obj["channel_snapshot_channel"]["id"], - local_channel_reserve=( - CurrencyAmount_from_json( - requester, obj["channel_snapshot_local_channel_reserve"] - ) - if obj["channel_snapshot_local_channel_reserve"] - else None - ), + local_channel_reserve=CurrencyAmount_from_json(requester, obj["channel_snapshot_local_channel_reserve"]) if obj["channel_snapshot_local_channel_reserve"] else None, timestamp=datetime.fromisoformat(obj["channel_snapshot_timestamp"]), - ) + + ) + diff --git a/lightspark/objects/ChannelStatus.py b/lightspark/objects/ChannelStatus.py index fef579d..379b5ff 100644 --- a/lightspark/objects/ChannelStatus.py +++ b/lightspark/objects/ChannelStatus.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -22,3 +23,4 @@ class ChannelStatus(Enum): """The channel has been closed. Information about the channel is still available for historical purposes but the channel cannot be used anymore.""" ERROR = "ERROR" """Something unexpected happened and we cannot determine the status of this channel. Please try again later or contact the support.""" + diff --git a/lightspark/objects/ChannelToTransactionsConnection.py b/lightspark/objects/ChannelToTransactionsConnection.py index 3140dea..d3eb330 100644 --- a/lightspark/objects/ChannelToTransactionsConnection.py +++ b/lightspark/objects/ChannelToTransactionsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,7 +11,8 @@ @dataclass -class ChannelToTransactionsConnection: +class ChannelToTransactionsConnection(): + requester: Requester count: int @@ -25,23 +27,20 @@ class ChannelToTransactionsConnection: total_fees: Optional[CurrencyAmount] """The total amount of fees for the transactions that transited through this channel, according to the filters and constraints of the connection.""" + + def to_json(self) -> Mapping[str, Any]: return { "channel_to_transactions_connection_count": self.count, - "channel_to_transactions_connection_average_fee": ( - self.average_fee.to_json() if self.average_fee else None - ), - "channel_to_transactions_connection_total_amount_transacted": ( - self.total_amount_transacted.to_json() - if self.total_amount_transacted - else None - ), - "channel_to_transactions_connection_total_fees": ( - self.total_fees.to_json() if self.total_fees else None - ), + "channel_to_transactions_connection_average_fee": self.average_fee.to_json() if self.average_fee else None, + "channel_to_transactions_connection_total_amount_transacted": self.total_amount_transacted.to_json() if self.total_amount_transacted else None, + "channel_to_transactions_connection_total_fees": self.total_fees.to_json() if self.total_fees else None, + } + + FRAGMENT = """ fragment ChannelToTransactionsConnectionFragment on ChannelToTransactionsConnection { __typename @@ -74,32 +73,13 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> ChannelToTransactionsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> ChannelToTransactionsConnection: return ChannelToTransactionsConnection( - requester=requester, - count=obj["channel_to_transactions_connection_count"], - average_fee=( - CurrencyAmount_from_json( - requester, obj["channel_to_transactions_connection_average_fee"] - ) - if obj["channel_to_transactions_connection_average_fee"] - else None - ), - total_amount_transacted=( - CurrencyAmount_from_json( - requester, - obj["channel_to_transactions_connection_total_amount_transacted"], - ) - if obj["channel_to_transactions_connection_total_amount_transacted"] - else None - ), - total_fees=( - CurrencyAmount_from_json( - requester, obj["channel_to_transactions_connection_total_fees"] - ) - if obj["channel_to_transactions_connection_total_fees"] - else None - ), - ) + requester=requester, count=obj["channel_to_transactions_connection_count"], + average_fee=CurrencyAmount_from_json(requester, obj["channel_to_transactions_connection_average_fee"]) if obj["channel_to_transactions_connection_average_fee"] else None, + total_amount_transacted=CurrencyAmount_from_json(requester, obj["channel_to_transactions_connection_total_amount_transacted"]) if obj["channel_to_transactions_connection_total_amount_transacted"] else None, + total_fees=CurrencyAmount_from_json(requester, obj["channel_to_transactions_connection_total_fees"]) if obj["channel_to_transactions_connection_total_fees"] else None, + + ) + diff --git a/lightspark/objects/ClaimUmaInvitationInput.py b/lightspark/objects/ClaimUmaInvitationInput.py index 4d5dee3..79f407f 100644 --- a/lightspark/objects/ClaimUmaInvitationInput.py +++ b/lightspark/objects/ClaimUmaInvitationInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,22 +6,33 @@ @dataclass -class ClaimUmaInvitationInput: +class ClaimUmaInvitationInput(): + + invitation_code: str """The unique code that identifies this invitation and was shared by the inviter.""" invitee_uma: str """The UMA of the user claiming the invitation. It will be sent to the inviter so that they can start transacting with the invitee.""" + + def to_json(self) -> Mapping[str, Any]: return { "claim_uma_invitation_input_invitation_code": self.invitation_code, "claim_uma_invitation_input_invitee_uma": self.invitee_uma, + } + + + + def from_json(obj: Mapping[str, Any]) -> ClaimUmaInvitationInput: return ClaimUmaInvitationInput( invitation_code=obj["claim_uma_invitation_input_invitation_code"], invitee_uma=obj["claim_uma_invitation_input_invitee_uma"], - ) + + ) + diff --git a/lightspark/objects/ClaimUmaInvitationOutput.py b/lightspark/objects/ClaimUmaInvitationOutput.py index 2077b78..008c8ec 100644 --- a/lightspark/objects/ClaimUmaInvitationOutput.py +++ b/lightspark/objects/ClaimUmaInvitationOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,18 +8,24 @@ @dataclass -class ClaimUmaInvitationOutput: +class ClaimUmaInvitationOutput(): + requester: Requester invitation_id: str """An UMA.ME invitation object.""" + + def to_json(self) -> Mapping[str, Any]: return { - "claim_uma_invitation_output_invitation": {"id": self.invitation_id}, + "claim_uma_invitation_output_invitation": { "id": self.invitation_id }, + } + + FRAGMENT = """ fragment ClaimUmaInvitationOutputFragment on ClaimUmaInvitationOutput { __typename @@ -29,8 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> ClaimUmaInvitationOutput: return ClaimUmaInvitationOutput( - requester=requester, - invitation_id=obj["claim_uma_invitation_output_invitation"]["id"], - ) + requester=requester, invitation_id=obj["claim_uma_invitation_output_invitation"]["id"], + + ) + diff --git a/lightspark/objects/ClaimUmaInvitationWithIncentivesInput.py b/lightspark/objects/ClaimUmaInvitationWithIncentivesInput.py index 8503677..00865e6 100644 --- a/lightspark/objects/ClaimUmaInvitationWithIncentivesInput.py +++ b/lightspark/objects/ClaimUmaInvitationWithIncentivesInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -9,7 +10,9 @@ @dataclass -class ClaimUmaInvitationWithIncentivesInput: +class ClaimUmaInvitationWithIncentivesInput(): + + invitation_code: str """The unique code that identifies this invitation and was shared by the inviter.""" @@ -22,25 +25,29 @@ class ClaimUmaInvitationWithIncentivesInput: invitee_region: RegionCode """The region of the user getting the invitation.""" + + def to_json(self) -> Mapping[str, Any]: return { "claim_uma_invitation_with_incentives_input_invitation_code": self.invitation_code, "claim_uma_invitation_with_incentives_input_invitee_uma": self.invitee_uma, "claim_uma_invitation_with_incentives_input_invitee_phone_hash": self.invitee_phone_hash, "claim_uma_invitation_with_incentives_input_invitee_region": self.invitee_region.value, + } + + + + def from_json(obj: Mapping[str, Any]) -> ClaimUmaInvitationWithIncentivesInput: return ClaimUmaInvitationWithIncentivesInput( - invitation_code=obj[ - "claim_uma_invitation_with_incentives_input_invitation_code" - ], + invitation_code=obj["claim_uma_invitation_with_incentives_input_invitation_code"], invitee_uma=obj["claim_uma_invitation_with_incentives_input_invitee_uma"], - invitee_phone_hash=obj[ - "claim_uma_invitation_with_incentives_input_invitee_phone_hash" - ], - invitee_region=parse_enum( - RegionCode, obj["claim_uma_invitation_with_incentives_input_invitee_region"] - ), - ) + invitee_phone_hash=obj["claim_uma_invitation_with_incentives_input_invitee_phone_hash"], + + invitee_region=parse_enum(RegionCode, obj['claim_uma_invitation_with_incentives_input_invitee_region']), + + ) + diff --git a/lightspark/objects/ClaimUmaInvitationWithIncentivesOutput.py b/lightspark/objects/ClaimUmaInvitationWithIncentivesOutput.py index 6a35f68..a5dae7c 100644 --- a/lightspark/objects/ClaimUmaInvitationWithIncentivesOutput.py +++ b/lightspark/objects/ClaimUmaInvitationWithIncentivesOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,20 +8,24 @@ @dataclass -class ClaimUmaInvitationWithIncentivesOutput: +class ClaimUmaInvitationWithIncentivesOutput(): + requester: Requester invitation_id: str """An UMA.ME invitation object.""" + + def to_json(self) -> Mapping[str, Any]: return { - "claim_uma_invitation_with_incentives_output_invitation": { - "id": self.invitation_id - }, + "claim_uma_invitation_with_incentives_output_invitation": { "id": self.invitation_id }, + } + + FRAGMENT = """ fragment ClaimUmaInvitationWithIncentivesOutputFragment on ClaimUmaInvitationWithIncentivesOutput { __typename @@ -31,12 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> ClaimUmaInvitationWithIncentivesOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> ClaimUmaInvitationWithIncentivesOutput: return ClaimUmaInvitationWithIncentivesOutput( - requester=requester, - invitation_id=obj["claim_uma_invitation_with_incentives_output_invitation"][ - "id" - ], - ) + requester=requester, invitation_id=obj["claim_uma_invitation_with_incentives_output_invitation"]["id"], + + ) + diff --git a/lightspark/objects/ComplianceProvider.py b/lightspark/objects/ComplianceProvider.py index 598449d..318e573 100644 --- a/lightspark/objects/ComplianceProvider.py +++ b/lightspark/objects/ComplianceProvider.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -9,3 +10,4 @@ class ComplianceProvider(Enum): ___FUTURE_VALUE___ = "___FUTURE_VALUE___" """This is an enum value that represents future values that could be added in the future. Clients should support unknown values as more of them could be added without notice.""" CHAINALYSIS = "CHAINALYSIS" + diff --git a/lightspark/objects/Connection.py b/lightspark/objects/Connection.py index 0dc46fd..f03a352 100644 --- a/lightspark/objects/Connection.py +++ b/lightspark/objects/Connection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -8,7 +9,8 @@ @dataclass -class Connection: +class Connection(): + requester: Requester count: int @@ -19,6 +21,9 @@ class Connection: typename: str + + + FRAGMENT = """ fragment ConnectionFragment on Connection { __typename @@ -272,3 +277,6 @@ class Connection: } } """ + + + diff --git a/lightspark/objects/CreateApiTokenInput.py b/lightspark/objects/CreateApiTokenInput.py index e8d2603..202b742 100644 --- a/lightspark/objects/CreateApiTokenInput.py +++ b/lightspark/objects/CreateApiTokenInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -9,24 +10,33 @@ @dataclass -class CreateApiTokenInput: +class CreateApiTokenInput(): + + name: str """An arbitrary name that the user can choose to identify the API token in a list.""" permissions: List[Permission] """List of permissions to grant to the API token""" + + def to_json(self) -> Mapping[str, Any]: return { "create_api_token_input_name": self.name, "create_api_token_input_permissions": [e.value for e in self.permissions], + } + + + + def from_json(obj: Mapping[str, Any]) -> CreateApiTokenInput: return CreateApiTokenInput( name=obj["create_api_token_input_name"], - permissions=parse_enum_list( - Permission, obj["create_api_token_input_permissions"] - ), - ) + permissions=parse_enum_list(Permission, obj["create_api_token_input_permissions"]), + + ) + diff --git a/lightspark/objects/CreateApiTokenOutput.py b/lightspark/objects/CreateApiTokenOutput.py index 1c51855..76dfe78 100644 --- a/lightspark/objects/CreateApiTokenOutput.py +++ b/lightspark/objects/CreateApiTokenOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,7 +11,8 @@ @dataclass -class CreateApiTokenOutput: +class CreateApiTokenOutput(): + requester: Requester api_token: ApiToken @@ -20,13 +22,18 @@ class CreateApiTokenOutput: """The secret that should be used to authenticate against our API. This secret is not stored and will never be available again after this. You must keep this secret secure as it grants access to your account.""" + + def to_json(self) -> Mapping[str, Any]: return { "create_api_token_output_api_token": self.api_token.to_json(), "create_api_token_output_client_secret": self.client_secret, + } + + FRAGMENT = """ fragment CreateApiTokenOutputFragment on CreateApiTokenOutput { __typename @@ -45,11 +52,11 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> CreateApiTokenOutput: return CreateApiTokenOutput( - requester=requester, - api_token=ApiToken_from_json( - requester, obj["create_api_token_output_api_token"] - ), + requester=requester, api_token=ApiToken_from_json(requester, obj["create_api_token_output_api_token"]), client_secret=obj["create_api_token_output_client_secret"], - ) + + ) + diff --git a/lightspark/objects/CreateInvitationWithIncentivesInput.py b/lightspark/objects/CreateInvitationWithIncentivesInput.py index a596174..4821964 100644 --- a/lightspark/objects/CreateInvitationWithIncentivesInput.py +++ b/lightspark/objects/CreateInvitationWithIncentivesInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -9,7 +10,9 @@ @dataclass -class CreateInvitationWithIncentivesInput: +class CreateInvitationWithIncentivesInput(): + + inviter_uma: str """The UMA of the user creating the invitation. It will be used to identify the inviter when receiving the invitation.""" @@ -19,21 +22,27 @@ class CreateInvitationWithIncentivesInput: inviter_region: RegionCode """The region of the user creating the invitation.""" + + def to_json(self) -> Mapping[str, Any]: return { "create_invitation_with_incentives_input_inviter_uma": self.inviter_uma, "create_invitation_with_incentives_input_inviter_phone_hash": self.inviter_phone_hash, "create_invitation_with_incentives_input_inviter_region": self.inviter_region.value, + } + + + + def from_json(obj: Mapping[str, Any]) -> CreateInvitationWithIncentivesInput: return CreateInvitationWithIncentivesInput( inviter_uma=obj["create_invitation_with_incentives_input_inviter_uma"], - inviter_phone_hash=obj[ - "create_invitation_with_incentives_input_inviter_phone_hash" - ], - inviter_region=parse_enum( - RegionCode, obj["create_invitation_with_incentives_input_inviter_region"] - ), - ) + inviter_phone_hash=obj["create_invitation_with_incentives_input_inviter_phone_hash"], + + inviter_region=parse_enum(RegionCode, obj['create_invitation_with_incentives_input_inviter_region']), + + ) + diff --git a/lightspark/objects/CreateInvitationWithIncentivesOutput.py b/lightspark/objects/CreateInvitationWithIncentivesOutput.py index c3a6764..ad64156 100644 --- a/lightspark/objects/CreateInvitationWithIncentivesOutput.py +++ b/lightspark/objects/CreateInvitationWithIncentivesOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,20 +8,24 @@ @dataclass -class CreateInvitationWithIncentivesOutput: +class CreateInvitationWithIncentivesOutput(): + requester: Requester invitation_id: str """The created invitation in the form of a string identifier.""" + + def to_json(self) -> Mapping[str, Any]: return { - "create_invitation_with_incentives_output_invitation": { - "id": self.invitation_id - }, + "create_invitation_with_incentives_output_invitation": { "id": self.invitation_id }, + } + + FRAGMENT = """ fragment CreateInvitationWithIncentivesOutputFragment on CreateInvitationWithIncentivesOutput { __typename @@ -31,10 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> CreateInvitationWithIncentivesOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> CreateInvitationWithIncentivesOutput: return CreateInvitationWithIncentivesOutput( - requester=requester, - invitation_id=obj["create_invitation_with_incentives_output_invitation"]["id"], - ) + requester=requester, invitation_id=obj["create_invitation_with_incentives_output_invitation"]["id"], + + ) + diff --git a/lightspark/objects/CreateInvoiceInput.py b/lightspark/objects/CreateInvoiceInput.py index 340efe3..54b7d71 100644 --- a/lightspark/objects/CreateInvoiceInput.py +++ b/lightspark/objects/CreateInvoiceInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -9,7 +10,9 @@ @dataclass -class CreateInvoiceInput: +class CreateInvoiceInput(): + + node_id: str """The node from which to create the invoice.""" @@ -17,31 +20,49 @@ class CreateInvoiceInput: """The amount for which the invoice should be created, in millisatoshis. Setting the amount to 0 will allow the payer to specify an amount.""" memo: Optional[str] + invoice_type: Optional[InvoiceType] + expiry_secs: Optional[int] - """The expiry of the invoice in seconds. Default value is 86400 (1 day).""" + """The expiry of the invoice in seconds. Default value is 86400 (1 day) for AMP invoice, or 3600 (1 hour) for STANDARD invoice.""" + + payment_hash: Optional[str] + """The payment hash of the invoice. It should only be set if your node is a remote signing node. If not set, it will be requested through REMOTE_SIGNING webhooks with sub event type REQUEST_INVOICE_PAYMENT_HASH.""" + + preimage_nonce: Optional[str] + """The 32-byte nonce used to generate the invoice preimage if applicable. It will later be included in RELEASE_PAYMENT_PREIMAGE webhook to help recover the raw preimage. This can only be specified when `payment_hash` is specified.""" + + def to_json(self) -> Mapping[str, Any]: return { "create_invoice_input_node_id": self.node_id, "create_invoice_input_amount_msats": self.amount_msats, "create_invoice_input_memo": self.memo, - "create_invoice_input_invoice_type": ( - self.invoice_type.value if self.invoice_type else None - ), + "create_invoice_input_invoice_type": self.invoice_type.value if self.invoice_type else None, "create_invoice_input_expiry_secs": self.expiry_secs, + "create_invoice_input_payment_hash": self.payment_hash, + "create_invoice_input_preimage_nonce": self.preimage_nonce, + } + + + + def from_json(obj: Mapping[str, Any]) -> CreateInvoiceInput: return CreateInvoiceInput( node_id=obj["create_invoice_input_node_id"], amount_msats=obj["create_invoice_input_amount_msats"], memo=obj["create_invoice_input_memo"], - invoice_type=parse_enum_optional( - InvoiceType, obj["create_invoice_input_invoice_type"] - ), + + invoice_type=parse_enum_optional(InvoiceType, obj['create_invoice_input_invoice_type']), expiry_secs=obj["create_invoice_input_expiry_secs"], - ) + payment_hash=obj["create_invoice_input_payment_hash"], + preimage_nonce=obj["create_invoice_input_preimage_nonce"], + + ) + diff --git a/lightspark/objects/CreateInvoiceOutput.py b/lightspark/objects/CreateInvoiceOutput.py index 2601f45..658e890 100644 --- a/lightspark/objects/CreateInvoiceOutput.py +++ b/lightspark/objects/CreateInvoiceOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,17 +8,24 @@ @dataclass -class CreateInvoiceOutput: +class CreateInvoiceOutput(): + requester: Requester invoice_id: str + + + def to_json(self) -> Mapping[str, Any]: return { - "create_invoice_output_invoice": {"id": self.invoice_id}, + "create_invoice_output_invoice": { "id": self.invoice_id }, + } + + FRAGMENT = """ fragment CreateInvoiceOutputFragment on CreateInvoiceOutput { __typename @@ -28,8 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> CreateInvoiceOutput: return CreateInvoiceOutput( - requester=requester, - invoice_id=obj["create_invoice_output_invoice"]["id"], - ) + requester=requester, invoice_id=obj["create_invoice_output_invoice"]["id"], + + ) + diff --git a/lightspark/objects/CreateLnurlInvoiceInput.py b/lightspark/objects/CreateLnurlInvoiceInput.py index 3b748f7..b40a8ff 100644 --- a/lightspark/objects/CreateLnurlInvoiceInput.py +++ b/lightspark/objects/CreateLnurlInvoiceInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,7 +6,9 @@ @dataclass -class CreateLnurlInvoiceInput: +class CreateLnurlInvoiceInput(): + + node_id: str """The node from which to create the invoice.""" @@ -21,6 +24,8 @@ class CreateLnurlInvoiceInput: receiver_hash: Optional[str] """An optional, monthly-rotated, unique hashed identifier corresponding to the receiver of the payment.""" + + def to_json(self) -> Mapping[str, Any]: return { "create_lnurl_invoice_input_node_id": self.node_id, @@ -28,9 +33,14 @@ def to_json(self) -> Mapping[str, Any]: "create_lnurl_invoice_input_metadata_hash": self.metadata_hash, "create_lnurl_invoice_input_expiry_secs": self.expiry_secs, "create_lnurl_invoice_input_receiver_hash": self.receiver_hash, + } + + + + def from_json(obj: Mapping[str, Any]) -> CreateLnurlInvoiceInput: return CreateLnurlInvoiceInput( node_id=obj["create_lnurl_invoice_input_node_id"], @@ -38,4 +48,6 @@ def from_json(obj: Mapping[str, Any]) -> CreateLnurlInvoiceInput: metadata_hash=obj["create_lnurl_invoice_input_metadata_hash"], expiry_secs=obj["create_lnurl_invoice_input_expiry_secs"], receiver_hash=obj["create_lnurl_invoice_input_receiver_hash"], - ) + + ) + diff --git a/lightspark/objects/CreateNodeWalletAddressInput.py b/lightspark/objects/CreateNodeWalletAddressInput.py index 9425e2e..d823110 100644 --- a/lightspark/objects/CreateNodeWalletAddressInput.py +++ b/lightspark/objects/CreateNodeWalletAddressInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,16 +6,28 @@ @dataclass -class CreateNodeWalletAddressInput: +class CreateNodeWalletAddressInput(): + + node_id: str + + + def to_json(self) -> Mapping[str, Any]: return { "create_node_wallet_address_input_node_id": self.node_id, + } + + + + def from_json(obj: Mapping[str, Any]) -> CreateNodeWalletAddressInput: return CreateNodeWalletAddressInput( node_id=obj["create_node_wallet_address_input_node_id"], - ) + + ) + diff --git a/lightspark/objects/CreateNodeWalletAddressOutput.py b/lightspark/objects/CreateNodeWalletAddressOutput.py index be4dd0b..b12a58d 100644 --- a/lightspark/objects/CreateNodeWalletAddressOutput.py +++ b/lightspark/objects/CreateNodeWalletAddressOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,37 +6,39 @@ from lightspark.requests.requester import Requester -from .MultiSigAddressValidationParameters import MultiSigAddressValidationParameters -from .MultiSigAddressValidationParameters import ( - from_json as MultiSigAddressValidationParameters_from_json, -) +from .MultiSigAddressValidationParameters import \ + MultiSigAddressValidationParameters +from .MultiSigAddressValidationParameters import \ + from_json as MultiSigAddressValidationParameters_from_json @dataclass -class CreateNodeWalletAddressOutput: +class CreateNodeWalletAddressOutput(): + requester: Requester node_id: str + wallet_address: str + - multisig_wallet_address_validation_parameters: Optional[ - MultiSigAddressValidationParameters - ] + multisig_wallet_address_validation_parameters: Optional[MultiSigAddressValidationParameters] """Vaildation parameters for the 2-of-2 multisig address. None if the address is not a 2-of-2 multisig address.""" + + def to_json(self) -> Mapping[str, Any]: return { - "create_node_wallet_address_output_node": {"id": self.node_id}, + "create_node_wallet_address_output_node": { "id": self.node_id }, "create_node_wallet_address_output_wallet_address": self.wallet_address, - "create_node_wallet_address_output_multisig_wallet_address_validation_parameters": ( - self.multisig_wallet_address_validation_parameters.to_json() - if self.multisig_wallet_address_validation_parameters - else None - ), + "create_node_wallet_address_output_multisig_wallet_address_validation_parameters": self.multisig_wallet_address_validation_parameters.to_json() if self.multisig_wallet_address_validation_parameters else None, + } + + FRAGMENT = """ fragment CreateNodeWalletAddressOutputFragment on CreateNodeWalletAddressOutput { __typename @@ -52,23 +55,12 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> CreateNodeWalletAddressOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> CreateNodeWalletAddressOutput: return CreateNodeWalletAddressOutput( - requester=requester, - node_id=obj["create_node_wallet_address_output_node"]["id"], + requester=requester, node_id=obj["create_node_wallet_address_output_node"]["id"], wallet_address=obj["create_node_wallet_address_output_wallet_address"], - multisig_wallet_address_validation_parameters=( - MultiSigAddressValidationParameters_from_json( - requester, - obj[ - "create_node_wallet_address_output_multisig_wallet_address_validation_parameters" - ], - ) - if obj[ - "create_node_wallet_address_output_multisig_wallet_address_validation_parameters" - ] - else None - ), - ) + multisig_wallet_address_validation_parameters=MultiSigAddressValidationParameters_from_json(requester, obj["create_node_wallet_address_output_multisig_wallet_address_validation_parameters"]) if obj["create_node_wallet_address_output_multisig_wallet_address_validation_parameters"] else None, + + ) + diff --git a/lightspark/objects/CreateOfferInput.py b/lightspark/objects/CreateOfferInput.py new file mode 100644 index 0000000..0e013ee --- /dev/null +++ b/lightspark/objects/CreateOfferInput.py @@ -0,0 +1,43 @@ + +# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved + +from dataclasses import dataclass +from typing import Any, Mapping, Optional + + +@dataclass +class CreateOfferInput(): + + + node_id: str + """The node from which to create the offer.""" + + amount_msats: Optional[int] + """The amount for which the offer should be created, in millisatoshis. Setting the amount to 0 will allow the payer to specify an amount.""" + + description: Optional[str] + """A short description of the offer.""" + + + + def to_json(self) -> Mapping[str, Any]: + return { + "create_offer_input_node_id": self.node_id, + "create_offer_input_amount_msats": self.amount_msats, + "create_offer_input_description": self.description, + + } + + + + + + +def from_json(obj: Mapping[str, Any]) -> CreateOfferInput: + return CreateOfferInput( + node_id=obj["create_offer_input_node_id"], + amount_msats=obj["create_offer_input_amount_msats"], + description=obj["create_offer_input_description"], + + ) + diff --git a/lightspark/objects/CreateOfferOutput.py b/lightspark/objects/CreateOfferOutput.py new file mode 100644 index 0000000..0e2e2b5 --- /dev/null +++ b/lightspark/objects/CreateOfferOutput.py @@ -0,0 +1,45 @@ + +# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved + +from dataclasses import dataclass +from typing import Any, Mapping + +from lightspark.requests.requester import Requester + + +@dataclass +class CreateOfferOutput(): + + requester: Requester + + offer_id: str + + + + + def to_json(self) -> Mapping[str, Any]: + return { + "create_offer_output_offer": { "id": self.offer_id }, + + } + + + + +FRAGMENT = """ +fragment CreateOfferOutputFragment on CreateOfferOutput { + __typename + create_offer_output_offer: offer { + id + } +} +""" + + + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> CreateOfferOutput: + return CreateOfferOutput( + requester=requester, offer_id=obj["create_offer_output_offer"]["id"], + + ) + diff --git a/lightspark/objects/CreateTestModeInvoiceInput.py b/lightspark/objects/CreateTestModeInvoiceInput.py index be96011..1ba5511 100644 --- a/lightspark/objects/CreateTestModeInvoiceInput.py +++ b/lightspark/objects/CreateTestModeInvoiceInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -9,32 +10,44 @@ @dataclass -class CreateTestModeInvoiceInput: +class CreateTestModeInvoiceInput(): + + local_node_id: str + """The local node from which to create the invoice.""" amount_msats: int + """The amount for which the invoice should be created, in millisatoshis. Setting the amount to 0 will allow the payer to specify an amount.""" memo: Optional[str] + """An optional memo to include in the invoice.""" invoice_type: Optional[InvoiceType] + """The type of invoice to create.""" + + def to_json(self) -> Mapping[str, Any]: return { "create_test_mode_invoice_input_local_node_id": self.local_node_id, "create_test_mode_invoice_input_amount_msats": self.amount_msats, "create_test_mode_invoice_input_memo": self.memo, - "create_test_mode_invoice_input_invoice_type": ( - self.invoice_type.value if self.invoice_type else None - ), + "create_test_mode_invoice_input_invoice_type": self.invoice_type.value if self.invoice_type else None, + } + + + + def from_json(obj: Mapping[str, Any]) -> CreateTestModeInvoiceInput: return CreateTestModeInvoiceInput( local_node_id=obj["create_test_mode_invoice_input_local_node_id"], amount_msats=obj["create_test_mode_invoice_input_amount_msats"], memo=obj["create_test_mode_invoice_input_memo"], - invoice_type=parse_enum_optional( - InvoiceType, obj["create_test_mode_invoice_input_invoice_type"] - ), - ) + + invoice_type=parse_enum_optional(InvoiceType, obj['create_test_mode_invoice_input_invoice_type']), + + ) + diff --git a/lightspark/objects/CreateTestModeInvoiceOutput.py b/lightspark/objects/CreateTestModeInvoiceOutput.py index ac3e96d..ba7a97c 100644 --- a/lightspark/objects/CreateTestModeInvoiceOutput.py +++ b/lightspark/objects/CreateTestModeInvoiceOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,17 +8,24 @@ @dataclass -class CreateTestModeInvoiceOutput: +class CreateTestModeInvoiceOutput(): + requester: Requester encoded_payment_request: str + + + def to_json(self) -> Mapping[str, Any]: return { "create_test_mode_invoice_output_encoded_payment_request": self.encoded_payment_request, + } + + FRAGMENT = """ fragment CreateTestModeInvoiceOutputFragment on CreateTestModeInvoiceOutput { __typename @@ -26,12 +34,10 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> CreateTestModeInvoiceOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> CreateTestModeInvoiceOutput: return CreateTestModeInvoiceOutput( - requester=requester, - encoded_payment_request=obj[ - "create_test_mode_invoice_output_encoded_payment_request" - ], - ) + requester=requester, encoded_payment_request=obj["create_test_mode_invoice_output_encoded_payment_request"], + + ) + diff --git a/lightspark/objects/CreateTestModePaymentInput.py b/lightspark/objects/CreateTestModePaymentInput.py index 0c71eb6..c1f9d8c 100644 --- a/lightspark/objects/CreateTestModePaymentInput.py +++ b/lightspark/objects/CreateTestModePaymentInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,7 +6,9 @@ @dataclass -class CreateTestModePaymentInput: +class CreateTestModePaymentInput(): + + local_node_id: str """The node to where you want to send the payment.""" @@ -15,17 +18,26 @@ class CreateTestModePaymentInput: amount_msats: Optional[int] """The amount you will be paid for this invoice, expressed in msats. It should ONLY be set when the invoice amount is zero.""" + + def to_json(self) -> Mapping[str, Any]: return { "create_test_mode_payment_input_local_node_id": self.local_node_id, "create_test_mode_payment_input_encoded_invoice": self.encoded_invoice, "create_test_mode_payment_input_amount_msats": self.amount_msats, + } + + + + def from_json(obj: Mapping[str, Any]) -> CreateTestModePaymentInput: return CreateTestModePaymentInput( local_node_id=obj["create_test_mode_payment_input_local_node_id"], encoded_invoice=obj["create_test_mode_payment_input_encoded_invoice"], amount_msats=obj["create_test_mode_payment_input_amount_msats"], - ) + + ) + diff --git a/lightspark/objects/CreateTestModePaymentoutput.py b/lightspark/objects/CreateTestModePaymentoutput.py index 26b0bf9..9e903c7 100644 --- a/lightspark/objects/CreateTestModePaymentoutput.py +++ b/lightspark/objects/CreateTestModePaymentoutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,7 +8,7 @@ @dataclass -class CreateTestModePaymentoutput: +class CreateTestModePaymentoutput(): """This is an object identifying the output of a test mode payment. This object can be used to retrieve the associated payment made from a Test Mode Payment call.""" requester: Requester @@ -18,15 +19,18 @@ class CreateTestModePaymentoutput: incoming_payment_id: str """The payment that has been received.""" + + def to_json(self) -> Mapping[str, Any]: return { - "create_test_mode_paymentoutput_payment": {"id": self.payment_id}, - "create_test_mode_paymentoutput_incoming_payment": { - "id": self.incoming_payment_id - }, + "create_test_mode_paymentoutput_payment": { "id": self.payment_id }, + "create_test_mode_paymentoutput_incoming_payment": { "id": self.incoming_payment_id }, + } + + FRAGMENT = """ fragment CreateTestModePaymentoutputFragment on CreateTestModePaymentoutput { __typename @@ -40,13 +44,11 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> CreateTestModePaymentoutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> CreateTestModePaymentoutput: return CreateTestModePaymentoutput( - requester=requester, - payment_id=obj["create_test_mode_paymentoutput_payment"]["id"], - incoming_payment_id=obj["create_test_mode_paymentoutput_incoming_payment"][ - "id" - ], - ) + requester=requester, payment_id=obj["create_test_mode_paymentoutput_payment"]["id"], + incoming_payment_id=obj["create_test_mode_paymentoutput_incoming_payment"]["id"], + + ) + diff --git a/lightspark/objects/CreateUmaInvitationInput.py b/lightspark/objects/CreateUmaInvitationInput.py index 881c2c6..4a68c62 100644 --- a/lightspark/objects/CreateUmaInvitationInput.py +++ b/lightspark/objects/CreateUmaInvitationInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,17 +6,28 @@ @dataclass -class CreateUmaInvitationInput: +class CreateUmaInvitationInput(): + + inviter_uma: str """The UMA of the user creating the invitation. It will be used to identify the inviter when receiving the invitation.""" + + def to_json(self) -> Mapping[str, Any]: return { "create_uma_invitation_input_inviter_uma": self.inviter_uma, + } + + + + def from_json(obj: Mapping[str, Any]) -> CreateUmaInvitationInput: return CreateUmaInvitationInput( inviter_uma=obj["create_uma_invitation_input_inviter_uma"], - ) + + ) + diff --git a/lightspark/objects/CreateUmaInvitationOutput.py b/lightspark/objects/CreateUmaInvitationOutput.py index e93cf97..51a7a27 100644 --- a/lightspark/objects/CreateUmaInvitationOutput.py +++ b/lightspark/objects/CreateUmaInvitationOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,18 +8,24 @@ @dataclass -class CreateUmaInvitationOutput: +class CreateUmaInvitationOutput(): + requester: Requester invitation_id: str """The created invitation in the form of a string identifier.""" + + def to_json(self) -> Mapping[str, Any]: return { - "create_uma_invitation_output_invitation": {"id": self.invitation_id}, + "create_uma_invitation_output_invitation": { "id": self.invitation_id }, + } + + FRAGMENT = """ fragment CreateUmaInvitationOutputFragment on CreateUmaInvitationOutput { __typename @@ -29,10 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> CreateUmaInvitationOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> CreateUmaInvitationOutput: return CreateUmaInvitationOutput( - requester=requester, - invitation_id=obj["create_uma_invitation_output_invitation"]["id"], - ) + requester=requester, invitation_id=obj["create_uma_invitation_output_invitation"]["id"], + + ) + diff --git a/lightspark/objects/CreateUmaInvoiceInput.py b/lightspark/objects/CreateUmaInvoiceInput.py index 2b70e09..05414c6 100644 --- a/lightspark/objects/CreateUmaInvoiceInput.py +++ b/lightspark/objects/CreateUmaInvoiceInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,7 +6,9 @@ @dataclass -class CreateUmaInvoiceInput: +class CreateUmaInvoiceInput(): + + node_id: str """The node from which to create the invoice.""" @@ -21,6 +24,8 @@ class CreateUmaInvoiceInput: receiver_hash: Optional[str] """An optional, monthly-rotated, unique hashed identifier corresponding to the receiver of the payment.""" + + def to_json(self) -> Mapping[str, Any]: return { "create_uma_invoice_input_node_id": self.node_id, @@ -28,9 +33,14 @@ def to_json(self) -> Mapping[str, Any]: "create_uma_invoice_input_metadata_hash": self.metadata_hash, "create_uma_invoice_input_expiry_secs": self.expiry_secs, "create_uma_invoice_input_receiver_hash": self.receiver_hash, + } + + + + def from_json(obj: Mapping[str, Any]) -> CreateUmaInvoiceInput: return CreateUmaInvoiceInput( node_id=obj["create_uma_invoice_input_node_id"], @@ -38,4 +48,6 @@ def from_json(obj: Mapping[str, Any]) -> CreateUmaInvoiceInput: metadata_hash=obj["create_uma_invoice_input_metadata_hash"], expiry_secs=obj["create_uma_invoice_input_expiry_secs"], receiver_hash=obj["create_uma_invoice_input_receiver_hash"], - ) + + ) + diff --git a/lightspark/objects/CurrencyAmount.py b/lightspark/objects/CurrencyAmount.py index 92bc2f6..5b19945 100644 --- a/lightspark/objects/CurrencyAmount.py +++ b/lightspark/objects/CurrencyAmount.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -11,7 +12,7 @@ @dataclass -class CurrencyAmount: +class CurrencyAmount(): """This object represents the value and unit for an amount of currency.""" requester: Requester @@ -31,6 +32,8 @@ class CurrencyAmount: preferred_currency_value_approx: float """The approximate float value for this CurrencyAmount in the very base level of user's preferred currency. For example, for USD, the value will be in cents.""" + + def to_json(self) -> Mapping[str, Any]: return { "currency_amount_original_value": self.original_value, @@ -38,8 +41,10 @@ def to_json(self) -> Mapping[str, Any]: "currency_amount_preferred_currency_unit": self.preferred_currency_unit.value, "currency_amount_preferred_currency_value_rounded": self.preferred_currency_value_rounded, "currency_amount_preferred_currency_value_approx": self.preferred_currency_value_approx, + } + _CONVERSION_MAP = { CurrencyUnit.BITCOIN: { CurrencyUnit.BITCOIN: lambda v: v, @@ -91,14 +96,12 @@ def to_json(self) -> Mapping[str, Any]: }, } + def convert_to(self, unit: CurrencyUnit) -> "CurrencyAmount": try: conversion_fn = self._CONVERSION_MAP[self.original_unit][unit] except KeyError as e: - raise LightsparkException( - "CONVERSION_ERROR", - f"Cannot convert from {self.original_unit} to {unit}", - ) from e + raise LightsparkException("CONVERSION_ERROR", f"Cannot convert from {self.original_unit} to {unit}") from e return CurrencyAmount( requester=self.requester, original_unit=self.original_unit, @@ -106,7 +109,8 @@ def convert_to(self, unit: CurrencyUnit) -> "CurrencyAmount": preferred_currency_value_rounded=conversion_fn(self.original_value), preferred_currency_value_approx=conversion_fn(self.original_value), preferred_currency_unit=unit, - ) + ) + FRAGMENT = """ @@ -121,18 +125,16 @@ def convert_to(self, unit: CurrencyUnit) -> "CurrencyAmount": """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> CurrencyAmount: return CurrencyAmount( - requester=requester, - original_value=obj["currency_amount_original_value"], - original_unit=parse_enum(CurrencyUnit, obj["currency_amount_original_unit"]), - preferred_currency_unit=parse_enum( - CurrencyUnit, obj["currency_amount_preferred_currency_unit"] - ), - preferred_currency_value_rounded=obj[ - "currency_amount_preferred_currency_value_rounded" - ], - preferred_currency_value_approx=obj[ - "currency_amount_preferred_currency_value_approx" - ], - ) + requester=requester, original_value=obj["currency_amount_original_value"], + + original_unit=parse_enum(CurrencyUnit, obj['currency_amount_original_unit']), + + preferred_currency_unit=parse_enum(CurrencyUnit, obj['currency_amount_preferred_currency_unit']), + preferred_currency_value_rounded=obj["currency_amount_preferred_currency_value_rounded"], + preferred_currency_value_approx=obj["currency_amount_preferred_currency_value_approx"], + + ) + diff --git a/lightspark/objects/CurrencyAmountInput.py b/lightspark/objects/CurrencyAmountInput.py new file mode 100644 index 0000000..038fa17 --- /dev/null +++ b/lightspark/objects/CurrencyAmountInput.py @@ -0,0 +1,43 @@ + +# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved + +from dataclasses import dataclass +from typing import Any, Mapping + +from lightspark.utils.enums import parse_enum + +from .CurrencyUnit import CurrencyUnit + + +@dataclass +class CurrencyAmountInput(): + + + value: int + + + unit: CurrencyUnit + + + + + def to_json(self) -> Mapping[str, Any]: + return { + "currency_amount_input_value": self.value, + "currency_amount_input_unit": self.unit.value, + + } + + + + + + +def from_json(obj: Mapping[str, Any]) -> CurrencyAmountInput: + return CurrencyAmountInput( + value=obj["currency_amount_input_value"], + + unit=parse_enum(CurrencyUnit, obj['currency_amount_input_unit']), + + ) + diff --git a/lightspark/objects/CurrencyUnit.py b/lightspark/objects/CurrencyUnit.py index 158a351..8f9f539 100644 --- a/lightspark/objects/CurrencyUnit.py +++ b/lightspark/objects/CurrencyUnit.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -18,9 +19,14 @@ class CurrencyUnit(Enum): """United States Dollar.""" MXN = "MXN" """Mexican Peso.""" + PHP = "PHP" + """Philippine Peso.""" + EUR = "EUR" + """Euro.""" NANOBITCOIN = "NANOBITCOIN" """0.000000001 (10e-9) Bitcoin or a billionth of a Bitcoin. We recommend using the Satoshi unit instead when possible.""" MICROBITCOIN = "MICROBITCOIN" """0.000001 (10e-6) Bitcoin or a millionth of a Bitcoin. We recommend using the Satoshi unit instead when possible.""" MILLIBITCOIN = "MILLIBITCOIN" """0.001 (10e-3) Bitcoin or a thousandth of a Bitcoin. We recommend using the Satoshi unit instead when possible.""" + diff --git a/lightspark/objects/DailyLiquidityForecast.py b/lightspark/objects/DailyLiquidityForecast.py index ab76177..0961ca4 100644 --- a/lightspark/objects/DailyLiquidityForecast.py +++ b/lightspark/objects/DailyLiquidityForecast.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -13,7 +14,8 @@ @dataclass -class DailyLiquidityForecast: +class DailyLiquidityForecast(): + requester: Requester date: datetime @@ -25,14 +27,19 @@ class DailyLiquidityForecast: amount: CurrencyAmount """The value of the forecast. It represents the amount of msats that we think will be moved for that specified direction, for that node, on that date.""" + + def to_json(self) -> Mapping[str, Any]: return { "daily_liquidity_forecast_date": self.date, "daily_liquidity_forecast_direction": self.direction.value, "daily_liquidity_forecast_amount": self.amount.to_json(), + } + + FRAGMENT = """ fragment DailyLiquidityForecastFragment on DailyLiquidityForecast { __typename @@ -50,14 +57,13 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> DailyLiquidityForecast: return DailyLiquidityForecast( - requester=requester, - date=obj["daily_liquidity_forecast_date"], - direction=parse_enum( - LightningPaymentDirection, obj["daily_liquidity_forecast_direction"] - ), - amount=CurrencyAmount_from_json( - requester, obj["daily_liquidity_forecast_amount"] - ), - ) + requester=requester, date=obj["daily_liquidity_forecast_date"], + + direction=parse_enum(LightningPaymentDirection, obj['daily_liquidity_forecast_direction']), + amount=CurrencyAmount_from_json(requester, obj["daily_liquidity_forecast_amount"]), + + ) + diff --git a/lightspark/objects/DeclineToSignMessagesInput.py b/lightspark/objects/DeclineToSignMessagesInput.py index 9ac7c7f..8c37b3a 100644 --- a/lightspark/objects/DeclineToSignMessagesInput.py +++ b/lightspark/objects/DeclineToSignMessagesInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,17 +6,28 @@ @dataclass -class DeclineToSignMessagesInput: +class DeclineToSignMessagesInput(): + + payload_ids: List[str] """List of payload ids to decline to sign because validation failed.""" + + def to_json(self) -> Mapping[str, Any]: return { "decline_to_sign_messages_input_payload_ids": self.payload_ids, + } + + + + def from_json(obj: Mapping[str, Any]) -> DeclineToSignMessagesInput: return DeclineToSignMessagesInput( payload_ids=obj["decline_to_sign_messages_input_payload_ids"], - ) + + ) + diff --git a/lightspark/objects/DeclineToSignMessagesOutput.py b/lightspark/objects/DeclineToSignMessagesOutput.py index 7de917f..cf7f427 100644 --- a/lightspark/objects/DeclineToSignMessagesOutput.py +++ b/lightspark/objects/DeclineToSignMessagesOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,19 +11,24 @@ @dataclass -class DeclineToSignMessagesOutput: +class DeclineToSignMessagesOutput(): + requester: Requester declined_payloads: List[SignablePayload] + + + def to_json(self) -> Mapping[str, Any]: return { - "decline_to_sign_messages_output_declined_payloads": [ - e.to_json() for e in self.declined_payloads - ], + "decline_to_sign_messages_output_declined_payloads": [e.to_json() for e in self.declined_payloads], + } + + FRAGMENT = """ fragment DeclineToSignMessagesOutputFragment on DeclineToSignMessagesOutput { __typename @@ -33,16 +39,12 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> DeclineToSignMessagesOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> DeclineToSignMessagesOutput: return DeclineToSignMessagesOutput( - requester=requester, - declined_payloads=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: SignablePayload_from_json(requester, e), - obj["decline_to_sign_messages_output_declined_payloads"], - ) - ), - ) + requester=requester, declined_payloads=list(map( + # pylint: disable=unnecessary-lambda + lambda e: SignablePayload_from_json(requester, e), obj["decline_to_sign_messages_output_declined_payloads"])), + + ) + diff --git a/lightspark/objects/DeleteApiTokenInput.py b/lightspark/objects/DeleteApiTokenInput.py index 620618b..6347a03 100644 --- a/lightspark/objects/DeleteApiTokenInput.py +++ b/lightspark/objects/DeleteApiTokenInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,16 +6,28 @@ @dataclass -class DeleteApiTokenInput: +class DeleteApiTokenInput(): + + api_token_id: str + + + def to_json(self) -> Mapping[str, Any]: return { "delete_api_token_input_api_token_id": self.api_token_id, + } + + + + def from_json(obj: Mapping[str, Any]) -> DeleteApiTokenInput: return DeleteApiTokenInput( api_token_id=obj["delete_api_token_input_api_token_id"], - ) + + ) + diff --git a/lightspark/objects/DeleteApiTokenOutput.py b/lightspark/objects/DeleteApiTokenOutput.py index 94eb18e..116f2f1 100644 --- a/lightspark/objects/DeleteApiTokenOutput.py +++ b/lightspark/objects/DeleteApiTokenOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,17 +8,24 @@ @dataclass -class DeleteApiTokenOutput: +class DeleteApiTokenOutput(): + requester: Requester account_id: str + + + def to_json(self) -> Mapping[str, Any]: return { - "delete_api_token_output_account": {"id": self.account_id}, + "delete_api_token_output_account": { "id": self.account_id }, + } + + FRAGMENT = """ fragment DeleteApiTokenOutputFragment on DeleteApiTokenOutput { __typename @@ -28,8 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> DeleteApiTokenOutput: return DeleteApiTokenOutput( - requester=requester, - account_id=obj["delete_api_token_output_account"]["id"], - ) + requester=requester, account_id=obj["delete_api_token_output_account"]["id"], + + ) + diff --git a/lightspark/objects/Deposit.py b/lightspark/objects/Deposit.py index 43d088c..eb99367 100644 --- a/lightspark/objects/Deposit.py +++ b/lightspark/objects/Deposit.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -61,6 +62,7 @@ class Deposit(OnChainTransaction, Transaction, Entity): """The recipient Lightspark node this deposit was sent to.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "Deposit", @@ -68,9 +70,7 @@ def to_json(self) -> Mapping[str, Any]: "deposit_created_at": self.created_at.isoformat(), "deposit_updated_at": self.updated_at.isoformat(), "deposit_status": self.status.value, - "deposit_resolved_at": ( - self.resolved_at.isoformat() if self.resolved_at else None - ), + "deposit_resolved_at": self.resolved_at.isoformat() if self.resolved_at else None, "deposit_amount": self.amount.to_json(), "deposit_transaction_hash": self.transaction_hash, "deposit_fees": self.fees.to_json() if self.fees else None, @@ -78,10 +78,13 @@ def to_json(self) -> Mapping[str, Any]: "deposit_block_height": self.block_height, "deposit_destination_addresses": self.destination_addresses, "deposit_num_confirmations": self.num_confirmations, - "deposit_destination": {"id": self.destination_id}, + "deposit_destination": { "id": self.destination_id }, + } + + FRAGMENT = """ fragment DepositFragment on Deposit { __typename @@ -118,29 +121,23 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> Deposit: return Deposit( - requester=requester, - typename="Deposit", - id=obj["deposit_id"], + requester=requester, typename="Deposit", id=obj["deposit_id"], 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=( - datetime.fromisoformat(obj["deposit_resolved_at"]) - if obj["deposit_resolved_at"] - else None - ), + + status=parse_enum(TransactionStatus, obj['deposit_status']), + 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"]) - if obj["deposit_fees"] - else None - ), + fees=CurrencyAmount_from_json(requester, obj["deposit_fees"]) if obj["deposit_fees"] else None, block_hash=obj["deposit_block_hash"], block_height=obj["deposit_block_height"], destination_addresses=obj["deposit_destination_addresses"], num_confirmations=obj["deposit_num_confirmations"], destination_id=obj["deposit_destination"]["id"], - ) + + ) + diff --git a/lightspark/objects/Entity.py b/lightspark/objects/Entity.py index 2e6084b..ca061a9 100644 --- a/lightspark/objects/Entity.py +++ b/lightspark/objects/Entity.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,7 +8,7 @@ @dataclass -class Entity: +class Entity(): """This interface is used by all the entities in the Lightspark system. It defines a few core fields that are available everywhere. Any object that implements this interface can be queried using the `entity` query and its ID.""" requester: Requester @@ -23,6 +24,9 @@ class Entity: typename: str + + + FRAGMENT = """ fragment EntityFragment on Entity { __typename @@ -947,6 +951,42 @@ class Entity: } } } + ... on Offer { + __typename + offer_id: id + offer_created_at: created_at + offer_updated_at: updated_at + offer_data: data { + id + } + offer_encoded_offer: encoded_offer + offer_amount: amount { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + offer_description: description + } + ... on OfferData { + __typename + offer_data_id: id + offer_data_created_at: created_at + offer_data_updated_at: updated_at + offer_data_amount: amount { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + offer_data_encoded_offer: encoded_offer + offer_data_bitcoin_networks: bitcoin_networks + offer_data_expires_at: expires_at + } ... on OutgoingPayment { __typename outgoing_payment_id: id @@ -1522,3 +1562,6 @@ class Entity: } } """ + + + diff --git a/lightspark/objects/FailHtlcsInput.py b/lightspark/objects/FailHtlcsInput.py index 07b3d1a..1afa151 100644 --- a/lightspark/objects/FailHtlcsInput.py +++ b/lightspark/objects/FailHtlcsInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,22 +6,33 @@ @dataclass -class FailHtlcsInput: +class FailHtlcsInput(): + + invoice_id: str """The id of invoice which the pending HTLCs that need to be failed are paying for.""" cancel_invoice: bool """Whether the invoice needs to be canceled after failing the htlcs. If yes, the invoice cannot be paid anymore.""" + + def to_json(self) -> Mapping[str, Any]: return { "fail_htlcs_input_invoice_id": self.invoice_id, "fail_htlcs_input_cancel_invoice": self.cancel_invoice, + } + + + + def from_json(obj: Mapping[str, Any]) -> FailHtlcsInput: return FailHtlcsInput( invoice_id=obj["fail_htlcs_input_invoice_id"], cancel_invoice=obj["fail_htlcs_input_cancel_invoice"], - ) + + ) + diff --git a/lightspark/objects/FailHtlcsOutput.py b/lightspark/objects/FailHtlcsOutput.py index 1bdf34b..9691fa1 100644 --- a/lightspark/objects/FailHtlcsOutput.py +++ b/lightspark/objects/FailHtlcsOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,17 +8,24 @@ @dataclass -class FailHtlcsOutput: +class FailHtlcsOutput(): + requester: Requester invoice_id: str + + + def to_json(self) -> Mapping[str, Any]: return { - "fail_htlcs_output_invoice": {"id": self.invoice_id}, + "fail_htlcs_output_invoice": { "id": self.invoice_id }, + } + + FRAGMENT = """ fragment FailHtlcsOutputFragment on FailHtlcsOutput { __typename @@ -28,8 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> FailHtlcsOutput: return FailHtlcsOutput( - requester=requester, - invoice_id=obj["fail_htlcs_output_invoice"]["id"], - ) + requester=requester, invoice_id=obj["fail_htlcs_output_invoice"]["id"], + + ) + diff --git a/lightspark/objects/FeeEstimate.py b/lightspark/objects/FeeEstimate.py index 8779146..0401c1f 100644 --- a/lightspark/objects/FeeEstimate.py +++ b/lightspark/objects/FeeEstimate.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,22 +11,29 @@ @dataclass -class FeeEstimate: +class FeeEstimate(): """This object represents the estimated L1 transaction fees for the Bitcoin network. Fee estimates are separated by potential confirmation speeds for settlement.""" requester: Requester fee_fast: CurrencyAmount + fee_min: CurrencyAmount + + + def to_json(self) -> Mapping[str, Any]: return { "fee_estimate_fee_fast": self.fee_fast.to_json(), "fee_estimate_fee_min": self.fee_min.to_json(), + } + + FRAGMENT = """ fragment FeeEstimateFragment on FeeEstimate { __typename @@ -49,9 +57,11 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> FeeEstimate: return FeeEstimate( - requester=requester, - fee_fast=CurrencyAmount_from_json(requester, obj["fee_estimate_fee_fast"]), + requester=requester, fee_fast=CurrencyAmount_from_json(requester, obj["fee_estimate_fee_fast"]), fee_min=CurrencyAmount_from_json(requester, obj["fee_estimate_fee_min"]), - ) + + ) + diff --git a/lightspark/objects/FundNodeInput.py b/lightspark/objects/FundNodeInput.py index 626dbd0..faa3486 100644 --- a/lightspark/objects/FundNodeInput.py +++ b/lightspark/objects/FundNodeInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,24 +6,38 @@ @dataclass -class FundNodeInput: +class FundNodeInput(): + + node_id: str + amount_sats: Optional[int] + funding_address: Optional[str] + + + def to_json(self) -> Mapping[str, Any]: return { "fund_node_input_node_id": self.node_id, "fund_node_input_amount_sats": self.amount_sats, "fund_node_input_funding_address": self.funding_address, + } + + + + def from_json(obj: Mapping[str, Any]) -> FundNodeInput: return FundNodeInput( node_id=obj["fund_node_input_node_id"], amount_sats=obj["fund_node_input_amount_sats"], funding_address=obj["fund_node_input_funding_address"], - ) + + ) + diff --git a/lightspark/objects/FundNodeOutput.py b/lightspark/objects/FundNodeOutput.py index 1ef782f..d0672f8 100644 --- a/lightspark/objects/FundNodeOutput.py +++ b/lightspark/objects/FundNodeOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,17 +11,24 @@ @dataclass -class FundNodeOutput: +class FundNodeOutput(): + requester: Requester amount: CurrencyAmount + + + def to_json(self) -> Mapping[str, Any]: return { "fund_node_output_amount": self.amount.to_json(), + } + + FRAGMENT = """ fragment FundNodeOutputFragment on FundNodeOutput { __typename @@ -36,8 +44,10 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> FundNodeOutput: return FundNodeOutput( - requester=requester, - amount=CurrencyAmount_from_json(requester, obj["fund_node_output_amount"]), - ) + requester=requester, amount=CurrencyAmount_from_json(requester, obj["fund_node_output_amount"]), + + ) + diff --git a/lightspark/objects/GraphNode.py b/lightspark/objects/GraphNode.py index 587a6da..9bc1531 100644 --- a/lightspark/objects/GraphNode.py +++ b/lightspark/objects/GraphNode.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -12,7 +13,8 @@ from .Node import Node from .NodeAddressType import NodeAddressType from .NodeToAddressesConnection import NodeToAddressesConnection -from .NodeToAddressesConnection import from_json as NodeToAddressesConnection_from_json +from .NodeToAddressesConnection import \ + from_json as NodeToAddressesConnection_from_json @dataclass @@ -49,9 +51,7 @@ class GraphNode(Node, Entity): """The public key of this node. It acts as a unique identifier of this node in the Lightning Network.""" typename: str - def get_addresses( - self, first: Optional[int] = None, types: Optional[List[NodeAddressType]] = None - ) -> NodeToAddressesConnection: + def get_addresses(self, first: Optional[int]= None, types: Optional[List[NodeAddressType]]= None) -> NodeToAddressesConnection: json = self.requester.execute_graphql( """ query FetchNodeToAddressesConnection($entity_id: ID!, $first: Int, $types: [NodeAddressType!]) { @@ -70,11 +70,12 @@ def get_addresses( } } """, - {"entity_id": self.id, "first": first, "types": types}, + {"entity_id": self.id, "first": first, "types": types} ) connection = json["entity"]["addresses"] return NodeToAddressesConnection_from_json(self.requester, connection) + def to_json(self) -> Mapping[str, Any]: return { "__typename": "GraphNode", @@ -87,9 +88,12 @@ def to_json(self) -> Mapping[str, Any]: "graph_node_conductivity": self.conductivity, "graph_node_display_name": self.display_name, "graph_node_public_key": self.public_key, + } + + FRAGMENT = """ fragment GraphNodeFragment on GraphNode { __typename @@ -106,17 +110,19 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> GraphNode: return GraphNode( - requester=requester, - typename="GraphNode", - id=obj["graph_node_id"], + requester=requester, typename="GraphNode", id=obj["graph_node_id"], 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"]), + + bitcoin_network=parse_enum(BitcoinNetwork, obj['graph_node_bitcoin_network']), color=obj["graph_node_color"], conductivity=obj["graph_node_conductivity"], display_name=obj["graph_node_display_name"], public_key=obj["graph_node_public_key"], - ) + + ) + diff --git a/lightspark/objects/Hop.py b/lightspark/objects/Hop.py index 83260bd..91252e0 100644 --- a/lightspark/objects/Hop.py +++ b/lightspark/objects/Hop.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -45,25 +46,25 @@ class Hop(Entity): """The block height at which an unsettled HTLC is considered expired.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "Hop", "hop_id": self.id, "hop_created_at": self.created_at.isoformat(), "hop_updated_at": self.updated_at.isoformat(), - "hop_destination": ( - {"id": self.destination_id} if self.destination_id else None - ), + "hop_destination": { "id": self.destination_id } if self.destination_id else None, "hop_index": self.index, "hop_public_key": self.public_key, - "hop_amount_to_forward": ( - self.amount_to_forward.to_json() if self.amount_to_forward else None - ), + "hop_amount_to_forward": self.amount_to_forward.to_json() if self.amount_to_forward else None, "hop_fee": self.fee.to_json() if self.fee else None, "hop_expiry_block_height": self.expiry_block_height, + } + + FRAGMENT = """ fragment HopFragment on Hop { __typename @@ -96,25 +97,18 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> Hop: return Hop( - requester=requester, - typename="Hop", - id=obj["hop_id"], + requester=requester, typename="Hop", id=obj["hop_id"], 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"], - amount_to_forward=( - CurrencyAmount_from_json(requester, obj["hop_amount_to_forward"]) - if obj["hop_amount_to_forward"] - else None - ), - fee=( - CurrencyAmount_from_json(requester, obj["hop_fee"]) - if obj["hop_fee"] - else None - ), + amount_to_forward=CurrencyAmount_from_json(requester, obj["hop_amount_to_forward"]) if obj["hop_amount_to_forward"] else None, + fee=CurrencyAmount_from_json(requester, obj["hop_fee"]) if obj["hop_fee"] else None, expiry_block_height=obj["hop_expiry_block_height"], - ) + + ) + diff --git a/lightspark/objects/HtlcAttemptFailureCode.py b/lightspark/objects/HtlcAttemptFailureCode.py index 43dcc11..0699a64 100644 --- a/lightspark/objects/HtlcAttemptFailureCode.py +++ b/lightspark/objects/HtlcAttemptFailureCode.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -36,3 +37,4 @@ class HtlcAttemptFailureCode(Enum): INTERNAL_FAILURE = "INTERNAL_FAILURE" UNKNOWN_FAILURE = "UNKNOWN_FAILURE" UNREADABLE_FAILURE = "UNREADABLE_FAILURE" + diff --git a/lightspark/objects/IdAndSignature.py b/lightspark/objects/IdAndSignature.py index a5e7339..4d13228 100644 --- a/lightspark/objects/IdAndSignature.py +++ b/lightspark/objects/IdAndSignature.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,22 +6,33 @@ @dataclass -class IdAndSignature: +class IdAndSignature(): + + id: str """The id of the message.""" signature: str """The signature of the message.""" + + def to_json(self) -> Mapping[str, Any]: return { "id_and_signature_id": self.id, "id_and_signature_signature": self.signature, + } + + + + def from_json(obj: Mapping[str, Any]) -> IdAndSignature: return IdAndSignature( id=obj["id_and_signature_id"], signature=obj["id_and_signature_signature"], - ) + + ) + diff --git a/lightspark/objects/IncentivesIneligibilityReason.py b/lightspark/objects/IncentivesIneligibilityReason.py index 44e9929..d15fd59 100644 --- a/lightspark/objects/IncentivesIneligibilityReason.py +++ b/lightspark/objects/IncentivesIneligibilityReason.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -20,3 +21,4 @@ class IncentivesIneligibilityReason(Enum): """This invitation is not eligible for incentives because the receiving VASP is not part of the incentives program.""" NOT_CROSS_BORDER = "NOT_CROSS_BORDER" """This invitation is not eligible for incentives because the sender and receiver are in the same region.""" + diff --git a/lightspark/objects/IncentivesStatus.py b/lightspark/objects/IncentivesStatus.py index 40676cc..ece227e 100644 --- a/lightspark/objects/IncentivesStatus.py +++ b/lightspark/objects/IncentivesStatus.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -14,3 +15,4 @@ class IncentivesStatus(Enum): """The incentives have been validated.""" INELIGIBLE = "INELIGIBLE" """This invitation is not eligible for incentives. A more detailed reason can be found in the `incentives_ineligibility_reason` field.""" + diff --git a/lightspark/objects/IncomingPayment.py b/lightspark/objects/IncomingPayment.py index ad0205a..e1bc378 100644 --- a/lightspark/objects/IncomingPayment.py +++ b/lightspark/objects/IncomingPayment.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -11,10 +12,10 @@ from .CurrencyAmount import from_json as CurrencyAmount_from_json from .Entity import Entity from .IncomingPaymentAttemptStatus import IncomingPaymentAttemptStatus -from .IncomingPaymentToAttemptsConnection import IncomingPaymentToAttemptsConnection -from .IncomingPaymentToAttemptsConnection import ( - from_json as IncomingPaymentToAttemptsConnection_from_json, -) +from .IncomingPaymentToAttemptsConnection import \ + IncomingPaymentToAttemptsConnection +from .IncomingPaymentToAttemptsConnection import \ + from_json as IncomingPaymentToAttemptsConnection_from_json from .LightningTransaction import LightningTransaction from .PostTransactionData import PostTransactionData from .PostTransactionData import from_json as PostTransactionData_from_json @@ -65,12 +66,7 @@ class IncomingPayment(LightningTransaction, Transaction, Entity): """Whether the payment is made from the same node.""" typename: str - def get_attempts( - self, - first: Optional[int] = None, - statuses: Optional[List[IncomingPaymentAttemptStatus]] = None, - after: Optional[str] = None, - ) -> IncomingPaymentToAttemptsConnection: + def get_attempts(self, first: Optional[int]= None, statuses: Optional[List[IncomingPaymentAttemptStatus]]= None, after: Optional[str]= None) -> IncomingPaymentToAttemptsConnection: json = self.requester.execute_graphql( """ query FetchIncomingPaymentToAttemptsConnection($entity_id: ID!, $first: Int, $statuses: [IncomingPaymentAttemptStatus!], $after: String) { @@ -110,16 +106,12 @@ def get_attempts( } } """, - { - "entity_id": self.id, - "first": first, - "statuses": statuses, - "after": after, - }, + {"entity_id": self.id, "first": first, "statuses": statuses, "after": after} ) connection = json["entity"]["attempts"] return IncomingPaymentToAttemptsConnection_from_json(self.requester, connection) + def to_json(self) -> Mapping[str, Any]: return { "__typename": "IncomingPayment", @@ -127,25 +119,20 @@ def to_json(self) -> Mapping[str, Any]: "incoming_payment_created_at": self.created_at.isoformat(), "incoming_payment_updated_at": self.updated_at.isoformat(), "incoming_payment_status": self.status.value, - "incoming_payment_resolved_at": ( - self.resolved_at.isoformat() if self.resolved_at else None - ), + "incoming_payment_resolved_at": self.resolved_at.isoformat() if self.resolved_at else None, "incoming_payment_amount": self.amount.to_json(), "incoming_payment_transaction_hash": self.transaction_hash, "incoming_payment_is_uma": self.is_uma, - "incoming_payment_destination": {"id": self.destination_id}, - "incoming_payment_payment_request": ( - {"id": self.payment_request_id} if self.payment_request_id else None - ), - "incoming_payment_uma_post_transaction_data": ( - [e.to_json() for e in self.uma_post_transaction_data] - if self.uma_post_transaction_data - else None - ), + "incoming_payment_destination": { "id": self.destination_id }, + "incoming_payment_payment_request": { "id": self.payment_request_id } if self.payment_request_id else None, + "incoming_payment_uma_post_transaction_data": [e.to_json() for e in self.uma_post_transaction_data] if self.uma_post_transaction_data else None, "incoming_payment_is_internal_payment": self.is_internal_payment, + } + + FRAGMENT = """ fragment IncomingPaymentFragment on IncomingPayment { __typename @@ -187,38 +174,24 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> IncomingPayment: return IncomingPayment( - requester=requester, - typename="IncomingPayment", - id=obj["incoming_payment_id"], + requester=requester, typename="IncomingPayment", id=obj["incoming_payment_id"], 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=( - datetime.fromisoformat(obj["incoming_payment_resolved_at"]) - if obj["incoming_payment_resolved_at"] - else None - ), + + status=parse_enum(TransactionStatus, obj['incoming_payment_status']), + 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"], is_uma=obj["incoming_payment_is_uma"], destination_id=obj["incoming_payment_destination"]["id"], - payment_request_id=( - obj["incoming_payment_payment_request"]["id"] - if obj["incoming_payment_payment_request"] - else None - ), - uma_post_transaction_data=( - list( - map( - # pylint: disable=unnecessary-lambda - lambda e: PostTransactionData_from_json(requester, e), - obj["incoming_payment_uma_post_transaction_data"], - ) - ) - if obj["incoming_payment_uma_post_transaction_data"] - else None - ), + payment_request_id=obj["incoming_payment_payment_request"]["id"] if obj["incoming_payment_payment_request"] else None, + uma_post_transaction_data=list(map( + # pylint: disable=unnecessary-lambda + lambda e: PostTransactionData_from_json(requester, e), obj["incoming_payment_uma_post_transaction_data"])) if obj["incoming_payment_uma_post_transaction_data"] else None, is_internal_payment=obj["incoming_payment_is_internal_payment"], - ) + + ) + diff --git a/lightspark/objects/IncomingPaymentAttempt.py b/lightspark/objects/IncomingPaymentAttempt.py index e8f99a7..446aee7 100644 --- a/lightspark/objects/IncomingPaymentAttempt.py +++ b/lightspark/objects/IncomingPaymentAttempt.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -41,6 +42,7 @@ class IncomingPaymentAttempt(Entity): """The channel this attempt was made on.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "IncomingPaymentAttempt", @@ -48,14 +50,15 @@ def to_json(self) -> Mapping[str, Any]: "incoming_payment_attempt_created_at": self.created_at.isoformat(), "incoming_payment_attempt_updated_at": self.updated_at.isoformat(), "incoming_payment_attempt_status": self.status.value, - "incoming_payment_attempt_resolved_at": ( - self.resolved_at.isoformat() if self.resolved_at else None - ), + "incoming_payment_attempt_resolved_at": self.resolved_at.isoformat() if self.resolved_at else None, "incoming_payment_attempt_amount": self.amount.to_json(), - "incoming_payment_attempt_channel": {"id": self.channel_id}, + "incoming_payment_attempt_channel": { "id": self.channel_id }, + } + + FRAGMENT = """ fragment IncomingPaymentAttemptFragment on IncomingPaymentAttempt { __typename @@ -79,23 +82,17 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> IncomingPaymentAttempt: return IncomingPaymentAttempt( - requester=requester, - typename="IncomingPaymentAttempt", - id=obj["incoming_payment_attempt_id"], + requester=requester, typename="IncomingPaymentAttempt", id=obj["incoming_payment_attempt_id"], 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=( - 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"] - ), + + status=parse_enum(IncomingPaymentAttemptStatus, obj['incoming_payment_attempt_status']), + 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"]), channel_id=obj["incoming_payment_attempt_channel"]["id"], - ) + + ) + diff --git a/lightspark/objects/IncomingPaymentAttemptStatus.py b/lightspark/objects/IncomingPaymentAttemptStatus.py index 43aa394..16724c3 100644 --- a/lightspark/objects/IncomingPaymentAttemptStatus.py +++ b/lightspark/objects/IncomingPaymentAttemptStatus.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -12,3 +13,4 @@ class IncomingPaymentAttemptStatus(Enum): SETTLED = "SETTLED" CANCELED = "CANCELED" UNKNOWN = "UNKNOWN" + diff --git a/lightspark/objects/IncomingPaymentToAttemptsConnection.py b/lightspark/objects/IncomingPaymentToAttemptsConnection.py index e29e66c..dab5c6c 100644 --- a/lightspark/objects/IncomingPaymentToAttemptsConnection.py +++ b/lightspark/objects/IncomingPaymentToAttemptsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,7 +8,8 @@ from .Connection import Connection from .IncomingPaymentAttempt import IncomingPaymentAttempt -from .IncomingPaymentAttempt import from_json as IncomingPaymentAttempt_from_json +from .IncomingPaymentAttempt import \ + from_json as IncomingPaymentAttempt_from_json from .PageInfo import PageInfo from .PageInfo import from_json as PageInfo_from_json @@ -28,17 +30,19 @@ class IncomingPaymentToAttemptsConnection(Connection): """The incoming payment attempts for the current page of this connection.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "IncomingPaymentToAttemptsConnection", "incoming_payment_to_attempts_connection_count": self.count, "incoming_payment_to_attempts_connection_page_info": self.page_info.to_json(), - "incoming_payment_to_attempts_connection_entities": [ - e.to_json() for e in self.entities - ], + "incoming_payment_to_attempts_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment IncomingPaymentToAttemptsConnectionFragment on IncomingPaymentToAttemptsConnection { __typename @@ -57,21 +61,14 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> IncomingPaymentToAttemptsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> IncomingPaymentToAttemptsConnection: return IncomingPaymentToAttemptsConnection( - requester=requester, - typename="IncomingPaymentToAttemptsConnection", - count=obj["incoming_payment_to_attempts_connection_count"], - page_info=PageInfo_from_json( - requester, obj["incoming_payment_to_attempts_connection_page_info"] - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: IncomingPaymentAttempt_from_json(requester, e), - obj["incoming_payment_to_attempts_connection_entities"], - ) - ), - ) + requester=requester, typename="IncomingPaymentToAttemptsConnection", count=obj["incoming_payment_to_attempts_connection_count"], + page_info=PageInfo_from_json(requester, obj["incoming_payment_to_attempts_connection_page_info"]), + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: IncomingPaymentAttempt_from_json(requester, e), obj["incoming_payment_to_attempts_connection_entities"])), + + ) + diff --git a/lightspark/objects/IncomingPaymentsForInvoiceQueryInput.py b/lightspark/objects/IncomingPaymentsForInvoiceQueryInput.py index 36dbb7f..9d2ba48 100644 --- a/lightspark/objects/IncomingPaymentsForInvoiceQueryInput.py +++ b/lightspark/objects/IncomingPaymentsForInvoiceQueryInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -9,25 +10,33 @@ @dataclass -class IncomingPaymentsForInvoiceQueryInput: +class IncomingPaymentsForInvoiceQueryInput(): + + invoice_id: str + statuses: Optional[List[TransactionStatus]] """An optional filter to only query outgoing payments of given statuses.""" + + def to_json(self) -> Mapping[str, Any]: return { "incoming_payments_for_invoice_query_input_invoice_id": self.invoice_id, - "incoming_payments_for_invoice_query_input_statuses": ( - [e.value for e in self.statuses] if self.statuses else None - ), + "incoming_payments_for_invoice_query_input_statuses": [e.value for e in self.statuses] if self.statuses else None, + } + + + + def from_json(obj: Mapping[str, Any]) -> IncomingPaymentsForInvoiceQueryInput: return IncomingPaymentsForInvoiceQueryInput( invoice_id=obj["incoming_payments_for_invoice_query_input_invoice_id"], - statuses=parse_optional_list_of_enums( - TransactionStatus, obj["incoming_payments_for_invoice_query_input_statuses"] - ), - ) + statuses=parse_optional_list_of_enums(TransactionStatus, obj["incoming_payments_for_invoice_query_input_statuses"]), + + ) + diff --git a/lightspark/objects/IncomingPaymentsForInvoiceQueryOutput.py b/lightspark/objects/IncomingPaymentsForInvoiceQueryOutput.py index f8fff4a..9ee3589 100644 --- a/lightspark/objects/IncomingPaymentsForInvoiceQueryOutput.py +++ b/lightspark/objects/IncomingPaymentsForInvoiceQueryOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,19 +11,24 @@ @dataclass -class IncomingPaymentsForInvoiceQueryOutput: +class IncomingPaymentsForInvoiceQueryOutput(): + requester: Requester payments: List[IncomingPayment] + + + def to_json(self) -> Mapping[str, Any]: return { - "incoming_payments_for_invoice_query_output_payments": [ - e.to_json() for e in self.payments - ], + "incoming_payments_for_invoice_query_output_payments": [e.to_json() for e in self.payments], + } + + FRAGMENT = """ fragment IncomingPaymentsForInvoiceQueryOutputFragment on IncomingPaymentsForInvoiceQueryOutput { __typename @@ -67,16 +73,12 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> IncomingPaymentsForInvoiceQueryOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> IncomingPaymentsForInvoiceQueryOutput: return IncomingPaymentsForInvoiceQueryOutput( - requester=requester, - payments=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: IncomingPayment_from_json(requester, e), - obj["incoming_payments_for_invoice_query_output_payments"], - ) - ), - ) + requester=requester, payments=list(map( + # pylint: disable=unnecessary-lambda + lambda e: IncomingPayment_from_json(requester, e), obj["incoming_payments_for_invoice_query_output_payments"])), + + ) + diff --git a/lightspark/objects/IncomingPaymentsForPaymentHashQueryInput.py b/lightspark/objects/IncomingPaymentsForPaymentHashQueryInput.py index d0de424..f41be06 100644 --- a/lightspark/objects/IncomingPaymentsForPaymentHashQueryInput.py +++ b/lightspark/objects/IncomingPaymentsForPaymentHashQueryInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -9,27 +10,33 @@ @dataclass -class IncomingPaymentsForPaymentHashQueryInput: +class IncomingPaymentsForPaymentHashQueryInput(): + + payment_hash: str """The 32-byte hash of the payment preimage for which to fetch payments""" statuses: Optional[List[TransactionStatus]] """An optional filter to only query incoming payments of given statuses.""" + + def to_json(self) -> Mapping[str, Any]: return { "incoming_payments_for_payment_hash_query_input_payment_hash": self.payment_hash, - "incoming_payments_for_payment_hash_query_input_statuses": ( - [e.value for e in self.statuses] if self.statuses else None - ), + "incoming_payments_for_payment_hash_query_input_statuses": [e.value for e in self.statuses] if self.statuses else None, + } + + + + def from_json(obj: Mapping[str, Any]) -> IncomingPaymentsForPaymentHashQueryInput: return IncomingPaymentsForPaymentHashQueryInput( payment_hash=obj["incoming_payments_for_payment_hash_query_input_payment_hash"], - statuses=parse_optional_list_of_enums( - TransactionStatus, - obj["incoming_payments_for_payment_hash_query_input_statuses"], - ), - ) + statuses=parse_optional_list_of_enums(TransactionStatus, obj["incoming_payments_for_payment_hash_query_input_statuses"]), + + ) + diff --git a/lightspark/objects/IncomingPaymentsForPaymentHashQueryOutput.py b/lightspark/objects/IncomingPaymentsForPaymentHashQueryOutput.py index 6834be1..f7e971c 100644 --- a/lightspark/objects/IncomingPaymentsForPaymentHashQueryOutput.py +++ b/lightspark/objects/IncomingPaymentsForPaymentHashQueryOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,19 +11,24 @@ @dataclass -class IncomingPaymentsForPaymentHashQueryOutput: +class IncomingPaymentsForPaymentHashQueryOutput(): + requester: Requester payments: List[IncomingPayment] + + + def to_json(self) -> Mapping[str, Any]: return { - "incoming_payments_for_payment_hash_query_output_payments": [ - e.to_json() for e in self.payments - ], + "incoming_payments_for_payment_hash_query_output_payments": [e.to_json() for e in self.payments], + } + + FRAGMENT = """ fragment IncomingPaymentsForPaymentHashQueryOutputFragment on IncomingPaymentsForPaymentHashQueryOutput { __typename @@ -33,16 +39,12 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> IncomingPaymentsForPaymentHashQueryOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> IncomingPaymentsForPaymentHashQueryOutput: return IncomingPaymentsForPaymentHashQueryOutput( - requester=requester, - payments=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: IncomingPayment_from_json(requester, e), - obj["incoming_payments_for_payment_hash_query_output_payments"], - ) - ), - ) + requester=requester, payments=list(map( + # pylint: disable=unnecessary-lambda + lambda e: IncomingPayment_from_json(requester, e), obj["incoming_payments_for_payment_hash_query_output_payments"])), + + ) + diff --git a/lightspark/objects/Invoice.py b/lightspark/objects/Invoice.py index 02e6d9b..4a55b0b 100644 --- a/lightspark/objects/Invoice.py +++ b/lightspark/objects/Invoice.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -18,7 +19,7 @@ @dataclass class Invoice(PaymentRequest, Entity): - """This object represents a BOLT #11 invoice (https://github.com/lightning/bolts/blob/master/11-payment-encoding.md) created by a Lightspark Node. You can retrieve this object to receive relevant payment information for a specific invoice generated by a Lightspark node.""" + """This object represents a Bolt #11 or Bolt #12 invoice created by a Lightspark Node. You can retrieve this object to receive relevant payment information for a specific invoice generated by a Lightspark node.""" requester: Requester @@ -47,6 +48,7 @@ class Invoice(PaymentRequest, Entity): """Whether this invoice is an LNURL invoice or not. NOTE: this field is only set if the invoice was created using the recommended `create_lnurl_invoice` function.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "Invoice", @@ -55,14 +57,15 @@ def to_json(self) -> Mapping[str, Any]: "invoice_updated_at": self.updated_at.isoformat(), "invoice_data": self.data.to_json(), "invoice_status": self.status.value, - "invoice_amount_paid": ( - self.amount_paid.to_json() if self.amount_paid else None - ), + "invoice_amount_paid": self.amount_paid.to_json() if self.amount_paid else None, "invoice_is_uma": self.is_uma, "invoice_is_lnurl": self.is_lnurl, + } + + FRAGMENT = """ fragment InvoiceFragment on Invoice { __typename @@ -375,20 +378,18 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> Invoice: return Invoice( - requester=requester, - typename="Invoice", - id=obj["invoice_id"], + requester=requester, typename="Invoice", id=obj["invoice_id"], 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"]) - if obj["invoice_amount_paid"] - else None - ), + + status=parse_enum(PaymentRequestStatus, obj['invoice_status']), + amount_paid=CurrencyAmount_from_json(requester, obj["invoice_amount_paid"]) if obj["invoice_amount_paid"] else None, is_uma=obj["invoice_is_uma"], is_lnurl=obj["invoice_is_lnurl"], - ) + + ) + diff --git a/lightspark/objects/InvoiceData.py b/lightspark/objects/InvoiceData.py index b0665b1..4ab62cb 100644 --- a/lightspark/objects/InvoiceData.py +++ b/lightspark/objects/InvoiceData.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -17,13 +18,15 @@ @dataclass class InvoiceData(PaymentRequestData): - """This object represents the data associated with a BOLT #11 invoice. You can retrieve this object to receive the relevant data associated with a specific invoice.""" + """This object represents the data associated with a Bolt #11 or Bolt #12 invoice. You can retrieve this object to receive the relevant data associated with a specific invoice.""" requester: Requester encoded_payment_request: str + bitcoin_network: BitcoinNetwork + payment_hash: str """The payment hash of this invoice.""" @@ -44,6 +47,7 @@ class InvoiceData(PaymentRequestData): """The lightning node that will be paid when fulfilling this invoice.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "InvoiceData", @@ -55,9 +59,12 @@ def to_json(self) -> Mapping[str, Any]: "invoice_data_expires_at": self.expires_at.isoformat(), "invoice_data_memo": self.memo, "invoice_data_destination": self.destination.to_json(), + } + + FRAGMENT = """ fragment InvoiceDataFragment on InvoiceData { __typename @@ -353,16 +360,18 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> InvoiceData: return InvoiceData( - requester=requester, - typename="InvoiceData", - encoded_payment_request=obj["invoice_data_encoded_payment_request"], - bitcoin_network=parse_enum(BitcoinNetwork, obj["invoice_data_bitcoin_network"]), + requester=requester, typename="InvoiceData", encoded_payment_request=obj["invoice_data_encoded_payment_request"], + + 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=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"]), - ) + + ) + diff --git a/lightspark/objects/InvoiceForPaymentHashInput.py b/lightspark/objects/InvoiceForPaymentHashInput.py index ed04924..ac818c2 100644 --- a/lightspark/objects/InvoiceForPaymentHashInput.py +++ b/lightspark/objects/InvoiceForPaymentHashInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,17 +6,28 @@ @dataclass -class InvoiceForPaymentHashInput: +class InvoiceForPaymentHashInput(): + + payment_hash: str """The 32-byte hash of the payment preimage for which to fetch an invoice.""" + + def to_json(self) -> Mapping[str, Any]: return { "invoice_for_payment_hash_input_payment_hash": self.payment_hash, + } + + + + def from_json(obj: Mapping[str, Any]) -> InvoiceForPaymentHashInput: return InvoiceForPaymentHashInput( payment_hash=obj["invoice_for_payment_hash_input_payment_hash"], - ) + + ) + diff --git a/lightspark/objects/InvoiceForPaymentHashOutput.py b/lightspark/objects/InvoiceForPaymentHashOutput.py index e547a29..9c34e82 100644 --- a/lightspark/objects/InvoiceForPaymentHashOutput.py +++ b/lightspark/objects/InvoiceForPaymentHashOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,19 +8,24 @@ @dataclass -class InvoiceForPaymentHashOutput: +class InvoiceForPaymentHashOutput(): + requester: Requester invoice_id: Optional[str] + + + def to_json(self) -> Mapping[str, Any]: return { - "invoice_for_payment_hash_output_invoice": ( - {"id": self.invoice_id} if self.invoice_id else None - ), + "invoice_for_payment_hash_output_invoice": { "id": self.invoice_id } if self.invoice_id else None, + } + + FRAGMENT = """ fragment InvoiceForPaymentHashOutputFragment on InvoiceForPaymentHashOutput { __typename @@ -30,14 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> InvoiceForPaymentHashOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> InvoiceForPaymentHashOutput: return InvoiceForPaymentHashOutput( - requester=requester, - invoice_id=( - obj["invoice_for_payment_hash_output_invoice"]["id"] - if obj["invoice_for_payment_hash_output_invoice"] - else None - ), - ) + requester=requester, invoice_id=obj["invoice_for_payment_hash_output_invoice"]["id"] if obj["invoice_for_payment_hash_output_invoice"] else None, + + ) + diff --git a/lightspark/objects/InvoiceType.py b/lightspark/objects/InvoiceType.py index 81a36ce..a0f45cc 100644 --- a/lightspark/objects/InvoiceType.py +++ b/lightspark/objects/InvoiceType.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -12,3 +13,4 @@ class InvoiceType(Enum): """A standard Bolt 11 invoice.""" AMP = "AMP" """An AMP (Atomic Multi-path Payment) invoice.""" + diff --git a/lightspark/objects/LightningFeeEstimateForInvoiceInput.py b/lightspark/objects/LightningFeeEstimateForInvoiceInput.py index 04391b0..086eb76 100644 --- a/lightspark/objects/LightningFeeEstimateForInvoiceInput.py +++ b/lightspark/objects/LightningFeeEstimateForInvoiceInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,7 +6,9 @@ @dataclass -class LightningFeeEstimateForInvoiceInput: +class LightningFeeEstimateForInvoiceInput(): + + node_id: str """The node from where you want to send the payment.""" @@ -15,19 +18,26 @@ class LightningFeeEstimateForInvoiceInput: amount_msats: Optional[int] """If the invoice does not specify a payment amount, then the amount that you wish to pay, expressed in msats.""" + + def to_json(self) -> Mapping[str, Any]: return { "lightning_fee_estimate_for_invoice_input_node_id": self.node_id, "lightning_fee_estimate_for_invoice_input_encoded_payment_request": self.encoded_payment_request, "lightning_fee_estimate_for_invoice_input_amount_msats": self.amount_msats, + } + + + + def from_json(obj: Mapping[str, Any]) -> LightningFeeEstimateForInvoiceInput: return LightningFeeEstimateForInvoiceInput( node_id=obj["lightning_fee_estimate_for_invoice_input_node_id"], - encoded_payment_request=obj[ - "lightning_fee_estimate_for_invoice_input_encoded_payment_request" - ], + encoded_payment_request=obj["lightning_fee_estimate_for_invoice_input_encoded_payment_request"], amount_msats=obj["lightning_fee_estimate_for_invoice_input_amount_msats"], - ) + + ) + diff --git a/lightspark/objects/LightningFeeEstimateForNodeInput.py b/lightspark/objects/LightningFeeEstimateForNodeInput.py index e0c80d0..2cc849b 100644 --- a/lightspark/objects/LightningFeeEstimateForNodeInput.py +++ b/lightspark/objects/LightningFeeEstimateForNodeInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,7 +6,9 @@ @dataclass -class LightningFeeEstimateForNodeInput: +class LightningFeeEstimateForNodeInput(): + + node_id: str """The node from where you want to send the payment.""" @@ -15,19 +18,26 @@ class LightningFeeEstimateForNodeInput: amount_msats: int """The payment amount expressed in msats.""" + + def to_json(self) -> Mapping[str, Any]: return { "lightning_fee_estimate_for_node_input_node_id": self.node_id, "lightning_fee_estimate_for_node_input_destination_node_public_key": self.destination_node_public_key, "lightning_fee_estimate_for_node_input_amount_msats": self.amount_msats, + } + + + + def from_json(obj: Mapping[str, Any]) -> LightningFeeEstimateForNodeInput: return LightningFeeEstimateForNodeInput( node_id=obj["lightning_fee_estimate_for_node_input_node_id"], - destination_node_public_key=obj[ - "lightning_fee_estimate_for_node_input_destination_node_public_key" - ], + destination_node_public_key=obj["lightning_fee_estimate_for_node_input_destination_node_public_key"], amount_msats=obj["lightning_fee_estimate_for_node_input_amount_msats"], - ) + + ) + diff --git a/lightspark/objects/LightningFeeEstimateOutput.py b/lightspark/objects/LightningFeeEstimateOutput.py index 3a6bcd0..018efae 100644 --- a/lightspark/objects/LightningFeeEstimateOutput.py +++ b/lightspark/objects/LightningFeeEstimateOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,18 +11,24 @@ @dataclass -class LightningFeeEstimateOutput: +class LightningFeeEstimateOutput(): + requester: Requester fee_estimate: CurrencyAmount """The estimated fees for the payment.""" + + def to_json(self) -> Mapping[str, Any]: return { "lightning_fee_estimate_output_fee_estimate": self.fee_estimate.to_json(), + } + + FRAGMENT = """ fragment LightningFeeEstimateOutputFragment on LightningFeeEstimateOutput { __typename @@ -37,12 +44,10 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> LightningFeeEstimateOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightningFeeEstimateOutput: return LightningFeeEstimateOutput( - requester=requester, - fee_estimate=CurrencyAmount_from_json( - requester, obj["lightning_fee_estimate_output_fee_estimate"] - ), - ) + requester=requester, fee_estimate=CurrencyAmount_from_json(requester, obj["lightning_fee_estimate_output_fee_estimate"]), + + ) + diff --git a/lightspark/objects/LightningPaymentDirection.py b/lightspark/objects/LightningPaymentDirection.py index e096998..5dd2a9b 100644 --- a/lightspark/objects/LightningPaymentDirection.py +++ b/lightspark/objects/LightningPaymentDirection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -12,3 +13,4 @@ class LightningPaymentDirection(Enum): """A payment that is received by the node.""" OUTGOING = "OUTGOING" """A payment that is sent by the node.""" + diff --git a/lightspark/objects/LightningTransaction.py b/lightspark/objects/LightningTransaction.py index 0cb1e8b..8a059a5 100644 --- a/lightspark/objects/LightningTransaction.py +++ b/lightspark/objects/LightningTransaction.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -48,6 +49,7 @@ class LightningTransaction(Transaction, Entity): """The hash of this transaction, so it can be uniquely identified on the Lightning Network.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": self.typename, @@ -55,14 +57,15 @@ def to_json(self) -> Mapping[str, Any]: "lightning_transaction_created_at": self.created_at.isoformat(), "lightning_transaction_updated_at": self.updated_at.isoformat(), "lightning_transaction_status": self.status.value, - "lightning_transaction_resolved_at": ( - self.resolved_at.isoformat() if self.resolved_at else None - ), + "lightning_transaction_resolved_at": self.resolved_at.isoformat() if self.resolved_at else None, "lightning_transaction_amount": self.amount.to_json(), "lightning_transaction_transaction_hash": self.transaction_hash, + } + + FRAGMENT = """ fragment LightningTransactionFragment on LightningTransaction { __typename @@ -489,154 +492,76 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightningTransaction: if obj["__typename"] == "IncomingPayment": - # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel from lightspark.objects.IncomingPayment import IncomingPayment - return IncomingPayment( - requester=requester, - typename="IncomingPayment", - id=obj["incoming_payment_id"], + requester=requester, typename="IncomingPayment", id=obj["incoming_payment_id"], 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=( - datetime.fromisoformat(obj["incoming_payment_resolved_at"]) - if obj["incoming_payment_resolved_at"] - else None - ), + + status=parse_enum(TransactionStatus, obj['incoming_payment_status']), + 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"], is_uma=obj["incoming_payment_is_uma"], destination_id=obj["incoming_payment_destination"]["id"], - payment_request_id=( - obj["incoming_payment_payment_request"]["id"] - if obj["incoming_payment_payment_request"] - else None - ), - uma_post_transaction_data=( - list( - map( - # pylint: disable=unnecessary-lambda - lambda e: PostTransactionData_from_json(requester, e), - obj["incoming_payment_uma_post_transaction_data"], - ) - ) - if obj["incoming_payment_uma_post_transaction_data"] - else None - ), + payment_request_id=obj["incoming_payment_payment_request"]["id"] if obj["incoming_payment_payment_request"] else None, + uma_post_transaction_data=list(map( + # pylint: disable=unnecessary-lambda + lambda e: PostTransactionData_from_json(requester, e), obj["incoming_payment_uma_post_transaction_data"])) if obj["incoming_payment_uma_post_transaction_data"] else None, is_internal_payment=obj["incoming_payment_is_internal_payment"], + ) if obj["__typename"] == "OutgoingPayment": - # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel from lightspark.objects.OutgoingPayment import OutgoingPayment - return OutgoingPayment( - requester=requester, - typename="OutgoingPayment", - id=obj["outgoing_payment_id"], + requester=requester, typename="OutgoingPayment", id=obj["outgoing_payment_id"], 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=( - datetime.fromisoformat(obj["outgoing_payment_resolved_at"]) - if obj["outgoing_payment_resolved_at"] - else None - ), + + status=parse_enum(TransactionStatus, obj['outgoing_payment_status']), + 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"], is_uma=obj["outgoing_payment_is_uma"], origin_id=obj["outgoing_payment_origin"]["id"], - destination_id=( - obj["outgoing_payment_destination"]["id"] - if obj["outgoing_payment_destination"] - else None - ), - fees=( - CurrencyAmount_from_json(requester, obj["outgoing_payment_fees"]) - if obj["outgoing_payment_fees"] - else None - ), - payment_request_data=( - PaymentRequestData_from_json( - requester, obj["outgoing_payment_payment_request_data"] - ) - if obj["outgoing_payment_payment_request_data"] - else None - ), - failure_reason=parse_enum_optional( - PaymentFailureReason, obj["outgoing_payment_failure_reason"] - ), - failure_message=( - RichText_from_json(requester, obj["outgoing_payment_failure_message"]) - if obj["outgoing_payment_failure_message"] - else None - ), - uma_post_transaction_data=( - list( - map( - # pylint: disable=unnecessary-lambda - lambda e: PostTransactionData_from_json(requester, e), - obj["outgoing_payment_uma_post_transaction_data"], - ) - ) - if obj["outgoing_payment_uma_post_transaction_data"] - else None - ), + destination_id=obj["outgoing_payment_destination"]["id"] if obj["outgoing_payment_destination"] else None, + fees=CurrencyAmount_from_json(requester, obj["outgoing_payment_fees"]) if obj["outgoing_payment_fees"] else None, + payment_request_data=PaymentRequestData_from_json(requester, obj["outgoing_payment_payment_request_data"]) if obj["outgoing_payment_payment_request_data"] else None, + + failure_reason=parse_enum_optional(PaymentFailureReason, obj['outgoing_payment_failure_reason']), + failure_message=RichText_from_json(requester, obj["outgoing_payment_failure_message"]) if obj["outgoing_payment_failure_message"] else None, + uma_post_transaction_data=list(map( + # pylint: disable=unnecessary-lambda + lambda e: PostTransactionData_from_json(requester, e), obj["outgoing_payment_uma_post_transaction_data"])) if obj["outgoing_payment_uma_post_transaction_data"] else None, payment_preimage=obj["outgoing_payment_payment_preimage"], is_internal_payment=obj["outgoing_payment_is_internal_payment"], idempotency_key=obj["outgoing_payment_idempotency_key"], + ) if obj["__typename"] == "RoutingTransaction": - # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel from lightspark.objects.RoutingTransaction import RoutingTransaction - return RoutingTransaction( - requester=requester, - typename="RoutingTransaction", - id=obj["routing_transaction_id"], + requester=requester, typename="RoutingTransaction", id=obj["routing_transaction_id"], 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=( - datetime.fromisoformat(obj["routing_transaction_resolved_at"]) - if obj["routing_transaction_resolved_at"] - else None - ), - amount=CurrencyAmount_from_json( - requester, obj["routing_transaction_amount"] - ), + + status=parse_enum(TransactionStatus, obj['routing_transaction_status']), + 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"]), transaction_hash=obj["routing_transaction_transaction_hash"], - incoming_channel_id=( - obj["routing_transaction_incoming_channel"]["id"] - if obj["routing_transaction_incoming_channel"] - else None - ), - outgoing_channel_id=( - obj["routing_transaction_outgoing_channel"]["id"] - if obj["routing_transaction_outgoing_channel"] - else None - ), - fees=( - CurrencyAmount_from_json(requester, obj["routing_transaction_fees"]) - if obj["routing_transaction_fees"] - else None - ), - failure_message=( - RichText_from_json( - requester, obj["routing_transaction_failure_message"] - ) - if obj["routing_transaction_failure_message"] - else None - ), - failure_reason=parse_enum_optional( - RoutingTransactionFailureReason, - obj["routing_transaction_failure_reason"], - ), + incoming_channel_id=obj["routing_transaction_incoming_channel"]["id"] if obj["routing_transaction_incoming_channel"] else None, + outgoing_channel_id=obj["routing_transaction_outgoing_channel"]["id"] if obj["routing_transaction_outgoing_channel"] else None, + fees=CurrencyAmount_from_json(requester, obj["routing_transaction_fees"]) if obj["routing_transaction_fees"] else None, + failure_message=RichText_from_json(requester, obj["routing_transaction_failure_message"]) if obj["routing_transaction_failure_message"] else None, + + failure_reason=parse_enum_optional(RoutingTransactionFailureReason, obj['routing_transaction_failure_reason']), + ) graphql_typename = obj["__typename"] - raise LightsparkException( - "UNKNOWN_INTERFACE", - f"Couldn't find a concrete type for interface LightningTransaction corresponding to the typename={graphql_typename}", - ) + raise LightsparkException("UNKNOWN_INTERFACE", f"Couldn't find a concrete type for interface LightningTransaction corresponding to the typename={graphql_typename}") diff --git a/lightspark/objects/LightsparkNode.py b/lightspark/objects/LightsparkNode.py index ddb3af6..08f0b1a 100644 --- a/lightspark/objects/LightsparkNode.py +++ b/lightspark/objects/LightsparkNode.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -19,20 +20,19 @@ from .Entity import Entity from .LightningPaymentDirection import LightningPaymentDirection from .LightsparkNodeStatus import LightsparkNodeStatus -from .LightsparkNodeToChannelsConnection import LightsparkNodeToChannelsConnection -from .LightsparkNodeToChannelsConnection import ( - from_json as LightsparkNodeToChannelsConnection_from_json, -) -from .LightsparkNodeToDailyLiquidityForecastsConnection import ( - LightsparkNodeToDailyLiquidityForecastsConnection, -) -from .LightsparkNodeToDailyLiquidityForecastsConnection import ( - from_json as LightsparkNodeToDailyLiquidityForecastsConnection_from_json, -) +from .LightsparkNodeToChannelsConnection import \ + LightsparkNodeToChannelsConnection +from .LightsparkNodeToChannelsConnection import \ + from_json as LightsparkNodeToChannelsConnection_from_json +from .LightsparkNodeToDailyLiquidityForecastsConnection import \ + LightsparkNodeToDailyLiquidityForecastsConnection +from .LightsparkNodeToDailyLiquidityForecastsConnection import \ + from_json as LightsparkNodeToDailyLiquidityForecastsConnection_from_json from .Node import Node from .NodeAddressType import NodeAddressType from .NodeToAddressesConnection import NodeToAddressesConnection -from .NodeToAddressesConnection import from_json as NodeToAddressesConnection_from_json +from .NodeToAddressesConnection import \ + from_json as NodeToAddressesConnection_from_json from .Secret import from_json as Secret_from_json @@ -97,9 +97,7 @@ class LightsparkNode(Node, Entity): """The balances that describe the funds in this node.""" typename: str - def get_addresses( - self, first: Optional[int] = None, types: Optional[List[NodeAddressType]] = None - ) -> NodeToAddressesConnection: + def get_addresses(self, first: Optional[int]= None, types: Optional[List[NodeAddressType]]= None) -> NodeToAddressesConnection: json = self.requester.execute_graphql( """ query FetchNodeToAddressesConnection($entity_id: ID!, $first: Int, $types: [NodeAddressType!]) { @@ -118,19 +116,12 @@ def get_addresses( } } """, - {"entity_id": self.id, "first": first, "types": types}, + {"entity_id": self.id, "first": first, "types": types} ) connection = json["entity"]["addresses"] return NodeToAddressesConnection_from_json(self.requester, connection) - def get_channels( - self, - first: Optional[int] = None, - after: Optional[str] = None, - before_date: Optional[datetime] = None, - after_date: Optional[datetime] = None, - statuses: Optional[List[ChannelStatus]] = None, - ) -> LightsparkNodeToChannelsConnection: + def get_channels(self, first: Optional[int]= None, after: Optional[str]= None, before_date: Optional[datetime]= None, after_date: Optional[datetime]= None, statuses: Optional[List[ChannelStatus]]= None) -> LightsparkNodeToChannelsConnection: json = self.requester.execute_graphql( """ query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $after: String, $before_date: DateTime, $after_date: DateTime, $statuses: [ChannelStatus!]) { @@ -245,24 +236,12 @@ def get_channels( } } """, - { - "entity_id": self.id, - "first": first, - "after": after, - "before_date": before_date, - "after_date": after_date, - "statuses": statuses, - }, + {"entity_id": self.id, "first": first, "after": after, "before_date": before_date, "after_date": after_date, "statuses": statuses} ) connection = json["entity"]["channels"] return LightsparkNodeToChannelsConnection_from_json(self.requester, connection) - def get_daily_liquidity_forecasts( - self, - from_date: datetime, - to_date: datetime, - direction: LightningPaymentDirection, - ) -> LightsparkNodeToDailyLiquidityForecastsConnection: + def get_daily_liquidity_forecasts(self, from_date: datetime, to_date: datetime, direction: LightningPaymentDirection) -> LightsparkNodeToDailyLiquidityForecastsConnection: json = self.requester.execute_graphql( """ query FetchLightsparkNodeToDailyLiquidityForecastsConnection($entity_id: ID!, $from_date: Date!, $to_date: Date!, $direction: LightningPaymentDirection!) { @@ -291,17 +270,11 @@ def get_daily_liquidity_forecasts( } } """, - { - "entity_id": self.id, - "from_date": from_date, - "to_date": to_date, - "direction": direction, - }, + {"entity_id": self.id, "from_date": from_date, "to_date": to_date, "direction": direction} ) connection = json["entity"]["daily_liquidity_forecasts"] - return LightsparkNodeToDailyLiquidityForecastsConnection_from_json( - self.requester, connection - ) + return LightsparkNodeToDailyLiquidityForecastsConnection_from_json(self.requester, connection) + def to_json(self) -> Mapping[str, Any]: return { @@ -315,30 +288,21 @@ def to_json(self) -> Mapping[str, Any]: "lightspark_node_conductivity": self.conductivity, "lightspark_node_display_name": self.display_name, "lightspark_node_public_key": self.public_key, - "lightspark_node_owner": {"id": self.owner_id}, + "lightspark_node_owner": { "id": self.owner_id }, "lightspark_node_status": self.status.value if self.status else None, - "lightspark_node_total_balance": ( - self.total_balance.to_json() if self.total_balance else None - ), - "lightspark_node_total_local_balance": ( - self.total_local_balance.to_json() if self.total_local_balance else None - ), - "lightspark_node_local_balance": ( - self.local_balance.to_json() if self.local_balance else None - ), - "lightspark_node_remote_balance": ( - self.remote_balance.to_json() if self.remote_balance else None - ), - "lightspark_node_blockchain_balance": ( - self.blockchain_balance.to_json() if self.blockchain_balance else None - ), + "lightspark_node_total_balance": self.total_balance.to_json() if self.total_balance else None, + "lightspark_node_total_local_balance": self.total_local_balance.to_json() if self.total_local_balance else None, + "lightspark_node_local_balance": self.local_balance.to_json() if self.local_balance else None, + "lightspark_node_remote_balance": self.remote_balance.to_json() if self.remote_balance else None, + "lightspark_node_blockchain_balance": self.blockchain_balance.to_json() if self.blockchain_balance else None, "lightspark_node_uma_prescreening_utxos": self.uma_prescreening_utxos, - "lightspark_node_balances": ( - self.balances.to_json() if self.balances else None - ), + "lightspark_node_balances": self.balances.to_json() if self.balances else None, + } + + FRAGMENT = """ fragment LightsparkNodeFragment on LightsparkNode { __typename @@ -605,166 +569,62 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightsparkNode: if obj["__typename"] == "LightsparkNodeWithOSK": - # pylint: disable=import-outside-toplevel - from lightspark.objects.LightsparkNodeWithOSK import LightsparkNodeWithOSK - + # pylint: disable=import-outside-toplevel + from lightspark.objects.LightsparkNodeWithOSK import \ + LightsparkNodeWithOSK return LightsparkNodeWithOSK( - requester=requester, - typename="LightsparkNodeWithOSK", - id=obj["lightspark_node_with_o_s_k_id"], - 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"] - ), + requester=requester, typename="LightsparkNodeWithOSK", id=obj["lightspark_node_with_o_s_k_id"], + 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"] - ), + + bitcoin_network=parse_enum(BitcoinNetwork, obj['lightspark_node_with_o_s_k_bitcoin_network']), color=obj["lightspark_node_with_o_s_k_color"], conductivity=obj["lightspark_node_with_o_s_k_conductivity"], display_name=obj["lightspark_node_with_o_s_k_display_name"], public_key=obj["lightspark_node_with_o_s_k_public_key"], owner_id=obj["lightspark_node_with_o_s_k_owner"]["id"], - status=parse_enum_optional( - LightsparkNodeStatus, obj["lightspark_node_with_o_s_k_status"] - ), - total_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_o_s_k_total_balance"] - ) - if obj["lightspark_node_with_o_s_k_total_balance"] - else None - ), - total_local_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_o_s_k_total_local_balance"] - ) - if obj["lightspark_node_with_o_s_k_total_local_balance"] - else None - ), - local_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_o_s_k_local_balance"] - ) - if obj["lightspark_node_with_o_s_k_local_balance"] - else None - ), - remote_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_o_s_k_remote_balance"] - ) - if obj["lightspark_node_with_o_s_k_remote_balance"] - else None - ), - blockchain_balance=( - BlockchainBalance_from_json( - requester, obj["lightspark_node_with_o_s_k_blockchain_balance"] - ) - if obj["lightspark_node_with_o_s_k_blockchain_balance"] - else None - ), - uma_prescreening_utxos=obj[ - "lightspark_node_with_o_s_k_uma_prescreening_utxos" - ], - balances=( - Balances_from_json( - requester, obj["lightspark_node_with_o_s_k_balances"] - ) - if obj["lightspark_node_with_o_s_k_balances"] - else None - ), - encrypted_signing_private_key=( - Secret_from_json( - requester, - obj["lightspark_node_with_o_s_k_encrypted_signing_private_key"], - ) - if obj["lightspark_node_with_o_s_k_encrypted_signing_private_key"] - else None - ), + + status=parse_enum_optional(LightsparkNodeStatus, obj['lightspark_node_with_o_s_k_status']), + total_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_o_s_k_total_balance"]) if obj["lightspark_node_with_o_s_k_total_balance"] else None, + total_local_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_o_s_k_total_local_balance"]) if obj["lightspark_node_with_o_s_k_total_local_balance"] else None, + local_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_o_s_k_local_balance"]) if obj["lightspark_node_with_o_s_k_local_balance"] else None, + remote_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_o_s_k_remote_balance"]) if obj["lightspark_node_with_o_s_k_remote_balance"] else None, + blockchain_balance=BlockchainBalance_from_json(requester, obj["lightspark_node_with_o_s_k_blockchain_balance"]) if obj["lightspark_node_with_o_s_k_blockchain_balance"] else None, + uma_prescreening_utxos=obj["lightspark_node_with_o_s_k_uma_prescreening_utxos"], + balances=Balances_from_json(requester, obj["lightspark_node_with_o_s_k_balances"]) if obj["lightspark_node_with_o_s_k_balances"] else None, + encrypted_signing_private_key=Secret_from_json(requester, obj["lightspark_node_with_o_s_k_encrypted_signing_private_key"]) if obj["lightspark_node_with_o_s_k_encrypted_signing_private_key"] else None, + ) if obj["__typename"] == "LightsparkNodeWithRemoteSigning": - # pylint: disable=import-outside-toplevel - from lightspark.objects.LightsparkNodeWithRemoteSigning import ( - LightsparkNodeWithRemoteSigning, - ) - + # pylint: disable=import-outside-toplevel + from lightspark.objects.LightsparkNodeWithRemoteSigning import \ + LightsparkNodeWithRemoteSigning return LightsparkNodeWithRemoteSigning( - requester=requester, - typename="LightsparkNodeWithRemoteSigning", - id=obj["lightspark_node_with_remote_signing_id"], - created_at=datetime.fromisoformat( - obj["lightspark_node_with_remote_signing_created_at"] - ), - updated_at=datetime.fromisoformat( - obj["lightspark_node_with_remote_signing_updated_at"] - ), + requester=requester, typename="LightsparkNodeWithRemoteSigning", id=obj["lightspark_node_with_remote_signing_id"], + 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"], - ), + + bitcoin_network=parse_enum(BitcoinNetwork, obj['lightspark_node_with_remote_signing_bitcoin_network']), color=obj["lightspark_node_with_remote_signing_color"], conductivity=obj["lightspark_node_with_remote_signing_conductivity"], display_name=obj["lightspark_node_with_remote_signing_display_name"], public_key=obj["lightspark_node_with_remote_signing_public_key"], owner_id=obj["lightspark_node_with_remote_signing_owner"]["id"], - status=parse_enum_optional( - LightsparkNodeStatus, obj["lightspark_node_with_remote_signing_status"] - ), - total_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_remote_signing_total_balance"] - ) - if obj["lightspark_node_with_remote_signing_total_balance"] - else None - ), - total_local_balance=( - CurrencyAmount_from_json( - requester, - obj["lightspark_node_with_remote_signing_total_local_balance"], - ) - if obj["lightspark_node_with_remote_signing_total_local_balance"] - else None - ), - local_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_remote_signing_local_balance"] - ) - if obj["lightspark_node_with_remote_signing_local_balance"] - else None - ), - remote_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_remote_signing_remote_balance"] - ) - if obj["lightspark_node_with_remote_signing_remote_balance"] - else None - ), - blockchain_balance=( - BlockchainBalance_from_json( - requester, - obj["lightspark_node_with_remote_signing_blockchain_balance"], - ) - if obj["lightspark_node_with_remote_signing_blockchain_balance"] - else None - ), - uma_prescreening_utxos=obj[ - "lightspark_node_with_remote_signing_uma_prescreening_utxos" - ], - balances=( - Balances_from_json( - requester, obj["lightspark_node_with_remote_signing_balances"] - ) - if obj["lightspark_node_with_remote_signing_balances"] - else None - ), + + status=parse_enum_optional(LightsparkNodeStatus, obj['lightspark_node_with_remote_signing_status']), + total_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_remote_signing_total_balance"]) if obj["lightspark_node_with_remote_signing_total_balance"] else None, + total_local_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_remote_signing_total_local_balance"]) if obj["lightspark_node_with_remote_signing_total_local_balance"] else None, + local_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_remote_signing_local_balance"]) if obj["lightspark_node_with_remote_signing_local_balance"] else None, + remote_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_remote_signing_remote_balance"]) if obj["lightspark_node_with_remote_signing_remote_balance"] else None, + blockchain_balance=BlockchainBalance_from_json(requester, obj["lightspark_node_with_remote_signing_blockchain_balance"]) if obj["lightspark_node_with_remote_signing_blockchain_balance"] else None, + uma_prescreening_utxos=obj["lightspark_node_with_remote_signing_uma_prescreening_utxos"], + balances=Balances_from_json(requester, obj["lightspark_node_with_remote_signing_balances"]) if obj["lightspark_node_with_remote_signing_balances"] else None, + ) graphql_typename = obj["__typename"] - raise LightsparkException( - "UNKNOWN_INTERFACE", - f"Couldn't find a concrete type for interface LightsparkNode corresponding to the typename={graphql_typename}", - ) + raise LightsparkException("UNKNOWN_INTERFACE", f"Couldn't find a concrete type for interface LightsparkNode corresponding to the typename={graphql_typename}") diff --git a/lightspark/objects/LightsparkNodeOwner.py b/lightspark/objects/LightsparkNodeOwner.py index f57adc3..0b25adc 100644 --- a/lightspark/objects/LightsparkNodeOwner.py +++ b/lightspark/objects/LightsparkNodeOwner.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -29,15 +30,19 @@ class LightsparkNodeOwner(Entity): """The date and time when the entity was last updated.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": self.typename, "lightspark_node_owner_id": self.id, "lightspark_node_owner_created_at": self.created_at.isoformat(), "lightspark_node_owner_updated_at": self.updated_at.isoformat(), + } + + FRAGMENT = """ fragment LightsparkNodeOwnerFragment on LightsparkNodeOwner { __typename @@ -91,45 +96,32 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightsparkNodeOwner: if obj["__typename"] == "Account": - # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel from lightspark.objects.Account import Account - return Account( - requester=requester, - typename="Account", - id=obj["account_id"], + requester=requester, typename="Account", id=obj["account_id"], created_at=datetime.fromisoformat(obj["account_created_at"]), updated_at=datetime.fromisoformat(obj["account_updated_at"]), name=obj["account_name"], + ) if obj["__typename"] == "Wallet": - # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel from lightspark.objects.Wallet import Wallet - return Wallet( - requester=requester, - typename="Wallet", - id=obj["wallet_id"], + requester=requester, typename="Wallet", id=obj["wallet_id"], 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 - ), + 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, third_party_identifier=obj["wallet_third_party_identifier"], account_id=obj["wallet_account"]["id"] if obj["wallet_account"] else None, - status=parse_enum(WalletStatus, obj["wallet_status"]), + + status=parse_enum(WalletStatus, obj['wallet_status']), + ) graphql_typename = obj["__typename"] - raise LightsparkException( - "UNKNOWN_INTERFACE", - f"Couldn't find a concrete type for interface LightsparkNodeOwner corresponding to the typename={graphql_typename}", - ) + raise LightsparkException("UNKNOWN_INTERFACE", f"Couldn't find a concrete type for interface LightsparkNodeOwner corresponding to the typename={graphql_typename}") diff --git a/lightspark/objects/LightsparkNodeStatus.py b/lightspark/objects/LightsparkNodeStatus.py index 47db97b..64f9a5a 100644 --- a/lightspark/objects/LightsparkNodeStatus.py +++ b/lightspark/objects/LightsparkNodeStatus.py @@ -1,9 +1,11 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum class LightsparkNodeStatus(Enum): + ___FUTURE_VALUE___ = "___FUTURE_VALUE___" """This is an enum value that represents future values that could be added in the future. Clients should support unknown values as more of them could be added without notice.""" CREATED = "CREATED" @@ -16,3 +18,4 @@ class LightsparkNodeStatus(Enum): TERMINATING = "TERMINATING" WALLET_LOCKED = "WALLET_LOCKED" FAILED_TO_DEPLOY = "FAILED_TO_DEPLOY" + diff --git a/lightspark/objects/LightsparkNodeToChannelsConnection.py b/lightspark/objects/LightsparkNodeToChannelsConnection.py index 5460d96..f7fbb1f 100644 --- a/lightspark/objects/LightsparkNodeToChannelsConnection.py +++ b/lightspark/objects/LightsparkNodeToChannelsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -14,6 +15,7 @@ @dataclass class LightsparkNodeToChannelsConnection(Connection): + requester: Requester count: int @@ -26,17 +28,19 @@ class LightsparkNodeToChannelsConnection(Connection): """The channels for the current page of this connection.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "LightsparkNodeToChannelsConnection", "lightspark_node_to_channels_connection_count": self.count, "lightspark_node_to_channels_connection_page_info": self.page_info.to_json(), - "lightspark_node_to_channels_connection_entities": [ - e.to_json() for e in self.entities - ], + "lightspark_node_to_channels_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment LightsparkNodeToChannelsConnectionFragment on LightsparkNodeToChannelsConnection { __typename @@ -55,21 +59,14 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> LightsparkNodeToChannelsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightsparkNodeToChannelsConnection: return LightsparkNodeToChannelsConnection( - requester=requester, - typename="LightsparkNodeToChannelsConnection", - count=obj["lightspark_node_to_channels_connection_count"], - page_info=PageInfo_from_json( - requester, obj["lightspark_node_to_channels_connection_page_info"] - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: Channel_from_json(requester, e), - obj["lightspark_node_to_channels_connection_entities"], - ) - ), - ) + requester=requester, typename="LightsparkNodeToChannelsConnection", count=obj["lightspark_node_to_channels_connection_count"], + page_info=PageInfo_from_json(requester, obj["lightspark_node_to_channels_connection_page_info"]), + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: Channel_from_json(requester, e), obj["lightspark_node_to_channels_connection_entities"])), + + ) + diff --git a/lightspark/objects/LightsparkNodeToDailyLiquidityForecastsConnection.py b/lightspark/objects/LightsparkNodeToDailyLiquidityForecastsConnection.py index 7ace8a0..b3c3a44 100644 --- a/lightspark/objects/LightsparkNodeToDailyLiquidityForecastsConnection.py +++ b/lightspark/objects/LightsparkNodeToDailyLiquidityForecastsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -8,34 +9,42 @@ from lightspark.utils.enums import parse_enum from .DailyLiquidityForecast import DailyLiquidityForecast -from .DailyLiquidityForecast import from_json as DailyLiquidityForecast_from_json +from .DailyLiquidityForecast import \ + from_json as DailyLiquidityForecast_from_json from .LightningPaymentDirection import LightningPaymentDirection @dataclass -class LightsparkNodeToDailyLiquidityForecastsConnection: +class LightsparkNodeToDailyLiquidityForecastsConnection(): + requester: Requester from_date: datetime + to_date: datetime + direction: LightningPaymentDirection + entities: List[DailyLiquidityForecast] """The daily liquidity forecasts for the current page of this connection.""" + + def to_json(self) -> Mapping[str, Any]: return { "lightspark_node_to_daily_liquidity_forecasts_connection_from_date": self.from_date, "lightspark_node_to_daily_liquidity_forecasts_connection_to_date": self.to_date, "lightspark_node_to_daily_liquidity_forecasts_connection_direction": self.direction.value, - "lightspark_node_to_daily_liquidity_forecasts_connection_entities": [ - e.to_json() for e in self.entities - ], + "lightspark_node_to_daily_liquidity_forecasts_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment LightsparkNodeToDailyLiquidityForecastsConnectionFragment on LightsparkNodeToDailyLiquidityForecastsConnection { __typename @@ -59,24 +68,16 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> LightsparkNodeToDailyLiquidityForecastsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightsparkNodeToDailyLiquidityForecastsConnection: return LightsparkNodeToDailyLiquidityForecastsConnection( - requester=requester, - from_date=obj[ - "lightspark_node_to_daily_liquidity_forecasts_connection_from_date" - ], + requester=requester, from_date=obj["lightspark_node_to_daily_liquidity_forecasts_connection_from_date"], to_date=obj["lightspark_node_to_daily_liquidity_forecasts_connection_to_date"], - direction=parse_enum( - LightningPaymentDirection, - obj["lightspark_node_to_daily_liquidity_forecasts_connection_direction"], - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: DailyLiquidityForecast_from_json(requester, e), - obj["lightspark_node_to_daily_liquidity_forecasts_connection_entities"], - ) - ), - ) + + direction=parse_enum(LightningPaymentDirection, obj['lightspark_node_to_daily_liquidity_forecasts_connection_direction']), + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: DailyLiquidityForecast_from_json(requester, e), obj["lightspark_node_to_daily_liquidity_forecasts_connection_entities"])), + + ) + diff --git a/lightspark/objects/LightsparkNodeWithOSK.py b/lightspark/objects/LightsparkNodeWithOSK.py index fbe39ab..708c00f 100644 --- a/lightspark/objects/LightsparkNodeWithOSK.py +++ b/lightspark/objects/LightsparkNodeWithOSK.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -19,20 +20,19 @@ from .LightningPaymentDirection import LightningPaymentDirection from .LightsparkNode import LightsparkNode from .LightsparkNodeStatus import LightsparkNodeStatus -from .LightsparkNodeToChannelsConnection import LightsparkNodeToChannelsConnection -from .LightsparkNodeToChannelsConnection import ( - from_json as LightsparkNodeToChannelsConnection_from_json, -) -from .LightsparkNodeToDailyLiquidityForecastsConnection import ( - LightsparkNodeToDailyLiquidityForecastsConnection, -) -from .LightsparkNodeToDailyLiquidityForecastsConnection import ( - from_json as LightsparkNodeToDailyLiquidityForecastsConnection_from_json, -) +from .LightsparkNodeToChannelsConnection import \ + LightsparkNodeToChannelsConnection +from .LightsparkNodeToChannelsConnection import \ + from_json as LightsparkNodeToChannelsConnection_from_json +from .LightsparkNodeToDailyLiquidityForecastsConnection import \ + LightsparkNodeToDailyLiquidityForecastsConnection +from .LightsparkNodeToDailyLiquidityForecastsConnection import \ + from_json as LightsparkNodeToDailyLiquidityForecastsConnection_from_json from .Node import Node from .NodeAddressType import NodeAddressType from .NodeToAddressesConnection import NodeToAddressesConnection -from .NodeToAddressesConnection import from_json as NodeToAddressesConnection_from_json +from .NodeToAddressesConnection import \ + from_json as NodeToAddressesConnection_from_json from .Secret import Secret from .Secret import from_json as Secret_from_json @@ -101,9 +101,7 @@ class LightsparkNodeWithOSK(LightsparkNode, Node, Entity): """The private key client is using to sign a GraphQL request which will be verified at server side.""" typename: str - def get_addresses( - self, first: Optional[int] = None, types: Optional[List[NodeAddressType]] = None - ) -> NodeToAddressesConnection: + def get_addresses(self, first: Optional[int]= None, types: Optional[List[NodeAddressType]]= None) -> NodeToAddressesConnection: json = self.requester.execute_graphql( """ query FetchNodeToAddressesConnection($entity_id: ID!, $first: Int, $types: [NodeAddressType!]) { @@ -122,19 +120,12 @@ def get_addresses( } } """, - {"entity_id": self.id, "first": first, "types": types}, + {"entity_id": self.id, "first": first, "types": types} ) connection = json["entity"]["addresses"] return NodeToAddressesConnection_from_json(self.requester, connection) - def get_channels( - self, - first: Optional[int] = None, - after: Optional[str] = None, - before_date: Optional[datetime] = None, - after_date: Optional[datetime] = None, - statuses: Optional[List[ChannelStatus]] = None, - ) -> LightsparkNodeToChannelsConnection: + def get_channels(self, first: Optional[int]= None, after: Optional[str]= None, before_date: Optional[datetime]= None, after_date: Optional[datetime]= None, statuses: Optional[List[ChannelStatus]]= None) -> LightsparkNodeToChannelsConnection: json = self.requester.execute_graphql( """ query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $after: String, $before_date: DateTime, $after_date: DateTime, $statuses: [ChannelStatus!]) { @@ -249,24 +240,12 @@ def get_channels( } } """, - { - "entity_id": self.id, - "first": first, - "after": after, - "before_date": before_date, - "after_date": after_date, - "statuses": statuses, - }, + {"entity_id": self.id, "first": first, "after": after, "before_date": before_date, "after_date": after_date, "statuses": statuses} ) connection = json["entity"]["channels"] return LightsparkNodeToChannelsConnection_from_json(self.requester, connection) - def get_daily_liquidity_forecasts( - self, - from_date: datetime, - to_date: datetime, - direction: LightningPaymentDirection, - ) -> LightsparkNodeToDailyLiquidityForecastsConnection: + def get_daily_liquidity_forecasts(self, from_date: datetime, to_date: datetime, direction: LightningPaymentDirection) -> LightsparkNodeToDailyLiquidityForecastsConnection: json = self.requester.execute_graphql( """ query FetchLightsparkNodeToDailyLiquidityForecastsConnection($entity_id: ID!, $from_date: Date!, $to_date: Date!, $direction: LightningPaymentDirection!) { @@ -295,17 +274,11 @@ def get_daily_liquidity_forecasts( } } """, - { - "entity_id": self.id, - "from_date": from_date, - "to_date": to_date, - "direction": direction, - }, + {"entity_id": self.id, "from_date": from_date, "to_date": to_date, "direction": direction} ) connection = json["entity"]["daily_liquidity_forecasts"] - return LightsparkNodeToDailyLiquidityForecastsConnection_from_json( - self.requester, connection - ) + return LightsparkNodeToDailyLiquidityForecastsConnection_from_json(self.requester, connection) + def to_json(self) -> Mapping[str, Any]: return { @@ -319,37 +292,22 @@ def to_json(self) -> Mapping[str, Any]: "lightspark_node_with_o_s_k_conductivity": self.conductivity, "lightspark_node_with_o_s_k_display_name": self.display_name, "lightspark_node_with_o_s_k_public_key": self.public_key, - "lightspark_node_with_o_s_k_owner": {"id": self.owner_id}, - "lightspark_node_with_o_s_k_status": ( - self.status.value if self.status else None - ), - "lightspark_node_with_o_s_k_total_balance": ( - self.total_balance.to_json() if self.total_balance else None - ), - "lightspark_node_with_o_s_k_total_local_balance": ( - self.total_local_balance.to_json() if self.total_local_balance else None - ), - "lightspark_node_with_o_s_k_local_balance": ( - self.local_balance.to_json() if self.local_balance else None - ), - "lightspark_node_with_o_s_k_remote_balance": ( - self.remote_balance.to_json() if self.remote_balance else None - ), - "lightspark_node_with_o_s_k_blockchain_balance": ( - self.blockchain_balance.to_json() if self.blockchain_balance else None - ), + "lightspark_node_with_o_s_k_owner": { "id": self.owner_id }, + "lightspark_node_with_o_s_k_status": self.status.value if self.status else None, + "lightspark_node_with_o_s_k_total_balance": self.total_balance.to_json() if self.total_balance else None, + "lightspark_node_with_o_s_k_total_local_balance": self.total_local_balance.to_json() if self.total_local_balance else None, + "lightspark_node_with_o_s_k_local_balance": self.local_balance.to_json() if self.local_balance else None, + "lightspark_node_with_o_s_k_remote_balance": self.remote_balance.to_json() if self.remote_balance else None, + "lightspark_node_with_o_s_k_blockchain_balance": self.blockchain_balance.to_json() if self.blockchain_balance else None, "lightspark_node_with_o_s_k_uma_prescreening_utxos": self.uma_prescreening_utxos, - "lightspark_node_with_o_s_k_balances": ( - self.balances.to_json() if self.balances else None - ), - "lightspark_node_with_o_s_k_encrypted_signing_private_key": ( - self.encrypted_signing_private_key.to_json() - if self.encrypted_signing_private_key - else None - ), + "lightspark_node_with_o_s_k_balances": self.balances.to_json() if self.balances else None, + "lightspark_node_with_o_s_k_encrypted_signing_private_key": self.encrypted_signing_private_key.to_json() if self.encrypted_signing_private_key else None, + } + + FRAGMENT = """ fragment LightsparkNodeWithOSKFragment on LightsparkNodeWithOSK { __typename @@ -486,72 +444,30 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightsparkNodeWithOSK: return LightsparkNodeWithOSK( - requester=requester, - typename="LightsparkNodeWithOSK", - id=obj["lightspark_node_with_o_s_k_id"], + requester=requester, typename="LightsparkNodeWithOSK", id=obj["lightspark_node_with_o_s_k_id"], 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"] - ), + + bitcoin_network=parse_enum(BitcoinNetwork, obj['lightspark_node_with_o_s_k_bitcoin_network']), color=obj["lightspark_node_with_o_s_k_color"], conductivity=obj["lightspark_node_with_o_s_k_conductivity"], display_name=obj["lightspark_node_with_o_s_k_display_name"], public_key=obj["lightspark_node_with_o_s_k_public_key"], owner_id=obj["lightspark_node_with_o_s_k_owner"]["id"], - status=parse_enum_optional( - LightsparkNodeStatus, obj["lightspark_node_with_o_s_k_status"] - ), - total_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_o_s_k_total_balance"] - ) - if obj["lightspark_node_with_o_s_k_total_balance"] - else None - ), - total_local_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_o_s_k_total_local_balance"] - ) - if obj["lightspark_node_with_o_s_k_total_local_balance"] - else None - ), - local_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_o_s_k_local_balance"] - ) - if obj["lightspark_node_with_o_s_k_local_balance"] - else None - ), - remote_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_o_s_k_remote_balance"] - ) - if obj["lightspark_node_with_o_s_k_remote_balance"] - else None - ), - blockchain_balance=( - BlockchainBalance_from_json( - requester, obj["lightspark_node_with_o_s_k_blockchain_balance"] - ) - if obj["lightspark_node_with_o_s_k_blockchain_balance"] - else None - ), + + status=parse_enum_optional(LightsparkNodeStatus, obj['lightspark_node_with_o_s_k_status']), + total_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_o_s_k_total_balance"]) if obj["lightspark_node_with_o_s_k_total_balance"] else None, + total_local_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_o_s_k_total_local_balance"]) if obj["lightspark_node_with_o_s_k_total_local_balance"] else None, + local_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_o_s_k_local_balance"]) if obj["lightspark_node_with_o_s_k_local_balance"] else None, + remote_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_o_s_k_remote_balance"]) if obj["lightspark_node_with_o_s_k_remote_balance"] else None, + blockchain_balance=BlockchainBalance_from_json(requester, obj["lightspark_node_with_o_s_k_blockchain_balance"]) if obj["lightspark_node_with_o_s_k_blockchain_balance"] else None, uma_prescreening_utxos=obj["lightspark_node_with_o_s_k_uma_prescreening_utxos"], - balances=( - Balances_from_json(requester, obj["lightspark_node_with_o_s_k_balances"]) - if obj["lightspark_node_with_o_s_k_balances"] - else None - ), - encrypted_signing_private_key=( - Secret_from_json( - requester, - obj["lightspark_node_with_o_s_k_encrypted_signing_private_key"], - ) - if obj["lightspark_node_with_o_s_k_encrypted_signing_private_key"] - else None - ), - ) + balances=Balances_from_json(requester, obj["lightspark_node_with_o_s_k_balances"]) if obj["lightspark_node_with_o_s_k_balances"] else None, + encrypted_signing_private_key=Secret_from_json(requester, obj["lightspark_node_with_o_s_k_encrypted_signing_private_key"]) if obj["lightspark_node_with_o_s_k_encrypted_signing_private_key"] else None, + + ) + diff --git a/lightspark/objects/LightsparkNodeWithRemoteSigning.py b/lightspark/objects/LightsparkNodeWithRemoteSigning.py index 0a909f1..1948fc6 100644 --- a/lightspark/objects/LightsparkNodeWithRemoteSigning.py +++ b/lightspark/objects/LightsparkNodeWithRemoteSigning.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -19,20 +20,19 @@ from .LightningPaymentDirection import LightningPaymentDirection from .LightsparkNode import LightsparkNode from .LightsparkNodeStatus import LightsparkNodeStatus -from .LightsparkNodeToChannelsConnection import LightsparkNodeToChannelsConnection -from .LightsparkNodeToChannelsConnection import ( - from_json as LightsparkNodeToChannelsConnection_from_json, -) -from .LightsparkNodeToDailyLiquidityForecastsConnection import ( - LightsparkNodeToDailyLiquidityForecastsConnection, -) -from .LightsparkNodeToDailyLiquidityForecastsConnection import ( - from_json as LightsparkNodeToDailyLiquidityForecastsConnection_from_json, -) +from .LightsparkNodeToChannelsConnection import \ + LightsparkNodeToChannelsConnection +from .LightsparkNodeToChannelsConnection import \ + from_json as LightsparkNodeToChannelsConnection_from_json +from .LightsparkNodeToDailyLiquidityForecastsConnection import \ + LightsparkNodeToDailyLiquidityForecastsConnection +from .LightsparkNodeToDailyLiquidityForecastsConnection import \ + from_json as LightsparkNodeToDailyLiquidityForecastsConnection_from_json from .Node import Node from .NodeAddressType import NodeAddressType from .NodeToAddressesConnection import NodeToAddressesConnection -from .NodeToAddressesConnection import from_json as NodeToAddressesConnection_from_json +from .NodeToAddressesConnection import \ + from_json as NodeToAddressesConnection_from_json @dataclass @@ -96,9 +96,7 @@ class LightsparkNodeWithRemoteSigning(LightsparkNode, Node, Entity): """The balances that describe the funds in this node.""" typename: str - def get_addresses( - self, first: Optional[int] = None, types: Optional[List[NodeAddressType]] = None - ) -> NodeToAddressesConnection: + def get_addresses(self, first: Optional[int]= None, types: Optional[List[NodeAddressType]]= None) -> NodeToAddressesConnection: json = self.requester.execute_graphql( """ query FetchNodeToAddressesConnection($entity_id: ID!, $first: Int, $types: [NodeAddressType!]) { @@ -117,19 +115,12 @@ def get_addresses( } } """, - {"entity_id": self.id, "first": first, "types": types}, + {"entity_id": self.id, "first": first, "types": types} ) connection = json["entity"]["addresses"] return NodeToAddressesConnection_from_json(self.requester, connection) - def get_channels( - self, - first: Optional[int] = None, - after: Optional[str] = None, - before_date: Optional[datetime] = None, - after_date: Optional[datetime] = None, - statuses: Optional[List[ChannelStatus]] = None, - ) -> LightsparkNodeToChannelsConnection: + def get_channels(self, first: Optional[int]= None, after: Optional[str]= None, before_date: Optional[datetime]= None, after_date: Optional[datetime]= None, statuses: Optional[List[ChannelStatus]]= None) -> LightsparkNodeToChannelsConnection: json = self.requester.execute_graphql( """ query FetchLightsparkNodeToChannelsConnection($entity_id: ID!, $first: Int, $after: String, $before_date: DateTime, $after_date: DateTime, $statuses: [ChannelStatus!]) { @@ -244,24 +235,12 @@ def get_channels( } } """, - { - "entity_id": self.id, - "first": first, - "after": after, - "before_date": before_date, - "after_date": after_date, - "statuses": statuses, - }, + {"entity_id": self.id, "first": first, "after": after, "before_date": before_date, "after_date": after_date, "statuses": statuses} ) connection = json["entity"]["channels"] return LightsparkNodeToChannelsConnection_from_json(self.requester, connection) - def get_daily_liquidity_forecasts( - self, - from_date: datetime, - to_date: datetime, - direction: LightningPaymentDirection, - ) -> LightsparkNodeToDailyLiquidityForecastsConnection: + def get_daily_liquidity_forecasts(self, from_date: datetime, to_date: datetime, direction: LightningPaymentDirection) -> LightsparkNodeToDailyLiquidityForecastsConnection: json = self.requester.execute_graphql( """ query FetchLightsparkNodeToDailyLiquidityForecastsConnection($entity_id: ID!, $from_date: Date!, $to_date: Date!, $direction: LightningPaymentDirection!) { @@ -290,17 +269,11 @@ def get_daily_liquidity_forecasts( } } """, - { - "entity_id": self.id, - "from_date": from_date, - "to_date": to_date, - "direction": direction, - }, + {"entity_id": self.id, "from_date": from_date, "to_date": to_date, "direction": direction} ) connection = json["entity"]["daily_liquidity_forecasts"] - return LightsparkNodeToDailyLiquidityForecastsConnection_from_json( - self.requester, connection - ) + return LightsparkNodeToDailyLiquidityForecastsConnection_from_json(self.requester, connection) + def to_json(self) -> Mapping[str, Any]: return { @@ -314,32 +287,21 @@ def to_json(self) -> Mapping[str, Any]: "lightspark_node_with_remote_signing_conductivity": self.conductivity, "lightspark_node_with_remote_signing_display_name": self.display_name, "lightspark_node_with_remote_signing_public_key": self.public_key, - "lightspark_node_with_remote_signing_owner": {"id": self.owner_id}, - "lightspark_node_with_remote_signing_status": ( - self.status.value if self.status else None - ), - "lightspark_node_with_remote_signing_total_balance": ( - self.total_balance.to_json() if self.total_balance else None - ), - "lightspark_node_with_remote_signing_total_local_balance": ( - self.total_local_balance.to_json() if self.total_local_balance else None - ), - "lightspark_node_with_remote_signing_local_balance": ( - self.local_balance.to_json() if self.local_balance else None - ), - "lightspark_node_with_remote_signing_remote_balance": ( - self.remote_balance.to_json() if self.remote_balance else None - ), - "lightspark_node_with_remote_signing_blockchain_balance": ( - self.blockchain_balance.to_json() if self.blockchain_balance else None - ), + "lightspark_node_with_remote_signing_owner": { "id": self.owner_id }, + "lightspark_node_with_remote_signing_status": self.status.value if self.status else None, + "lightspark_node_with_remote_signing_total_balance": self.total_balance.to_json() if self.total_balance else None, + "lightspark_node_with_remote_signing_total_local_balance": self.total_local_balance.to_json() if self.total_local_balance else None, + "lightspark_node_with_remote_signing_local_balance": self.local_balance.to_json() if self.local_balance else None, + "lightspark_node_with_remote_signing_remote_balance": self.remote_balance.to_json() if self.remote_balance else None, + "lightspark_node_with_remote_signing_blockchain_balance": self.blockchain_balance.to_json() if self.blockchain_balance else None, "lightspark_node_with_remote_signing_uma_prescreening_utxos": self.uma_prescreening_utxos, - "lightspark_node_with_remote_signing_balances": ( - self.balances.to_json() if self.balances else None - ), + "lightspark_node_with_remote_signing_balances": self.balances.to_json() if self.balances else None, + } + + FRAGMENT = """ fragment LightsparkNodeWithRemoteSigningFragment on LightsparkNodeWithRemoteSigning { __typename @@ -471,75 +433,29 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> LightsparkNodeWithRemoteSigning: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightsparkNodeWithRemoteSigning: return LightsparkNodeWithRemoteSigning( - requester=requester, - typename="LightsparkNodeWithRemoteSigning", - id=obj["lightspark_node_with_remote_signing_id"], - created_at=datetime.fromisoformat( - obj["lightspark_node_with_remote_signing_created_at"] - ), - updated_at=datetime.fromisoformat( - obj["lightspark_node_with_remote_signing_updated_at"] - ), + requester=requester, typename="LightsparkNodeWithRemoteSigning", id=obj["lightspark_node_with_remote_signing_id"], + 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"] - ), + + bitcoin_network=parse_enum(BitcoinNetwork, obj['lightspark_node_with_remote_signing_bitcoin_network']), color=obj["lightspark_node_with_remote_signing_color"], conductivity=obj["lightspark_node_with_remote_signing_conductivity"], display_name=obj["lightspark_node_with_remote_signing_display_name"], public_key=obj["lightspark_node_with_remote_signing_public_key"], owner_id=obj["lightspark_node_with_remote_signing_owner"]["id"], - status=parse_enum_optional( - LightsparkNodeStatus, obj["lightspark_node_with_remote_signing_status"] - ), - total_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_remote_signing_total_balance"] - ) - if obj["lightspark_node_with_remote_signing_total_balance"] - else None - ), - total_local_balance=( - CurrencyAmount_from_json( - requester, - obj["lightspark_node_with_remote_signing_total_local_balance"], - ) - if obj["lightspark_node_with_remote_signing_total_local_balance"] - else None - ), - local_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_remote_signing_local_balance"] - ) - if obj["lightspark_node_with_remote_signing_local_balance"] - else None - ), - remote_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_remote_signing_remote_balance"] - ) - if obj["lightspark_node_with_remote_signing_remote_balance"] - else None - ), - blockchain_balance=( - BlockchainBalance_from_json( - requester, obj["lightspark_node_with_remote_signing_blockchain_balance"] - ) - if obj["lightspark_node_with_remote_signing_blockchain_balance"] - else None - ), - uma_prescreening_utxos=obj[ - "lightspark_node_with_remote_signing_uma_prescreening_utxos" - ], - balances=( - Balances_from_json( - requester, obj["lightspark_node_with_remote_signing_balances"] - ) - if obj["lightspark_node_with_remote_signing_balances"] - else None - ), - ) + + status=parse_enum_optional(LightsparkNodeStatus, obj['lightspark_node_with_remote_signing_status']), + total_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_remote_signing_total_balance"]) if obj["lightspark_node_with_remote_signing_total_balance"] else None, + total_local_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_remote_signing_total_local_balance"]) if obj["lightspark_node_with_remote_signing_total_local_balance"] else None, + local_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_remote_signing_local_balance"]) if obj["lightspark_node_with_remote_signing_local_balance"] else None, + remote_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_remote_signing_remote_balance"]) if obj["lightspark_node_with_remote_signing_remote_balance"] else None, + blockchain_balance=BlockchainBalance_from_json(requester, obj["lightspark_node_with_remote_signing_blockchain_balance"]) if obj["lightspark_node_with_remote_signing_blockchain_balance"] else None, + uma_prescreening_utxos=obj["lightspark_node_with_remote_signing_uma_prescreening_utxos"], + balances=Balances_from_json(requester, obj["lightspark_node_with_remote_signing_balances"]) if obj["lightspark_node_with_remote_signing_balances"] else None, + + ) + diff --git a/lightspark/objects/MultiSigAddressValidationParameters.py b/lightspark/objects/MultiSigAddressValidationParameters.py index 748d231..bbde7a3 100644 --- a/lightspark/objects/MultiSigAddressValidationParameters.py +++ b/lightspark/objects/MultiSigAddressValidationParameters.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,7 +8,8 @@ @dataclass -class MultiSigAddressValidationParameters: +class MultiSigAddressValidationParameters(): + requester: Requester counterparty_funding_pubkey: str @@ -16,13 +18,18 @@ class MultiSigAddressValidationParameters: funding_pubkey_derivation_path: str """The derivation path used to derive the funding public key for the 2-of-2 multisig address.""" + + def to_json(self) -> Mapping[str, Any]: return { "multi_sig_address_validation_parameters_counterparty_funding_pubkey": self.counterparty_funding_pubkey, "multi_sig_address_validation_parameters_funding_pubkey_derivation_path": self.funding_pubkey_derivation_path, + } + + FRAGMENT = """ fragment MultiSigAddressValidationParametersFragment on MultiSigAddressValidationParameters { __typename @@ -32,15 +39,11 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> MultiSigAddressValidationParameters: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> MultiSigAddressValidationParameters: return MultiSigAddressValidationParameters( - requester=requester, - counterparty_funding_pubkey=obj[ - "multi_sig_address_validation_parameters_counterparty_funding_pubkey" - ], - funding_pubkey_derivation_path=obj[ - "multi_sig_address_validation_parameters_funding_pubkey_derivation_path" - ], - ) + requester=requester, counterparty_funding_pubkey=obj["multi_sig_address_validation_parameters_counterparty_funding_pubkey"], + funding_pubkey_derivation_path=obj["multi_sig_address_validation_parameters_funding_pubkey_derivation_path"], + + ) + diff --git a/lightspark/objects/Node.py b/lightspark/objects/Node.py index 7b05295..1fe648e 100644 --- a/lightspark/objects/Node.py +++ b/lightspark/objects/Node.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -16,7 +17,8 @@ from .LightsparkNodeStatus import LightsparkNodeStatus from .NodeAddressType import NodeAddressType from .NodeToAddressesConnection import NodeToAddressesConnection -from .NodeToAddressesConnection import from_json as NodeToAddressesConnection_from_json +from .NodeToAddressesConnection import \ + from_json as NodeToAddressesConnection_from_json from .Secret import from_json as Secret_from_json @@ -54,9 +56,7 @@ class Node(Entity): """The public key of this node. It acts as a unique identifier of this node in the Lightning Network.""" typename: str - def get_addresses( - self, first: Optional[int] = None, types: Optional[List[NodeAddressType]] = None - ) -> NodeToAddressesConnection: + def get_addresses(self, first: Optional[int]= None, types: Optional[List[NodeAddressType]]= None) -> NodeToAddressesConnection: json = self.requester.execute_graphql( """ query FetchNodeToAddressesConnection($entity_id: ID!, $first: Int, $types: [NodeAddressType!]) { @@ -75,11 +75,12 @@ def get_addresses( } } """, - {"entity_id": self.id, "first": first, "types": types}, + {"entity_id": self.id, "first": first, "types": types} ) connection = json["entity"]["addresses"] return NodeToAddressesConnection_from_json(self.requester, connection) + def to_json(self) -> Mapping[str, Any]: return { "__typename": self.typename, @@ -92,9 +93,12 @@ def to_json(self) -> Mapping[str, Any]: "node_conductivity": self.conductivity, "node_display_name": self.display_name, "node_public_key": self.public_key, + } + + FRAGMENT = """ fragment NodeFragment on Node { __typename @@ -373,185 +377,78 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> Node: if obj["__typename"] == "GraphNode": - # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel from lightspark.objects.GraphNode import GraphNode - return GraphNode( - requester=requester, - typename="GraphNode", - id=obj["graph_node_id"], + requester=requester, typename="GraphNode", id=obj["graph_node_id"], 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"] - ), + + bitcoin_network=parse_enum(BitcoinNetwork, obj['graph_node_bitcoin_network']), color=obj["graph_node_color"], conductivity=obj["graph_node_conductivity"], display_name=obj["graph_node_display_name"], public_key=obj["graph_node_public_key"], + ) if obj["__typename"] == "LightsparkNodeWithOSK": - # pylint: disable=import-outside-toplevel - from lightspark.objects.LightsparkNodeWithOSK import LightsparkNodeWithOSK - + # pylint: disable=import-outside-toplevel + from lightspark.objects.LightsparkNodeWithOSK import \ + LightsparkNodeWithOSK return LightsparkNodeWithOSK( - requester=requester, - typename="LightsparkNodeWithOSK", - id=obj["lightspark_node_with_o_s_k_id"], - 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"] - ), + requester=requester, typename="LightsparkNodeWithOSK", id=obj["lightspark_node_with_o_s_k_id"], + 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"] - ), + + bitcoin_network=parse_enum(BitcoinNetwork, obj['lightspark_node_with_o_s_k_bitcoin_network']), color=obj["lightspark_node_with_o_s_k_color"], conductivity=obj["lightspark_node_with_o_s_k_conductivity"], display_name=obj["lightspark_node_with_o_s_k_display_name"], public_key=obj["lightspark_node_with_o_s_k_public_key"], owner_id=obj["lightspark_node_with_o_s_k_owner"]["id"], - status=parse_enum_optional( - LightsparkNodeStatus, obj["lightspark_node_with_o_s_k_status"] - ), - total_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_o_s_k_total_balance"] - ) - if obj["lightspark_node_with_o_s_k_total_balance"] - else None - ), - total_local_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_o_s_k_total_local_balance"] - ) - if obj["lightspark_node_with_o_s_k_total_local_balance"] - else None - ), - local_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_o_s_k_local_balance"] - ) - if obj["lightspark_node_with_o_s_k_local_balance"] - else None - ), - remote_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_o_s_k_remote_balance"] - ) - if obj["lightspark_node_with_o_s_k_remote_balance"] - else None - ), - blockchain_balance=( - BlockchainBalance_from_json( - requester, obj["lightspark_node_with_o_s_k_blockchain_balance"] - ) - if obj["lightspark_node_with_o_s_k_blockchain_balance"] - else None - ), - uma_prescreening_utxos=obj[ - "lightspark_node_with_o_s_k_uma_prescreening_utxos" - ], - balances=( - Balances_from_json( - requester, obj["lightspark_node_with_o_s_k_balances"] - ) - if obj["lightspark_node_with_o_s_k_balances"] - else None - ), - encrypted_signing_private_key=( - Secret_from_json( - requester, - obj["lightspark_node_with_o_s_k_encrypted_signing_private_key"], - ) - if obj["lightspark_node_with_o_s_k_encrypted_signing_private_key"] - else None - ), + + status=parse_enum_optional(LightsparkNodeStatus, obj['lightspark_node_with_o_s_k_status']), + total_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_o_s_k_total_balance"]) if obj["lightspark_node_with_o_s_k_total_balance"] else None, + total_local_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_o_s_k_total_local_balance"]) if obj["lightspark_node_with_o_s_k_total_local_balance"] else None, + local_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_o_s_k_local_balance"]) if obj["lightspark_node_with_o_s_k_local_balance"] else None, + remote_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_o_s_k_remote_balance"]) if obj["lightspark_node_with_o_s_k_remote_balance"] else None, + blockchain_balance=BlockchainBalance_from_json(requester, obj["lightspark_node_with_o_s_k_blockchain_balance"]) if obj["lightspark_node_with_o_s_k_blockchain_balance"] else None, + uma_prescreening_utxos=obj["lightspark_node_with_o_s_k_uma_prescreening_utxos"], + balances=Balances_from_json(requester, obj["lightspark_node_with_o_s_k_balances"]) if obj["lightspark_node_with_o_s_k_balances"] else None, + encrypted_signing_private_key=Secret_from_json(requester, obj["lightspark_node_with_o_s_k_encrypted_signing_private_key"]) if obj["lightspark_node_with_o_s_k_encrypted_signing_private_key"] else None, + ) if obj["__typename"] == "LightsparkNodeWithRemoteSigning": - # pylint: disable=import-outside-toplevel - from lightspark.objects.LightsparkNodeWithRemoteSigning import ( - LightsparkNodeWithRemoteSigning, - ) - + # pylint: disable=import-outside-toplevel + from lightspark.objects.LightsparkNodeWithRemoteSigning import \ + LightsparkNodeWithRemoteSigning return LightsparkNodeWithRemoteSigning( - requester=requester, - typename="LightsparkNodeWithRemoteSigning", - id=obj["lightspark_node_with_remote_signing_id"], - created_at=datetime.fromisoformat( - obj["lightspark_node_with_remote_signing_created_at"] - ), - updated_at=datetime.fromisoformat( - obj["lightspark_node_with_remote_signing_updated_at"] - ), + requester=requester, typename="LightsparkNodeWithRemoteSigning", id=obj["lightspark_node_with_remote_signing_id"], + 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"], - ), + + bitcoin_network=parse_enum(BitcoinNetwork, obj['lightspark_node_with_remote_signing_bitcoin_network']), color=obj["lightspark_node_with_remote_signing_color"], conductivity=obj["lightspark_node_with_remote_signing_conductivity"], display_name=obj["lightspark_node_with_remote_signing_display_name"], public_key=obj["lightspark_node_with_remote_signing_public_key"], owner_id=obj["lightspark_node_with_remote_signing_owner"]["id"], - status=parse_enum_optional( - LightsparkNodeStatus, obj["lightspark_node_with_remote_signing_status"] - ), - total_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_remote_signing_total_balance"] - ) - if obj["lightspark_node_with_remote_signing_total_balance"] - else None - ), - total_local_balance=( - CurrencyAmount_from_json( - requester, - obj["lightspark_node_with_remote_signing_total_local_balance"], - ) - if obj["lightspark_node_with_remote_signing_total_local_balance"] - else None - ), - local_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_remote_signing_local_balance"] - ) - if obj["lightspark_node_with_remote_signing_local_balance"] - else None - ), - remote_balance=( - CurrencyAmount_from_json( - requester, obj["lightspark_node_with_remote_signing_remote_balance"] - ) - if obj["lightspark_node_with_remote_signing_remote_balance"] - else None - ), - blockchain_balance=( - BlockchainBalance_from_json( - requester, - obj["lightspark_node_with_remote_signing_blockchain_balance"], - ) - if obj["lightspark_node_with_remote_signing_blockchain_balance"] - else None - ), - uma_prescreening_utxos=obj[ - "lightspark_node_with_remote_signing_uma_prescreening_utxos" - ], - balances=( - Balances_from_json( - requester, obj["lightspark_node_with_remote_signing_balances"] - ) - if obj["lightspark_node_with_remote_signing_balances"] - else None - ), + + status=parse_enum_optional(LightsparkNodeStatus, obj['lightspark_node_with_remote_signing_status']), + total_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_remote_signing_total_balance"]) if obj["lightspark_node_with_remote_signing_total_balance"] else None, + total_local_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_remote_signing_total_local_balance"]) if obj["lightspark_node_with_remote_signing_total_local_balance"] else None, + local_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_remote_signing_local_balance"]) if obj["lightspark_node_with_remote_signing_local_balance"] else None, + remote_balance=CurrencyAmount_from_json(requester, obj["lightspark_node_with_remote_signing_remote_balance"]) if obj["lightspark_node_with_remote_signing_remote_balance"] else None, + blockchain_balance=BlockchainBalance_from_json(requester, obj["lightspark_node_with_remote_signing_blockchain_balance"]) if obj["lightspark_node_with_remote_signing_blockchain_balance"] else None, + uma_prescreening_utxos=obj["lightspark_node_with_remote_signing_uma_prescreening_utxos"], + balances=Balances_from_json(requester, obj["lightspark_node_with_remote_signing_balances"]) if obj["lightspark_node_with_remote_signing_balances"] else None, + ) graphql_typename = obj["__typename"] - raise LightsparkException( - "UNKNOWN_INTERFACE", - f"Couldn't find a concrete type for interface Node corresponding to the typename={graphql_typename}", - ) + raise LightsparkException("UNKNOWN_INTERFACE", f"Couldn't find a concrete type for interface Node corresponding to the typename={graphql_typename}") diff --git a/lightspark/objects/NodeAddress.py b/lightspark/objects/NodeAddress.py index 62c5bb5..8c9b02b 100644 --- a/lightspark/objects/NodeAddress.py +++ b/lightspark/objects/NodeAddress.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,7 +11,7 @@ @dataclass -class NodeAddress: +class NodeAddress(): """This object represents the address of a node on the Lightning Network.""" requester: Requester @@ -21,13 +22,18 @@ class NodeAddress: type: NodeAddressType """The type, or protocol, of this address.""" + + def to_json(self) -> Mapping[str, Any]: return { "node_address_address": self.address, "node_address_type": self.type.value, + } + + FRAGMENT = """ fragment NodeAddressFragment on NodeAddress { __typename @@ -37,9 +43,12 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> NodeAddress: return NodeAddress( - requester=requester, - address=obj["node_address_address"], - type=parse_enum(NodeAddressType, obj["node_address_type"]), - ) + requester=requester, address=obj["node_address_address"], + + type=parse_enum(NodeAddressType, obj['node_address_type']), + + ) + diff --git a/lightspark/objects/NodeAddressType.py b/lightspark/objects/NodeAddressType.py index c9b417b..2b9d21d 100644 --- a/lightspark/objects/NodeAddressType.py +++ b/lightspark/objects/NodeAddressType.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -11,3 +12,4 @@ class NodeAddressType(Enum): IPV4 = "IPV4" IPV6 = "IPV6" TOR = "TOR" + diff --git a/lightspark/objects/NodeToAddressesConnection.py b/lightspark/objects/NodeToAddressesConnection.py index 8093dd1..55a1a54 100644 --- a/lightspark/objects/NodeToAddressesConnection.py +++ b/lightspark/objects/NodeToAddressesConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,7 +11,7 @@ @dataclass -class NodeToAddressesConnection: +class NodeToAddressesConnection(): """A connection between a node and the addresses it has announced for itself on Lightning Network.""" requester: Requester @@ -21,15 +22,18 @@ class NodeToAddressesConnection: entities: List[NodeAddress] """The addresses for the current page of this connection.""" + + def to_json(self) -> Mapping[str, Any]: return { "node_to_addresses_connection_count": self.count, - "node_to_addresses_connection_entities": [ - e.to_json() for e in self.entities - ], + "node_to_addresses_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment NodeToAddressesConnectionFragment on NodeToAddressesConnection { __typename @@ -43,17 +47,13 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> NodeToAddressesConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> NodeToAddressesConnection: return NodeToAddressesConnection( - requester=requester, - count=obj["node_to_addresses_connection_count"], - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: NodeAddress_from_json(requester, e), - obj["node_to_addresses_connection_entities"], - ) - ), - ) + requester=requester, count=obj["node_to_addresses_connection_count"], + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: NodeAddress_from_json(requester, e), obj["node_to_addresses_connection_entities"])), + + ) + diff --git a/lightspark/objects/Offer.py b/lightspark/objects/Offer.py new file mode 100644 index 0000000..56ef18d --- /dev/null +++ b/lightspark/objects/Offer.py @@ -0,0 +1,95 @@ + +# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved + +from dataclasses import dataclass +from datetime import datetime +from typing import Any, Mapping, Optional + +from lightspark.requests.requester import Requester + +from .CurrencyAmount import CurrencyAmount +from .CurrencyAmount import from_json as CurrencyAmount_from_json +from .Entity import Entity + + +@dataclass +class Offer(Entity): + """This object represents a BOLT #12 offer (https://github.com/lightning/bolts/blob/master/12-offer-encoding.md) created by a Lightspark Node.""" + + requester: Requester + + id: str + """The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string.""" + + created_at: datetime + """The date and time when the entity was first created.""" + + updated_at: datetime + """The date and time when the entity was last updated.""" + + data_id: str + """The details of the offer.""" + + encoded_offer: str + """The BOLT12 encoded offer. Starts with 'lno'.""" + + amount: Optional[CurrencyAmount] + """The amount of the offer. If null, the payer chooses the amount.""" + + description: Optional[str] + """The description of the offer.""" + typename: str + + + def to_json(self) -> Mapping[str, Any]: + return { + "__typename": "Offer", + "offer_id": self.id, + "offer_created_at": self.created_at.isoformat(), + "offer_updated_at": self.updated_at.isoformat(), + "offer_data": { "id": self.data_id }, + "offer_encoded_offer": self.encoded_offer, + "offer_amount": self.amount.to_json() if self.amount else None, + "offer_description": self.description, + + } + + + + +FRAGMENT = """ +fragment OfferFragment on Offer { + __typename + offer_id: id + offer_created_at: created_at + offer_updated_at: updated_at + offer_data: data { + id + } + offer_encoded_offer: encoded_offer + offer_amount: amount { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + offer_description: description +} +""" + + + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> Offer: + return Offer( + requester=requester, typename="Offer", id=obj["offer_id"], + created_at=datetime.fromisoformat(obj["offer_created_at"]), + updated_at=datetime.fromisoformat(obj["offer_updated_at"]), + data_id=obj["offer_data"]["id"], + encoded_offer=obj["offer_encoded_offer"], + amount=CurrencyAmount_from_json(requester, obj["offer_amount"]) if obj["offer_amount"] else None, + description=obj["offer_description"], + + ) + diff --git a/lightspark/objects/OfferData.py b/lightspark/objects/OfferData.py new file mode 100644 index 0000000..70c68c6 --- /dev/null +++ b/lightspark/objects/OfferData.py @@ -0,0 +1,95 @@ + +# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved + +from dataclasses import dataclass +from datetime import datetime +from typing import Any, List, Mapping, Optional + +from lightspark.requests.requester import Requester +from lightspark.utils.enums import parse_enum_list + +from .BitcoinNetwork import BitcoinNetwork +from .CurrencyAmount import CurrencyAmount +from .CurrencyAmount import from_json as CurrencyAmount_from_json +from .Entity import Entity + + +@dataclass +class OfferData(Entity): + """This object represents the data associated with a BOLT #12 offer. You can retrieve this object to receive the relevant data associated with a specific offer.""" + + requester: Requester + + id: str + """The unique identifier of this entity across all Lightspark systems. Should be treated as an opaque string.""" + + created_at: datetime + """The date and time when the entity was first created.""" + + updated_at: datetime + """The date and time when the entity was last updated.""" + + amount: Optional[CurrencyAmount] + """The requested amount in this invoice. If it is equal to 0, the sender should choose the amount to send.""" + + encoded_offer: str + """The Bech32 encoded offer.""" + + bitcoin_networks: List[BitcoinNetwork] + """The bitcoin networks supported by the offer.""" + + expires_at: Optional[datetime] + """The date and time when this invoice will expire.""" + typename: str + + + def to_json(self) -> Mapping[str, Any]: + return { + "__typename": "OfferData", + "offer_data_id": self.id, + "offer_data_created_at": self.created_at.isoformat(), + "offer_data_updated_at": self.updated_at.isoformat(), + "offer_data_amount": self.amount.to_json() if self.amount else None, + "offer_data_encoded_offer": self.encoded_offer, + "offer_data_bitcoin_networks": [e.value for e in self.bitcoin_networks], + "offer_data_expires_at": self.expires_at.isoformat() if self.expires_at else None, + + } + + + + +FRAGMENT = """ +fragment OfferDataFragment on OfferData { + __typename + offer_data_id: id + offer_data_created_at: created_at + offer_data_updated_at: updated_at + offer_data_amount: amount { + __typename + currency_amount_original_value: original_value + currency_amount_original_unit: original_unit + currency_amount_preferred_currency_unit: preferred_currency_unit + currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded + currency_amount_preferred_currency_value_approx: preferred_currency_value_approx + } + offer_data_encoded_offer: encoded_offer + offer_data_bitcoin_networks: bitcoin_networks + offer_data_expires_at: expires_at +} +""" + + + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> OfferData: + return OfferData( + requester=requester, typename="OfferData", id=obj["offer_data_id"], + created_at=datetime.fromisoformat(obj["offer_data_created_at"]), + updated_at=datetime.fromisoformat(obj["offer_data_updated_at"]), + amount=CurrencyAmount_from_json(requester, obj["offer_data_amount"]) if obj["offer_data_amount"] else None, + encoded_offer=obj["offer_data_encoded_offer"], + bitcoin_networks=parse_enum_list(BitcoinNetwork, obj["offer_data_bitcoin_networks"]), + expires_at=datetime.fromisoformat(obj["offer_data_expires_at"]) if obj["offer_data_expires_at"] else None, + + ) + diff --git a/lightspark/objects/OnChainFeeTarget.py b/lightspark/objects/OnChainFeeTarget.py index cabed26..9ab4558 100644 --- a/lightspark/objects/OnChainFeeTarget.py +++ b/lightspark/objects/OnChainFeeTarget.py @@ -1,9 +1,11 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum class OnChainFeeTarget(Enum): + ___FUTURE_VALUE___ = "___FUTURE_VALUE___" """This is an enum value that represents future values that could be added in the future. Clients should support unknown values as more of them could be added without notice.""" HIGH = "HIGH" @@ -14,3 +16,4 @@ class OnChainFeeTarget(Enum): """Transaction expected to be confirmed within 18 blocks.""" BACKGROUND = "BACKGROUND" """Transaction expected to be confirmed within 50 blocks.""" + diff --git a/lightspark/objects/OnChainTransaction.py b/lightspark/objects/OnChainTransaction.py index 0035f22..7272f27 100644 --- a/lightspark/objects/OnChainTransaction.py +++ b/lightspark/objects/OnChainTransaction.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -58,6 +59,7 @@ class OnChainTransaction(Transaction, Entity): """The number of blockchain confirmations for this transaction in real time.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": self.typename, @@ -65,9 +67,7 @@ def to_json(self) -> Mapping[str, Any]: "on_chain_transaction_created_at": self.created_at.isoformat(), "on_chain_transaction_updated_at": self.updated_at.isoformat(), "on_chain_transaction_status": self.status.value, - "on_chain_transaction_resolved_at": ( - self.resolved_at.isoformat() if self.resolved_at else None - ), + "on_chain_transaction_resolved_at": self.resolved_at.isoformat() if self.resolved_at else None, "on_chain_transaction_amount": self.amount.to_json(), "on_chain_transaction_transaction_hash": self.transaction_hash, "on_chain_transaction_fees": self.fees.to_json() if self.fees else None, @@ -75,9 +75,12 @@ def to_json(self) -> Mapping[str, Any]: "on_chain_transaction_block_height": self.block_height, "on_chain_transaction_destination_addresses": self.destination_addresses, "on_chain_transaction_num_confirmations": self.num_confirmations, + } + + FRAGMENT = """ fragment OnChainTransactionFragment on OnChainTransaction { __typename @@ -213,161 +216,89 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> OnChainTransaction: if obj["__typename"] == "ChannelClosingTransaction": - # pylint: disable=import-outside-toplevel - from lightspark.objects.ChannelClosingTransaction import ( - ChannelClosingTransaction, - ) - + # pylint: disable=import-outside-toplevel + from lightspark.objects.ChannelClosingTransaction import \ + ChannelClosingTransaction return ChannelClosingTransaction( - requester=requester, - typename="ChannelClosingTransaction", - id=obj["channel_closing_transaction_id"], - 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=( - 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"] - ), + requester=requester, typename="ChannelClosingTransaction", id=obj["channel_closing_transaction_id"], + 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=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"]), transaction_hash=obj["channel_closing_transaction_transaction_hash"], - fees=( - CurrencyAmount_from_json( - requester, obj["channel_closing_transaction_fees"] - ) - if obj["channel_closing_transaction_fees"] - else None - ), + fees=CurrencyAmount_from_json(requester, obj["channel_closing_transaction_fees"]) if obj["channel_closing_transaction_fees"] else None, block_hash=obj["channel_closing_transaction_block_hash"], block_height=obj["channel_closing_transaction_block_height"], - destination_addresses=obj[ - "channel_closing_transaction_destination_addresses" - ], + destination_addresses=obj["channel_closing_transaction_destination_addresses"], num_confirmations=obj["channel_closing_transaction_num_confirmations"], - channel_id=( - obj["channel_closing_transaction_channel"]["id"] - if obj["channel_closing_transaction_channel"] - else None - ), + channel_id=obj["channel_closing_transaction_channel"]["id"] if obj["channel_closing_transaction_channel"] else None, + ) if obj["__typename"] == "ChannelOpeningTransaction": - # pylint: disable=import-outside-toplevel - from lightspark.objects.ChannelOpeningTransaction import ( - ChannelOpeningTransaction, - ) - + # pylint: disable=import-outside-toplevel + from lightspark.objects.ChannelOpeningTransaction import \ + ChannelOpeningTransaction return ChannelOpeningTransaction( - requester=requester, - typename="ChannelOpeningTransaction", - id=obj["channel_opening_transaction_id"], - 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=( - 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"] - ), + requester=requester, typename="ChannelOpeningTransaction", id=obj["channel_opening_transaction_id"], + 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=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"]), transaction_hash=obj["channel_opening_transaction_transaction_hash"], - fees=( - CurrencyAmount_from_json( - requester, obj["channel_opening_transaction_fees"] - ) - if obj["channel_opening_transaction_fees"] - else None - ), + fees=CurrencyAmount_from_json(requester, obj["channel_opening_transaction_fees"]) if obj["channel_opening_transaction_fees"] else None, block_hash=obj["channel_opening_transaction_block_hash"], block_height=obj["channel_opening_transaction_block_height"], - destination_addresses=obj[ - "channel_opening_transaction_destination_addresses" - ], + destination_addresses=obj["channel_opening_transaction_destination_addresses"], num_confirmations=obj["channel_opening_transaction_num_confirmations"], - channel_id=( - obj["channel_opening_transaction_channel"]["id"] - if obj["channel_opening_transaction_channel"] - else None - ), + channel_id=obj["channel_opening_transaction_channel"]["id"] if obj["channel_opening_transaction_channel"] else None, + ) if obj["__typename"] == "Deposit": - # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel from lightspark.objects.Deposit import Deposit - return Deposit( - requester=requester, - typename="Deposit", - id=obj["deposit_id"], + requester=requester, typename="Deposit", id=obj["deposit_id"], 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=( - datetime.fromisoformat(obj["deposit_resolved_at"]) - if obj["deposit_resolved_at"] - else None - ), + + status=parse_enum(TransactionStatus, obj['deposit_status']), + 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"]) - if obj["deposit_fees"] - else None - ), + fees=CurrencyAmount_from_json(requester, obj["deposit_fees"]) if obj["deposit_fees"] else None, block_hash=obj["deposit_block_hash"], block_height=obj["deposit_block_height"], destination_addresses=obj["deposit_destination_addresses"], num_confirmations=obj["deposit_num_confirmations"], destination_id=obj["deposit_destination"]["id"], + ) if obj["__typename"] == "Withdrawal": - # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel from lightspark.objects.Withdrawal import Withdrawal - return Withdrawal( - requester=requester, - typename="Withdrawal", - id=obj["withdrawal_id"], + requester=requester, typename="Withdrawal", id=obj["withdrawal_id"], created_at=datetime.fromisoformat(obj["withdrawal_created_at"]), updated_at=datetime.fromisoformat(obj["withdrawal_updated_at"]), - status=parse_enum(TransactionStatus, obj["withdrawal_status"]), - resolved_at=( - datetime.fromisoformat(obj["withdrawal_resolved_at"]) - if obj["withdrawal_resolved_at"] - else None - ), + + status=parse_enum(TransactionStatus, obj['withdrawal_status']), + resolved_at=datetime.fromisoformat(obj["withdrawal_resolved_at"]) if obj["withdrawal_resolved_at"] else None, amount=CurrencyAmount_from_json(requester, obj["withdrawal_amount"]), transaction_hash=obj["withdrawal_transaction_hash"], - fees=( - CurrencyAmount_from_json(requester, obj["withdrawal_fees"]) - if obj["withdrawal_fees"] - else None - ), + fees=CurrencyAmount_from_json(requester, obj["withdrawal_fees"]) if obj["withdrawal_fees"] else None, block_hash=obj["withdrawal_block_hash"], block_height=obj["withdrawal_block_height"], destination_addresses=obj["withdrawal_destination_addresses"], num_confirmations=obj["withdrawal_num_confirmations"], origin_id=obj["withdrawal_origin"]["id"], + ) graphql_typename = obj["__typename"] - raise LightsparkException( - "UNKNOWN_INTERFACE", - f"Couldn't find a concrete type for interface OnChainTransaction corresponding to the typename={graphql_typename}", - ) + raise LightsparkException("UNKNOWN_INTERFACE", f"Couldn't find a concrete type for interface OnChainTransaction corresponding to the typename={graphql_typename}") diff --git a/lightspark/objects/OutgoingPayment.py b/lightspark/objects/OutgoingPayment.py index 6740a5c..03111cd 100644 --- a/lightspark/objects/OutgoingPayment.py +++ b/lightspark/objects/OutgoingPayment.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -11,10 +12,10 @@ from .CurrencyAmount import from_json as CurrencyAmount_from_json from .Entity import Entity from .LightningTransaction import LightningTransaction -from .OutgoingPaymentToAttemptsConnection import OutgoingPaymentToAttemptsConnection -from .OutgoingPaymentToAttemptsConnection import ( - from_json as OutgoingPaymentToAttemptsConnection_from_json, -) +from .OutgoingPaymentToAttemptsConnection import \ + OutgoingPaymentToAttemptsConnection +from .OutgoingPaymentToAttemptsConnection import \ + from_json as OutgoingPaymentToAttemptsConnection_from_json from .PaymentFailureReason import PaymentFailureReason from .PaymentRequestData import PaymentRequestData from .PaymentRequestData import from_json as PaymentRequestData_from_json @@ -87,9 +88,7 @@ class OutgoingPayment(LightningTransaction, Transaction, Entity): """The idempotency key of the payment.""" typename: str - def get_attempts( - self, first: Optional[int] = None, after: Optional[str] = None - ) -> OutgoingPaymentToAttemptsConnection: + def get_attempts(self, first: Optional[int]= None, after: Optional[str]= None) -> OutgoingPaymentToAttemptsConnection: json = self.requester.execute_graphql( """ query FetchOutgoingPaymentToAttemptsConnection($entity_id: ID!, $first: Int, $after: String) { @@ -143,11 +142,12 @@ def get_attempts( } } """, - {"entity_id": self.id, "first": first, "after": after}, + {"entity_id": self.id, "first": first, "after": after} ) connection = json["entity"]["attempts"] return OutgoingPaymentToAttemptsConnection_from_json(self.requester, connection) + def to_json(self) -> Mapping[str, Any]: return { "__typename": "OutgoingPayment", @@ -155,39 +155,26 @@ def to_json(self) -> Mapping[str, Any]: "outgoing_payment_created_at": self.created_at.isoformat(), "outgoing_payment_updated_at": self.updated_at.isoformat(), "outgoing_payment_status": self.status.value, - "outgoing_payment_resolved_at": ( - self.resolved_at.isoformat() if self.resolved_at else None - ), + "outgoing_payment_resolved_at": self.resolved_at.isoformat() if self.resolved_at else None, "outgoing_payment_amount": self.amount.to_json(), "outgoing_payment_transaction_hash": self.transaction_hash, "outgoing_payment_is_uma": self.is_uma, - "outgoing_payment_origin": {"id": self.origin_id}, - "outgoing_payment_destination": ( - {"id": self.destination_id} if self.destination_id else None - ), + "outgoing_payment_origin": { "id": self.origin_id }, + "outgoing_payment_destination": { "id": self.destination_id } if self.destination_id else None, "outgoing_payment_fees": self.fees.to_json() if self.fees else None, - "outgoing_payment_payment_request_data": ( - self.payment_request_data.to_json() - if self.payment_request_data - else None - ), - "outgoing_payment_failure_reason": ( - self.failure_reason.value if self.failure_reason else None - ), - "outgoing_payment_failure_message": ( - self.failure_message.to_json() if self.failure_message else None - ), - "outgoing_payment_uma_post_transaction_data": ( - [e.to_json() for e in self.uma_post_transaction_data] - if self.uma_post_transaction_data - else None - ), + "outgoing_payment_payment_request_data": self.payment_request_data.to_json() if self.payment_request_data else None, + "outgoing_payment_failure_reason": self.failure_reason.value if self.failure_reason else None, + "outgoing_payment_failure_message": self.failure_message.to_json() if self.failure_message else None, + "outgoing_payment_uma_post_transaction_data": [e.to_json() for e in self.uma_post_transaction_data] if self.uma_post_transaction_data else None, "outgoing_payment_payment_preimage": self.payment_preimage, "outgoing_payment_is_internal_payment": self.is_internal_payment, "outgoing_payment_idempotency_key": self.idempotency_key, + } + + FRAGMENT = """ fragment OutgoingPaymentFragment on OutgoingPayment { __typename @@ -538,60 +525,31 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> OutgoingPayment: return OutgoingPayment( - requester=requester, - typename="OutgoingPayment", - id=obj["outgoing_payment_id"], + requester=requester, typename="OutgoingPayment", id=obj["outgoing_payment_id"], 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=( - datetime.fromisoformat(obj["outgoing_payment_resolved_at"]) - if obj["outgoing_payment_resolved_at"] - else None - ), + + status=parse_enum(TransactionStatus, obj['outgoing_payment_status']), + 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"], is_uma=obj["outgoing_payment_is_uma"], origin_id=obj["outgoing_payment_origin"]["id"], - destination_id=( - obj["outgoing_payment_destination"]["id"] - if obj["outgoing_payment_destination"] - else None - ), - fees=( - CurrencyAmount_from_json(requester, obj["outgoing_payment_fees"]) - if obj["outgoing_payment_fees"] - else None - ), - payment_request_data=( - PaymentRequestData_from_json( - requester, obj["outgoing_payment_payment_request_data"] - ) - if obj["outgoing_payment_payment_request_data"] - else None - ), - failure_reason=parse_enum_optional( - PaymentFailureReason, obj["outgoing_payment_failure_reason"] - ), - failure_message=( - RichText_from_json(requester, obj["outgoing_payment_failure_message"]) - if obj["outgoing_payment_failure_message"] - else None - ), - uma_post_transaction_data=( - list( - map( - # pylint: disable=unnecessary-lambda - lambda e: PostTransactionData_from_json(requester, e), - obj["outgoing_payment_uma_post_transaction_data"], - ) - ) - if obj["outgoing_payment_uma_post_transaction_data"] - else None - ), + destination_id=obj["outgoing_payment_destination"]["id"] if obj["outgoing_payment_destination"] else None, + fees=CurrencyAmount_from_json(requester, obj["outgoing_payment_fees"]) if obj["outgoing_payment_fees"] else None, + payment_request_data=PaymentRequestData_from_json(requester, obj["outgoing_payment_payment_request_data"]) if obj["outgoing_payment_payment_request_data"] else None, + + failure_reason=parse_enum_optional(PaymentFailureReason, obj['outgoing_payment_failure_reason']), + failure_message=RichText_from_json(requester, obj["outgoing_payment_failure_message"]) if obj["outgoing_payment_failure_message"] else None, + uma_post_transaction_data=list(map( + # pylint: disable=unnecessary-lambda + lambda e: PostTransactionData_from_json(requester, e), obj["outgoing_payment_uma_post_transaction_data"])) if obj["outgoing_payment_uma_post_transaction_data"] else None, payment_preimage=obj["outgoing_payment_payment_preimage"], is_internal_payment=obj["outgoing_payment_is_internal_payment"], idempotency_key=obj["outgoing_payment_idempotency_key"], - ) + + ) + diff --git a/lightspark/objects/OutgoingPaymentAttempt.py b/lightspark/objects/OutgoingPaymentAttempt.py index 9306322..4e479ea 100644 --- a/lightspark/objects/OutgoingPaymentAttempt.py +++ b/lightspark/objects/OutgoingPaymentAttempt.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -12,12 +13,10 @@ from .Entity import Entity from .HtlcAttemptFailureCode import HtlcAttemptFailureCode from .OutgoingPaymentAttemptStatus import OutgoingPaymentAttemptStatus -from .OutgoingPaymentAttemptToHopsConnection import ( - OutgoingPaymentAttemptToHopsConnection, -) -from .OutgoingPaymentAttemptToHopsConnection import ( - from_json as OutgoingPaymentAttemptToHopsConnection_from_json, -) +from .OutgoingPaymentAttemptToHopsConnection import \ + OutgoingPaymentAttemptToHopsConnection +from .OutgoingPaymentAttemptToHopsConnection import \ + from_json as OutgoingPaymentAttemptToHopsConnection_from_json @dataclass @@ -63,9 +62,7 @@ class OutgoingPaymentAttempt(Entity): """The channel snapshot at the time the outgoing payment attempt was made.""" typename: str - def get_hops( - self, first: Optional[int] = None, after: Optional[str] = None - ) -> OutgoingPaymentAttemptToHopsConnection: + def get_hops(self, first: Optional[int]= None, after: Optional[str]= None) -> OutgoingPaymentAttemptToHopsConnection: json = self.requester.execute_graphql( """ query FetchOutgoingPaymentAttemptToHopsConnection($entity_id: ID!, $first: Int, $after: String) { @@ -114,12 +111,11 @@ def get_hops( } } """, - {"entity_id": self.id, "first": first, "after": after}, + {"entity_id": self.id, "first": first, "after": after} ) connection = json["entity"]["hops"] - return OutgoingPaymentAttemptToHopsConnection_from_json( - self.requester, connection - ) + return OutgoingPaymentAttemptToHopsConnection_from_json(self.requester, connection) + def to_json(self) -> Mapping[str, Any]: return { @@ -128,27 +124,20 @@ def to_json(self) -> Mapping[str, Any]: "outgoing_payment_attempt_created_at": self.created_at.isoformat(), "outgoing_payment_attempt_updated_at": self.updated_at.isoformat(), "outgoing_payment_attempt_status": self.status.value, - "outgoing_payment_attempt_failure_code": ( - self.failure_code.value if self.failure_code else None - ), + "outgoing_payment_attempt_failure_code": self.failure_code.value if self.failure_code else None, "outgoing_payment_attempt_failure_source_index": self.failure_source_index, "outgoing_payment_attempt_attempted_at": self.attempted_at.isoformat(), - "outgoing_payment_attempt_resolved_at": ( - self.resolved_at.isoformat() if self.resolved_at else None - ), - "outgoing_payment_attempt_amount": ( - self.amount.to_json() if self.amount else None - ), + "outgoing_payment_attempt_resolved_at": self.resolved_at.isoformat() if self.resolved_at else None, + "outgoing_payment_attempt_amount": self.amount.to_json() if self.amount else None, "outgoing_payment_attempt_fees": self.fees.to_json() if self.fees else None, - "outgoing_payment_attempt_outgoing_payment": { - "id": self.outgoing_payment_id - }, - "outgoing_payment_attempt_channel_snapshot": ( - {"id": self.channel_snapshot_id} if self.channel_snapshot_id else None - ), + "outgoing_payment_attempt_outgoing_payment": { "id": self.outgoing_payment_id }, + "outgoing_payment_attempt_channel_snapshot": { "id": self.channel_snapshot_id } if self.channel_snapshot_id else None, + } + + FRAGMENT = """ fragment OutgoingPaymentAttemptFragment on OutgoingPaymentAttempt { __typename @@ -186,42 +175,23 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> OutgoingPaymentAttempt: return OutgoingPaymentAttempt( - requester=requester, - typename="OutgoingPaymentAttempt", - id=obj["outgoing_payment_attempt_id"], + requester=requester, typename="OutgoingPaymentAttempt", id=obj["outgoing_payment_attempt_id"], created_at=datetime.fromisoformat(obj["outgoing_payment_attempt_created_at"]), updated_at=datetime.fromisoformat(obj["outgoing_payment_attempt_updated_at"]), - status=parse_enum( - OutgoingPaymentAttemptStatus, obj["outgoing_payment_attempt_status"] - ), - failure_code=parse_enum_optional( - HtlcAttemptFailureCode, obj["outgoing_payment_attempt_failure_code"] - ), + + status=parse_enum(OutgoingPaymentAttemptStatus, obj['outgoing_payment_attempt_status']), + + failure_code=parse_enum_optional(HtlcAttemptFailureCode, obj['outgoing_payment_attempt_failure_code']), failure_source_index=obj["outgoing_payment_attempt_failure_source_index"], - attempted_at=datetime.fromisoformat( - obj["outgoing_payment_attempt_attempted_at"] - ), - resolved_at=( - datetime.fromisoformat(obj["outgoing_payment_attempt_resolved_at"]) - if obj["outgoing_payment_attempt_resolved_at"] - else None - ), - amount=( - CurrencyAmount_from_json(requester, obj["outgoing_payment_attempt_amount"]) - if obj["outgoing_payment_attempt_amount"] - else None - ), - fees=( - CurrencyAmount_from_json(requester, obj["outgoing_payment_attempt_fees"]) - if obj["outgoing_payment_attempt_fees"] - else None - ), + attempted_at=datetime.fromisoformat(obj["outgoing_payment_attempt_attempted_at"]), + resolved_at=datetime.fromisoformat(obj["outgoing_payment_attempt_resolved_at"]) if obj["outgoing_payment_attempt_resolved_at"] else None, + amount=CurrencyAmount_from_json(requester, obj["outgoing_payment_attempt_amount"]) if obj["outgoing_payment_attempt_amount"] else None, + fees=CurrencyAmount_from_json(requester, obj["outgoing_payment_attempt_fees"]) if obj["outgoing_payment_attempt_fees"] else None, outgoing_payment_id=obj["outgoing_payment_attempt_outgoing_payment"]["id"], - channel_snapshot_id=( - obj["outgoing_payment_attempt_channel_snapshot"]["id"] - if obj["outgoing_payment_attempt_channel_snapshot"] - else None - ), - ) + channel_snapshot_id=obj["outgoing_payment_attempt_channel_snapshot"]["id"] if obj["outgoing_payment_attempt_channel_snapshot"] else None, + + ) + diff --git a/lightspark/objects/OutgoingPaymentAttemptStatus.py b/lightspark/objects/OutgoingPaymentAttemptStatus.py index 47decbe..d550f18 100644 --- a/lightspark/objects/OutgoingPaymentAttemptStatus.py +++ b/lightspark/objects/OutgoingPaymentAttemptStatus.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -11,3 +12,4 @@ class OutgoingPaymentAttemptStatus(Enum): IN_FLIGHT = "IN_FLIGHT" SUCCEEDED = "SUCCEEDED" FAILED = "FAILED" + diff --git a/lightspark/objects/OutgoingPaymentAttemptToHopsConnection.py b/lightspark/objects/OutgoingPaymentAttemptToHopsConnection.py index b7bb0cb..9843f22 100644 --- a/lightspark/objects/OutgoingPaymentAttemptToHopsConnection.py +++ b/lightspark/objects/OutgoingPaymentAttemptToHopsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -28,17 +29,19 @@ class OutgoingPaymentAttemptToHopsConnection(Connection): """The hops for the current page of this connection.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "OutgoingPaymentAttemptToHopsConnection", "outgoing_payment_attempt_to_hops_connection_count": self.count, "outgoing_payment_attempt_to_hops_connection_page_info": self.page_info.to_json(), - "outgoing_payment_attempt_to_hops_connection_entities": [ - e.to_json() for e in self.entities - ], + "outgoing_payment_attempt_to_hops_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment OutgoingPaymentAttemptToHopsConnectionFragment on OutgoingPaymentAttemptToHopsConnection { __typename @@ -57,21 +60,14 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> OutgoingPaymentAttemptToHopsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> OutgoingPaymentAttemptToHopsConnection: return OutgoingPaymentAttemptToHopsConnection( - requester=requester, - typename="OutgoingPaymentAttemptToHopsConnection", - count=obj["outgoing_payment_attempt_to_hops_connection_count"], - page_info=PageInfo_from_json( - requester, obj["outgoing_payment_attempt_to_hops_connection_page_info"] - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: Hop_from_json(requester, e), - obj["outgoing_payment_attempt_to_hops_connection_entities"], - ) - ), - ) + requester=requester, typename="OutgoingPaymentAttemptToHopsConnection", count=obj["outgoing_payment_attempt_to_hops_connection_count"], + page_info=PageInfo_from_json(requester, obj["outgoing_payment_attempt_to_hops_connection_page_info"]), + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: Hop_from_json(requester, e), obj["outgoing_payment_attempt_to_hops_connection_entities"])), + + ) + diff --git a/lightspark/objects/OutgoingPaymentForIdempotencyKeyInput.py b/lightspark/objects/OutgoingPaymentForIdempotencyKeyInput.py index d3255b5..1739cbe 100644 --- a/lightspark/objects/OutgoingPaymentForIdempotencyKeyInput.py +++ b/lightspark/objects/OutgoingPaymentForIdempotencyKeyInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,18 +6,28 @@ @dataclass -class OutgoingPaymentForIdempotencyKeyInput: +class OutgoingPaymentForIdempotencyKeyInput(): + + idempotency_key: str + + + def to_json(self) -> Mapping[str, Any]: return { "outgoing_payment_for_idempotency_key_input_idempotency_key": self.idempotency_key, + } + + + + def from_json(obj: Mapping[str, Any]) -> OutgoingPaymentForIdempotencyKeyInput: return OutgoingPaymentForIdempotencyKeyInput( - idempotency_key=obj[ - "outgoing_payment_for_idempotency_key_input_idempotency_key" - ], - ) + idempotency_key=obj["outgoing_payment_for_idempotency_key_input_idempotency_key"], + + ) + diff --git a/lightspark/objects/OutgoingPaymentForIdempotencyKeyOutput.py b/lightspark/objects/OutgoingPaymentForIdempotencyKeyOutput.py index d7cdf13..723dc6d 100644 --- a/lightspark/objects/OutgoingPaymentForIdempotencyKeyOutput.py +++ b/lightspark/objects/OutgoingPaymentForIdempotencyKeyOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,19 +8,24 @@ @dataclass -class OutgoingPaymentForIdempotencyKeyOutput: +class OutgoingPaymentForIdempotencyKeyOutput(): + requester: Requester payment_id: Optional[str] + + + def to_json(self) -> Mapping[str, Any]: return { - "outgoing_payment_for_idempotency_key_output_payment": ( - {"id": self.payment_id} if self.payment_id else None - ), + "outgoing_payment_for_idempotency_key_output_payment": { "id": self.payment_id } if self.payment_id else None, + } + + FRAGMENT = """ fragment OutgoingPaymentForIdempotencyKeyOutputFragment on OutgoingPaymentForIdempotencyKeyOutput { __typename @@ -30,14 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> OutgoingPaymentForIdempotencyKeyOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> OutgoingPaymentForIdempotencyKeyOutput: return OutgoingPaymentForIdempotencyKeyOutput( - requester=requester, - payment_id=( - obj["outgoing_payment_for_idempotency_key_output_payment"]["id"] - if obj["outgoing_payment_for_idempotency_key_output_payment"] - else None - ), - ) + requester=requester, payment_id=obj["outgoing_payment_for_idempotency_key_output_payment"]["id"] if obj["outgoing_payment_for_idempotency_key_output_payment"] else None, + + ) + diff --git a/lightspark/objects/OutgoingPaymentToAttemptsConnection.py b/lightspark/objects/OutgoingPaymentToAttemptsConnection.py index 36f8242..5915a2d 100644 --- a/lightspark/objects/OutgoingPaymentToAttemptsConnection.py +++ b/lightspark/objects/OutgoingPaymentToAttemptsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,7 +8,8 @@ from .Connection import Connection from .OutgoingPaymentAttempt import OutgoingPaymentAttempt -from .OutgoingPaymentAttempt import from_json as OutgoingPaymentAttempt_from_json +from .OutgoingPaymentAttempt import \ + from_json as OutgoingPaymentAttempt_from_json from .PageInfo import PageInfo from .PageInfo import from_json as PageInfo_from_json @@ -28,17 +30,19 @@ class OutgoingPaymentToAttemptsConnection(Connection): """The attempts for the current page of this connection.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "OutgoingPaymentToAttemptsConnection", "outgoing_payment_to_attempts_connection_count": self.count, "outgoing_payment_to_attempts_connection_page_info": self.page_info.to_json(), - "outgoing_payment_to_attempts_connection_entities": [ - e.to_json() for e in self.entities - ], + "outgoing_payment_to_attempts_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment OutgoingPaymentToAttemptsConnectionFragment on OutgoingPaymentToAttemptsConnection { __typename @@ -57,21 +61,14 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> OutgoingPaymentToAttemptsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> OutgoingPaymentToAttemptsConnection: return OutgoingPaymentToAttemptsConnection( - requester=requester, - typename="OutgoingPaymentToAttemptsConnection", - count=obj["outgoing_payment_to_attempts_connection_count"], - page_info=PageInfo_from_json( - requester, obj["outgoing_payment_to_attempts_connection_page_info"] - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: OutgoingPaymentAttempt_from_json(requester, e), - obj["outgoing_payment_to_attempts_connection_entities"], - ) - ), - ) + requester=requester, typename="OutgoingPaymentToAttemptsConnection", count=obj["outgoing_payment_to_attempts_connection_count"], + page_info=PageInfo_from_json(requester, obj["outgoing_payment_to_attempts_connection_page_info"]), + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: OutgoingPaymentAttempt_from_json(requester, e), obj["outgoing_payment_to_attempts_connection_entities"])), + + ) + diff --git a/lightspark/objects/OutgoingPaymentsForInvoiceQueryInput.py b/lightspark/objects/OutgoingPaymentsForInvoiceQueryInput.py index 5dce430..292829c 100644 --- a/lightspark/objects/OutgoingPaymentsForInvoiceQueryInput.py +++ b/lightspark/objects/OutgoingPaymentsForInvoiceQueryInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -9,28 +10,33 @@ @dataclass -class OutgoingPaymentsForInvoiceQueryInput: +class OutgoingPaymentsForInvoiceQueryInput(): + + encoded_invoice: str """The encoded invoice that the outgoing payments paid to.""" statuses: Optional[List[TransactionStatus]] """An optional filter to only query outgoing payments of given statuses.""" + + def to_json(self) -> Mapping[str, Any]: return { "outgoing_payments_for_invoice_query_input_encoded_invoice": self.encoded_invoice, - "outgoing_payments_for_invoice_query_input_statuses": ( - [e.value for e in self.statuses] if self.statuses else None - ), + "outgoing_payments_for_invoice_query_input_statuses": [e.value for e in self.statuses] if self.statuses else None, + } + + + + def from_json(obj: Mapping[str, Any]) -> OutgoingPaymentsForInvoiceQueryInput: return OutgoingPaymentsForInvoiceQueryInput( - encoded_invoice=obj[ - "outgoing_payments_for_invoice_query_input_encoded_invoice" - ], - statuses=parse_optional_list_of_enums( - TransactionStatus, obj["outgoing_payments_for_invoice_query_input_statuses"] - ), - ) + encoded_invoice=obj["outgoing_payments_for_invoice_query_input_encoded_invoice"], + statuses=parse_optional_list_of_enums(TransactionStatus, obj["outgoing_payments_for_invoice_query_input_statuses"]), + + ) + diff --git a/lightspark/objects/OutgoingPaymentsForInvoiceQueryOutput.py b/lightspark/objects/OutgoingPaymentsForInvoiceQueryOutput.py index 725b0f6..327600f 100644 --- a/lightspark/objects/OutgoingPaymentsForInvoiceQueryOutput.py +++ b/lightspark/objects/OutgoingPaymentsForInvoiceQueryOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,19 +11,24 @@ @dataclass -class OutgoingPaymentsForInvoiceQueryOutput: +class OutgoingPaymentsForInvoiceQueryOutput(): + requester: Requester payments: List[OutgoingPayment] + + + def to_json(self) -> Mapping[str, Any]: return { - "outgoing_payments_for_invoice_query_output_payments": [ - e.to_json() for e in self.payments - ], + "outgoing_payments_for_invoice_query_output_payments": [e.to_json() for e in self.payments], + } + + FRAGMENT = """ fragment OutgoingPaymentsForInvoiceQueryOutputFragment on OutgoingPaymentsForInvoiceQueryOutput { __typename @@ -376,16 +382,12 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> OutgoingPaymentsForInvoiceQueryOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> OutgoingPaymentsForInvoiceQueryOutput: return OutgoingPaymentsForInvoiceQueryOutput( - requester=requester, - payments=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: OutgoingPayment_from_json(requester, e), - obj["outgoing_payments_for_invoice_query_output_payments"], - ) - ), - ) + requester=requester, payments=list(map( + # pylint: disable=unnecessary-lambda + lambda e: OutgoingPayment_from_json(requester, e), obj["outgoing_payments_for_invoice_query_output_payments"])), + + ) + diff --git a/lightspark/objects/OutgoingPaymentsForPaymentHashQueryInput.py b/lightspark/objects/OutgoingPaymentsForPaymentHashQueryInput.py index d0c8b76..8ff4ba9 100644 --- a/lightspark/objects/OutgoingPaymentsForPaymentHashQueryInput.py +++ b/lightspark/objects/OutgoingPaymentsForPaymentHashQueryInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -9,27 +10,33 @@ @dataclass -class OutgoingPaymentsForPaymentHashQueryInput: +class OutgoingPaymentsForPaymentHashQueryInput(): + + payment_hash: str """The 32-byte hash of the payment preimage for which to fetch payments""" statuses: Optional[List[TransactionStatus]] """An optional filter to only query outgoing payments of given statuses.""" + + def to_json(self) -> Mapping[str, Any]: return { "outgoing_payments_for_payment_hash_query_input_payment_hash": self.payment_hash, - "outgoing_payments_for_payment_hash_query_input_statuses": ( - [e.value for e in self.statuses] if self.statuses else None - ), + "outgoing_payments_for_payment_hash_query_input_statuses": [e.value for e in self.statuses] if self.statuses else None, + } + + + + def from_json(obj: Mapping[str, Any]) -> OutgoingPaymentsForPaymentHashQueryInput: return OutgoingPaymentsForPaymentHashQueryInput( payment_hash=obj["outgoing_payments_for_payment_hash_query_input_payment_hash"], - statuses=parse_optional_list_of_enums( - TransactionStatus, - obj["outgoing_payments_for_payment_hash_query_input_statuses"], - ), - ) + statuses=parse_optional_list_of_enums(TransactionStatus, obj["outgoing_payments_for_payment_hash_query_input_statuses"]), + + ) + diff --git a/lightspark/objects/OutgoingPaymentsForPaymentHashQueryOutput.py b/lightspark/objects/OutgoingPaymentsForPaymentHashQueryOutput.py index 7f445ac..8d68082 100644 --- a/lightspark/objects/OutgoingPaymentsForPaymentHashQueryOutput.py +++ b/lightspark/objects/OutgoingPaymentsForPaymentHashQueryOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,19 +11,24 @@ @dataclass -class OutgoingPaymentsForPaymentHashQueryOutput: +class OutgoingPaymentsForPaymentHashQueryOutput(): + requester: Requester payments: List[OutgoingPayment] + + + def to_json(self) -> Mapping[str, Any]: return { - "outgoing_payments_for_payment_hash_query_output_payments": [ - e.to_json() for e in self.payments - ], + "outgoing_payments_for_payment_hash_query_output_payments": [e.to_json() for e in self.payments], + } + + FRAGMENT = """ fragment OutgoingPaymentsForPaymentHashQueryOutputFragment on OutgoingPaymentsForPaymentHashQueryOutput { __typename @@ -33,16 +39,12 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> OutgoingPaymentsForPaymentHashQueryOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> OutgoingPaymentsForPaymentHashQueryOutput: return OutgoingPaymentsForPaymentHashQueryOutput( - requester=requester, - payments=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: OutgoingPayment_from_json(requester, e), - obj["outgoing_payments_for_payment_hash_query_output_payments"], - ) - ), - ) + requester=requester, payments=list(map( + # pylint: disable=unnecessary-lambda + lambda e: OutgoingPayment_from_json(requester, e), obj["outgoing_payments_for_payment_hash_query_output_payments"])), + + ) + diff --git a/lightspark/objects/PageInfo.py b/lightspark/objects/PageInfo.py index 3b56c5b..5e291c4 100644 --- a/lightspark/objects/PageInfo.py +++ b/lightspark/objects/PageInfo.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,18 +8,24 @@ @dataclass -class PageInfo: +class PageInfo(): """This is an object representing information about a page returned by the Lightspark API. For more information, please see the “Pagination” section of our API docs for more information about its usage.""" requester: Requester has_next_page: Optional[bool] + has_previous_page: Optional[bool] + start_cursor: Optional[str] + end_cursor: Optional[str] + + + def to_json(self) -> Mapping[str, Any]: return { @@ -26,9 +33,12 @@ def to_json(self) -> Mapping[str, Any]: "page_info_has_previous_page": self.has_previous_page, "page_info_start_cursor": self.start_cursor, "page_info_end_cursor": self.end_cursor, + } + + FRAGMENT = """ fragment PageInfoFragment on PageInfo { __typename @@ -40,11 +50,13 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> PageInfo: return PageInfo( - requester=requester, - has_next_page=obj["page_info_has_next_page"], + requester=requester, has_next_page=obj["page_info_has_next_page"], has_previous_page=obj["page_info_has_previous_page"], start_cursor=obj["page_info_start_cursor"], end_cursor=obj["page_info_end_cursor"], - ) + + ) + diff --git a/lightspark/objects/PayInvoiceInput.py b/lightspark/objects/PayInvoiceInput.py index bd98534..5d1a8b5 100644 --- a/lightspark/objects/PayInvoiceInput.py +++ b/lightspark/objects/PayInvoiceInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,7 +6,9 @@ @dataclass -class PayInvoiceInput: +class PayInvoiceInput(): + + node_id: str """The node from where you want to send the payment.""" @@ -24,6 +27,8 @@ class PayInvoiceInput: idempotency_key: Optional[str] """The idempotency key of the request. The same result will be returned for the same idempotency key.""" + + def to_json(self) -> Mapping[str, Any]: return { "pay_invoice_input_node_id": self.node_id, @@ -32,9 +37,14 @@ def to_json(self) -> Mapping[str, Any]: "pay_invoice_input_maximum_fees_msats": self.maximum_fees_msats, "pay_invoice_input_amount_msats": self.amount_msats, "pay_invoice_input_idempotency_key": self.idempotency_key, + } + + + + def from_json(obj: Mapping[str, Any]) -> PayInvoiceInput: return PayInvoiceInput( node_id=obj["pay_invoice_input_node_id"], @@ -43,4 +53,6 @@ def from_json(obj: Mapping[str, Any]) -> PayInvoiceInput: maximum_fees_msats=obj["pay_invoice_input_maximum_fees_msats"], amount_msats=obj["pay_invoice_input_amount_msats"], idempotency_key=obj["pay_invoice_input_idempotency_key"], - ) + + ) + diff --git a/lightspark/objects/PayInvoiceOutput.py b/lightspark/objects/PayInvoiceOutput.py index 4b33fb7..85be328 100644 --- a/lightspark/objects/PayInvoiceOutput.py +++ b/lightspark/objects/PayInvoiceOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,18 +8,24 @@ @dataclass -class PayInvoiceOutput: +class PayInvoiceOutput(): + requester: Requester payment_id: str """The payment that has been sent.""" + + def to_json(self) -> Mapping[str, Any]: return { - "pay_invoice_output_payment": {"id": self.payment_id}, + "pay_invoice_output_payment": { "id": self.payment_id }, + } + + FRAGMENT = """ fragment PayInvoiceOutputFragment on PayInvoiceOutput { __typename @@ -29,8 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> PayInvoiceOutput: return PayInvoiceOutput( - requester=requester, - payment_id=obj["pay_invoice_output_payment"]["id"], - ) + requester=requester, payment_id=obj["pay_invoice_output_payment"]["id"], + + ) + diff --git a/lightspark/objects/PayOfferInput.py b/lightspark/objects/PayOfferInput.py new file mode 100644 index 0000000..5dc8756 --- /dev/null +++ b/lightspark/objects/PayOfferInput.py @@ -0,0 +1,58 @@ + +# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved + +from dataclasses import dataclass +from typing import Any, Mapping, Optional + + +@dataclass +class PayOfferInput(): + + + node_id: str + """The ID of the node that will be sending the payment.""" + + encoded_offer: str + """The Bech32 offer you want to pay (as defined by the BOLT12 standard).""" + + timeout_secs: int + """The timeout in seconds that we will try to make the payment.""" + + maximum_fees_msats: int + """The maximum amount of fees that you want to pay for this payment to be sent, expressed in msats.""" + + amount_msats: Optional[int] + """The amount you will pay for this offer, expressed in msats. It should ONLY be set when the offer amount is zero.""" + + idempotency_key: Optional[str] + """An idempotency key for this payment. If provided, it will be used to create a payment with the same idempotency key. If not provided, a new idempotency key will be generated.""" + + + + def to_json(self) -> Mapping[str, Any]: + return { + "pay_offer_input_node_id": self.node_id, + "pay_offer_input_encoded_offer": self.encoded_offer, + "pay_offer_input_timeout_secs": self.timeout_secs, + "pay_offer_input_maximum_fees_msats": self.maximum_fees_msats, + "pay_offer_input_amount_msats": self.amount_msats, + "pay_offer_input_idempotency_key": self.idempotency_key, + + } + + + + + + +def from_json(obj: Mapping[str, Any]) -> PayOfferInput: + return PayOfferInput( + node_id=obj["pay_offer_input_node_id"], + encoded_offer=obj["pay_offer_input_encoded_offer"], + timeout_secs=obj["pay_offer_input_timeout_secs"], + maximum_fees_msats=obj["pay_offer_input_maximum_fees_msats"], + amount_msats=obj["pay_offer_input_amount_msats"], + idempotency_key=obj["pay_offer_input_idempotency_key"], + + ) + diff --git a/lightspark/objects/PayOfferOutput.py b/lightspark/objects/PayOfferOutput.py new file mode 100644 index 0000000..9722552 --- /dev/null +++ b/lightspark/objects/PayOfferOutput.py @@ -0,0 +1,45 @@ + +# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved + +from dataclasses import dataclass +from typing import Any, Mapping + +from lightspark.requests.requester import Requester + + +@dataclass +class PayOfferOutput(): + + requester: Requester + + payment_id: str + """The payment that has been sent.""" + + + + def to_json(self) -> Mapping[str, Any]: + return { + "pay_offer_output_payment": { "id": self.payment_id }, + + } + + + + +FRAGMENT = """ +fragment PayOfferOutputFragment on PayOfferOutput { + __typename + pay_offer_output_payment: payment { + id + } +} +""" + + + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> PayOfferOutput: + return PayOfferOutput( + requester=requester, payment_id=obj["pay_offer_output_payment"]["id"], + + ) + diff --git a/lightspark/objects/PayTestModeInvoiceInput.py b/lightspark/objects/PayTestModeInvoiceInput.py new file mode 100644 index 0000000..f9e65ce --- /dev/null +++ b/lightspark/objects/PayTestModeInvoiceInput.py @@ -0,0 +1,68 @@ + +# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved + +from dataclasses import dataclass +from typing import Any, Mapping, Optional + +from lightspark.utils.enums import parse_enum_optional + +from .PaymentFailureReason import PaymentFailureReason + + +@dataclass +class PayTestModeInvoiceInput(): + + + node_id: str + """The node from where you want to send the payment.""" + + encoded_invoice: str + """The invoice you want to pay (as defined by the BOLT11 standard).""" + + timeout_secs: int + """The timeout in seconds that we will try to make the payment.""" + + maximum_fees_msats: int + """The maximum amount of fees that you want to pay for this payment to be sent, expressed in msats.""" + + failure_reason: Optional[PaymentFailureReason] + """The failure reason to trigger for the payment. If not set, pay_invoice will be called.""" + + amount_msats: Optional[int] + """The amount you will pay for this invoice, expressed in msats. It should ONLY be set when the invoice amount is zero.""" + + idempotency_key: Optional[str] + """The idempotency key of the request. The same result will be returned for the same idempotency key.""" + + + + def to_json(self) -> Mapping[str, Any]: + return { + "pay_test_mode_invoice_input_node_id": self.node_id, + "pay_test_mode_invoice_input_encoded_invoice": self.encoded_invoice, + "pay_test_mode_invoice_input_timeout_secs": self.timeout_secs, + "pay_test_mode_invoice_input_maximum_fees_msats": self.maximum_fees_msats, + "pay_test_mode_invoice_input_failure_reason": self.failure_reason.value if self.failure_reason else None, + "pay_test_mode_invoice_input_amount_msats": self.amount_msats, + "pay_test_mode_invoice_input_idempotency_key": self.idempotency_key, + + } + + + + + + +def from_json(obj: Mapping[str, Any]) -> PayTestModeInvoiceInput: + return PayTestModeInvoiceInput( + node_id=obj["pay_test_mode_invoice_input_node_id"], + encoded_invoice=obj["pay_test_mode_invoice_input_encoded_invoice"], + timeout_secs=obj["pay_test_mode_invoice_input_timeout_secs"], + maximum_fees_msats=obj["pay_test_mode_invoice_input_maximum_fees_msats"], + + failure_reason=parse_enum_optional(PaymentFailureReason, obj['pay_test_mode_invoice_input_failure_reason']), + amount_msats=obj["pay_test_mode_invoice_input_amount_msats"], + idempotency_key=obj["pay_test_mode_invoice_input_idempotency_key"], + + ) + diff --git a/lightspark/objects/PayUmaInvoiceInput.py b/lightspark/objects/PayUmaInvoiceInput.py index 06c1eb8..93a65a9 100644 --- a/lightspark/objects/PayUmaInvoiceInput.py +++ b/lightspark/objects/PayUmaInvoiceInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,22 +6,32 @@ @dataclass -class PayUmaInvoiceInput: +class PayUmaInvoiceInput(): + + node_id: str + encoded_invoice: str + timeout_secs: int + maximum_fees_msats: int + amount_msats: Optional[int] + idempotency_key: Optional[str] + sender_hash: Optional[str] """An optional, monthly-rotated, unique hashed identifier corresponding to the sender of the payment.""" + + def to_json(self) -> Mapping[str, Any]: return { "pay_uma_invoice_input_node_id": self.node_id, @@ -30,9 +41,14 @@ def to_json(self) -> Mapping[str, Any]: "pay_uma_invoice_input_amount_msats": self.amount_msats, "pay_uma_invoice_input_idempotency_key": self.idempotency_key, "pay_uma_invoice_input_sender_hash": self.sender_hash, + } + + + + def from_json(obj: Mapping[str, Any]) -> PayUmaInvoiceInput: return PayUmaInvoiceInput( node_id=obj["pay_uma_invoice_input_node_id"], @@ -42,4 +58,6 @@ def from_json(obj: Mapping[str, Any]) -> PayUmaInvoiceInput: amount_msats=obj["pay_uma_invoice_input_amount_msats"], idempotency_key=obj["pay_uma_invoice_input_idempotency_key"], sender_hash=obj["pay_uma_invoice_input_sender_hash"], - ) + + ) + diff --git a/lightspark/objects/PaymentDirection.py b/lightspark/objects/PaymentDirection.py index ae7f5e4..f905363 100644 --- a/lightspark/objects/PaymentDirection.py +++ b/lightspark/objects/PaymentDirection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -10,3 +11,4 @@ class PaymentDirection(Enum): """This is an enum value that represents future values that could be added in the future. Clients should support unknown values as more of them could be added without notice.""" SENT = "SENT" RECEIVED = "RECEIVED" + diff --git a/lightspark/objects/PaymentFailureReason.py b/lightspark/objects/PaymentFailureReason.py index 5e5be86..2832b83 100644 --- a/lightspark/objects/PaymentFailureReason.py +++ b/lightspark/objects/PaymentFailureReason.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -19,6 +20,5 @@ class PaymentFailureReason(Enum): INVOICE_EXPIRED = "INVOICE_EXPIRED" INVOICE_CANCELLED = "INVOICE_CANCELLED" RISK_SCREENING_FAILED = "RISK_SCREENING_FAILED" - INSUFFICIENT_BALANCE_ON_SINGLE_PATH_INVOICE = ( - "INSUFFICIENT_BALANCE_ON_SINGLE_PATH_INVOICE" - ) + INSUFFICIENT_BALANCE_ON_SINGLE_PATH_INVOICE = "INSUFFICIENT_BALANCE_ON_SINGLE_PATH_INVOICE" + diff --git a/lightspark/objects/PaymentRequest.py b/lightspark/objects/PaymentRequest.py index b2cb6fb..1695be4 100644 --- a/lightspark/objects/PaymentRequest.py +++ b/lightspark/objects/PaymentRequest.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -37,6 +38,7 @@ class PaymentRequest(Entity): """The status of the payment request.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": self.typename, @@ -45,9 +47,12 @@ def to_json(self) -> Mapping[str, Any]: "payment_request_updated_at": self.updated_at.isoformat(), "payment_request_data": self.data.to_json(), "payment_request_status": self.status.value, + } + + FRAGMENT = """ fragment PaymentRequestFragment on PaymentRequest { __typename @@ -363,29 +368,22 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> PaymentRequest: if obj["__typename"] == "Invoice": - # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel from lightspark.objects.Invoice import Invoice - return Invoice( - requester=requester, - typename="Invoice", - id=obj["invoice_id"], + requester=requester, typename="Invoice", id=obj["invoice_id"], 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"]) - if obj["invoice_amount_paid"] - else None - ), + + status=parse_enum(PaymentRequestStatus, obj['invoice_status']), + amount_paid=CurrencyAmount_from_json(requester, obj["invoice_amount_paid"]) if obj["invoice_amount_paid"] else None, is_uma=obj["invoice_is_uma"], is_lnurl=obj["invoice_is_lnurl"], + ) graphql_typename = obj["__typename"] - raise LightsparkException( - "UNKNOWN_INTERFACE", - f"Couldn't find a concrete type for interface PaymentRequest corresponding to the typename={graphql_typename}", - ) + raise LightsparkException("UNKNOWN_INTERFACE", f"Couldn't find a concrete type for interface PaymentRequest corresponding to the typename={graphql_typename}") diff --git a/lightspark/objects/PaymentRequestData.py b/lightspark/objects/PaymentRequestData.py index fa14211..e400d6d 100644 --- a/lightspark/objects/PaymentRequestData.py +++ b/lightspark/objects/PaymentRequestData.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -14,25 +15,30 @@ @dataclass -class PaymentRequestData: - """This object is an interface of a payment request on the Lightning Network (i.e., a Lightning Invoice). It contains data related to parsing the payment details of a Lightning Invoice.""" +class PaymentRequestData(): + """This object is an interface of a payment request on the Lightning Network (i.e., Invoice or Bolt12Invoice). It contains data related to parsing the payment details of a Lightning Invoice.""" requester: Requester encoded_payment_request: str + bitcoin_network: BitcoinNetwork - + typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": self.typename, "payment_request_data_encoded_payment_request": self.encoded_payment_request, "payment_request_data_bitcoin_network": self.bitcoin_network.value, + } + + FRAGMENT = """ fragment PaymentRequestDataFragment on PaymentRequestData { __typename @@ -331,27 +337,22 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> PaymentRequestData: if obj["__typename"] == "InvoiceData": - # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel from lightspark.objects.InvoiceData import InvoiceData - return InvoiceData( - requester=requester, - typename="InvoiceData", - encoded_payment_request=obj["invoice_data_encoded_payment_request"], - bitcoin_network=parse_enum( - BitcoinNetwork, obj["invoice_data_bitcoin_network"] - ), + requester=requester, typename="InvoiceData", encoded_payment_request=obj["invoice_data_encoded_payment_request"], + + 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=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"]), + ) graphql_typename = obj["__typename"] - raise LightsparkException( - "UNKNOWN_INTERFACE", - f"Couldn't find a concrete type for interface PaymentRequestData corresponding to the typename={graphql_typename}", - ) + raise LightsparkException("UNKNOWN_INTERFACE", f"Couldn't find a concrete type for interface PaymentRequestData corresponding to the typename={graphql_typename}") diff --git a/lightspark/objects/PaymentRequestStatus.py b/lightspark/objects/PaymentRequestStatus.py index ac01ad4..22834fd 100644 --- a/lightspark/objects/PaymentRequestStatus.py +++ b/lightspark/objects/PaymentRequestStatus.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -10,3 +11,4 @@ class PaymentRequestStatus(Enum): """This is an enum value that represents future values that could be added in the future. Clients should support unknown values as more of them could be added without notice.""" OPEN = "OPEN" CLOSED = "CLOSED" + diff --git a/lightspark/objects/Permission.py b/lightspark/objects/Permission.py index 087663b..1c4eaee 100644 --- a/lightspark/objects/Permission.py +++ b/lightspark/objects/Permission.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -22,3 +23,4 @@ class Permission(Enum): USER_MANAGE = "USER_MANAGE" ACCOUNT_VIEW = "ACCOUNT_VIEW" ACCOUNT_MANAGE = "ACCOUNT_MANAGE" + diff --git a/lightspark/objects/PostTransactionData.py b/lightspark/objects/PostTransactionData.py index f0a13bf..b5d2fc9 100644 --- a/lightspark/objects/PostTransactionData.py +++ b/lightspark/objects/PostTransactionData.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,7 +11,7 @@ @dataclass -class PostTransactionData: +class PostTransactionData(): """This object represents post-transaction data that could be used to register payment for KYT.""" requester: Requester @@ -21,13 +22,18 @@ class PostTransactionData: amount: CurrencyAmount """The amount of funds transferred in the payment.""" + + def to_json(self) -> Mapping[str, Any]: return { "post_transaction_data_utxo": self.utxo, "post_transaction_data_amount": self.amount.to_json(), + } + + FRAGMENT = """ fragment PostTransactionDataFragment on PostTransactionData { __typename @@ -44,9 +50,11 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> PostTransactionData: return PostTransactionData( - requester=requester, - utxo=obj["post_transaction_data_utxo"], + requester=requester, utxo=obj["post_transaction_data_utxo"], amount=CurrencyAmount_from_json(requester, obj["post_transaction_data_amount"]), - ) + + ) + diff --git a/lightspark/objects/RegionCode.py b/lightspark/objects/RegionCode.py index eb6d425..1e5c647 100644 --- a/lightspark/objects/RegionCode.py +++ b/lightspark/objects/RegionCode.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -508,3 +509,4 @@ class RegionCode(Enum): """The code representing the country of Zimbabwe.""" NN = "NN" """The code representing a fake region for testing.""" + diff --git a/lightspark/objects/RegisterPaymentInput.py b/lightspark/objects/RegisterPaymentInput.py index 62539f4..69d681c 100644 --- a/lightspark/objects/RegisterPaymentInput.py +++ b/lightspark/objects/RegisterPaymentInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,7 +11,9 @@ @dataclass -class RegisterPaymentInput: +class RegisterPaymentInput(): + + provider: ComplianceProvider """The compliance provider that is going to screen the node. You need to be a customer of the selected provider and store the API key on the Lightspark account setting page.""" @@ -23,19 +26,30 @@ class RegisterPaymentInput: direction: PaymentDirection """Indicates whether this payment is an OutgoingPayment or an IncomingPayment.""" + + def to_json(self) -> Mapping[str, Any]: return { "register_payment_input_provider": self.provider.value, "register_payment_input_payment_id": self.payment_id, "register_payment_input_node_pubkey": self.node_pubkey, "register_payment_input_direction": self.direction.value, + } + + + + def from_json(obj: Mapping[str, Any]) -> RegisterPaymentInput: return RegisterPaymentInput( - provider=parse_enum(ComplianceProvider, obj["register_payment_input_provider"]), + + provider=parse_enum(ComplianceProvider, obj['register_payment_input_provider']), payment_id=obj["register_payment_input_payment_id"], node_pubkey=obj["register_payment_input_node_pubkey"], - direction=parse_enum(PaymentDirection, obj["register_payment_input_direction"]), - ) + + direction=parse_enum(PaymentDirection, obj['register_payment_input_direction']), + + ) + diff --git a/lightspark/objects/RegisterPaymentOutput.py b/lightspark/objects/RegisterPaymentOutput.py index c2da6fc..d4e324b 100644 --- a/lightspark/objects/RegisterPaymentOutput.py +++ b/lightspark/objects/RegisterPaymentOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,17 +8,24 @@ @dataclass -class RegisterPaymentOutput: +class RegisterPaymentOutput(): + requester: Requester payment_id: str + + + def to_json(self) -> Mapping[str, Any]: return { - "register_payment_output_payment": {"id": self.payment_id}, + "register_payment_output_payment": { "id": self.payment_id }, + } + + FRAGMENT = """ fragment RegisterPaymentOutputFragment on RegisterPaymentOutput { __typename @@ -28,8 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> RegisterPaymentOutput: return RegisterPaymentOutput( - requester=requester, - payment_id=obj["register_payment_output_payment"]["id"], - ) + requester=requester, payment_id=obj["register_payment_output_payment"]["id"], + + ) + diff --git a/lightspark/objects/ReleaseChannelPerCommitmentSecretInput.py b/lightspark/objects/ReleaseChannelPerCommitmentSecretInput.py index 15e9c1f..3b2a81d 100644 --- a/lightspark/objects/ReleaseChannelPerCommitmentSecretInput.py +++ b/lightspark/objects/ReleaseChannelPerCommitmentSecretInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,7 +6,9 @@ @dataclass -class ReleaseChannelPerCommitmentSecretInput: +class ReleaseChannelPerCommitmentSecretInput(): + + channel_id: str """The unique identifier of the channel.""" @@ -15,21 +18,26 @@ class ReleaseChannelPerCommitmentSecretInput: per_commitment_index: int """The index associated with the per-commitment secret.""" + + def to_json(self) -> Mapping[str, Any]: return { "release_channel_per_commitment_secret_input_channel_id": self.channel_id, "release_channel_per_commitment_secret_input_per_commitment_secret": self.per_commitment_secret, "release_channel_per_commitment_secret_input_per_commitment_index": self.per_commitment_index, + } + + + + def from_json(obj: Mapping[str, Any]) -> ReleaseChannelPerCommitmentSecretInput: return ReleaseChannelPerCommitmentSecretInput( channel_id=obj["release_channel_per_commitment_secret_input_channel_id"], - per_commitment_secret=obj[ - "release_channel_per_commitment_secret_input_per_commitment_secret" - ], - per_commitment_index=obj[ - "release_channel_per_commitment_secret_input_per_commitment_index" - ], - ) + per_commitment_secret=obj["release_channel_per_commitment_secret_input_per_commitment_secret"], + per_commitment_index=obj["release_channel_per_commitment_secret_input_per_commitment_index"], + + ) + diff --git a/lightspark/objects/ReleaseChannelPerCommitmentSecretOutput.py b/lightspark/objects/ReleaseChannelPerCommitmentSecretOutput.py index 75bb1bb..090c5f3 100644 --- a/lightspark/objects/ReleaseChannelPerCommitmentSecretOutput.py +++ b/lightspark/objects/ReleaseChannelPerCommitmentSecretOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,20 +8,24 @@ @dataclass -class ReleaseChannelPerCommitmentSecretOutput: +class ReleaseChannelPerCommitmentSecretOutput(): + requester: Requester channel_id: str """The channel object after the per-commitment secret release operation.""" + + def to_json(self) -> Mapping[str, Any]: return { - "release_channel_per_commitment_secret_output_channel": { - "id": self.channel_id - }, + "release_channel_per_commitment_secret_output_channel": { "id": self.channel_id }, + } + + FRAGMENT = """ fragment ReleaseChannelPerCommitmentSecretOutputFragment on ReleaseChannelPerCommitmentSecretOutput { __typename @@ -31,10 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> ReleaseChannelPerCommitmentSecretOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> ReleaseChannelPerCommitmentSecretOutput: return ReleaseChannelPerCommitmentSecretOutput( - requester=requester, - channel_id=obj["release_channel_per_commitment_secret_output_channel"]["id"], - ) + requester=requester, channel_id=obj["release_channel_per_commitment_secret_output_channel"]["id"], + + ) + diff --git a/lightspark/objects/ReleasePaymentPreimageInput.py b/lightspark/objects/ReleasePaymentPreimageInput.py index 9967f4c..10b3d3a 100644 --- a/lightspark/objects/ReleasePaymentPreimageInput.py +++ b/lightspark/objects/ReleasePaymentPreimageInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,22 +6,33 @@ @dataclass -class ReleasePaymentPreimageInput: +class ReleasePaymentPreimageInput(): + + invoice_id: str """The invoice the preimage belongs to.""" payment_preimage: str """The preimage to release.""" + + def to_json(self) -> Mapping[str, Any]: return { "release_payment_preimage_input_invoice_id": self.invoice_id, "release_payment_preimage_input_payment_preimage": self.payment_preimage, + } + + + + def from_json(obj: Mapping[str, Any]) -> ReleasePaymentPreimageInput: return ReleasePaymentPreimageInput( invoice_id=obj["release_payment_preimage_input_invoice_id"], payment_preimage=obj["release_payment_preimage_input_payment_preimage"], - ) + + ) + diff --git a/lightspark/objects/ReleasePaymentPreimageOutput.py b/lightspark/objects/ReleasePaymentPreimageOutput.py index 88811e5..a1b836c 100644 --- a/lightspark/objects/ReleasePaymentPreimageOutput.py +++ b/lightspark/objects/ReleasePaymentPreimageOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,18 +8,24 @@ @dataclass -class ReleasePaymentPreimageOutput: +class ReleasePaymentPreimageOutput(): + requester: Requester invoice_id: str """The invoice of the transaction.""" + + def to_json(self) -> Mapping[str, Any]: return { - "release_payment_preimage_output_invoice": {"id": self.invoice_id}, + "release_payment_preimage_output_invoice": { "id": self.invoice_id }, + } + + FRAGMENT = """ fragment ReleasePaymentPreimageOutputFragment on ReleasePaymentPreimageOutput { __typename @@ -29,10 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> ReleasePaymentPreimageOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> ReleasePaymentPreimageOutput: return ReleasePaymentPreimageOutput( - requester=requester, - invoice_id=obj["release_payment_preimage_output_invoice"]["id"], - ) + requester=requester, invoice_id=obj["release_payment_preimage_output_invoice"]["id"], + + ) + diff --git a/lightspark/objects/RemoteSigningSubEventType.py b/lightspark/objects/RemoteSigningSubEventType.py index e6e553a..9c9ccc6 100644 --- a/lightspark/objects/RemoteSigningSubEventType.py +++ b/lightspark/objects/RemoteSigningSubEventType.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -15,7 +16,6 @@ class RemoteSigningSubEventType(Enum): DERIVE_KEY_AND_SIGN = "DERIVE_KEY_AND_SIGN" RELEASE_PAYMENT_PREIMAGE = "RELEASE_PAYMENT_PREIMAGE" REQUEST_INVOICE_PAYMENT_HASH = "REQUEST_INVOICE_PAYMENT_HASH" - REVEAL_COUNTERPARTY_PER_COMMITMENT_SECRET = ( - "REVEAL_COUNTERPARTY_PER_COMMITMENT_SECRET" - ) + REVEAL_COUNTERPARTY_PER_COMMITMENT_SECRET = "REVEAL_COUNTERPARTY_PER_COMMITMENT_SECRET" VLS_MESSAGE = "VLS_MESSAGE" + diff --git a/lightspark/objects/RequestInitiator.py b/lightspark/objects/RequestInitiator.py index 5ded1d7..8688a0a 100644 --- a/lightspark/objects/RequestInitiator.py +++ b/lightspark/objects/RequestInitiator.py @@ -1,10 +1,13 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum class RequestInitiator(Enum): + ___FUTURE_VALUE___ = "___FUTURE_VALUE___" """This is an enum value that represents future values that could be added in the future. Clients should support unknown values as more of them could be added without notice.""" CUSTOMER = "CUSTOMER" LIGHTSPARK = "LIGHTSPARK" + diff --git a/lightspark/objects/RequestWithdrawalInput.py b/lightspark/objects/RequestWithdrawalInput.py index 0f0e514..a200397 100644 --- a/lightspark/objects/RequestWithdrawalInput.py +++ b/lightspark/objects/RequestWithdrawalInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,7 +11,9 @@ @dataclass -class RequestWithdrawalInput: +class RequestWithdrawalInput(): + + node_id: str """The node from which you'd like to make the withdrawal.""" @@ -32,6 +35,8 @@ class RequestWithdrawalInput: sats_per_vbyte: Optional[int] """A manual fee rate set in sat/vbyte that should be used when crafting the L1 transaction. You should only set `fee_target` or `sats_per_vbyte`""" + + def to_json(self) -> Mapping[str, Any]: return { "request_withdrawal_input_node_id": self.node_id, @@ -39,24 +44,27 @@ def to_json(self) -> Mapping[str, Any]: "request_withdrawal_input_amount_sats": self.amount_sats, "request_withdrawal_input_withdrawal_mode": self.withdrawal_mode.value, "request_withdrawal_input_idempotency_key": self.idempotency_key, - "request_withdrawal_input_fee_target": ( - self.fee_target.value if self.fee_target else None - ), + "request_withdrawal_input_fee_target": self.fee_target.value if self.fee_target else None, "request_withdrawal_input_sats_per_vbyte": self.sats_per_vbyte, + } + + + + def from_json(obj: Mapping[str, Any]) -> RequestWithdrawalInput: return RequestWithdrawalInput( node_id=obj["request_withdrawal_input_node_id"], bitcoin_address=obj["request_withdrawal_input_bitcoin_address"], amount_sats=obj["request_withdrawal_input_amount_sats"], - withdrawal_mode=parse_enum( - WithdrawalMode, obj["request_withdrawal_input_withdrawal_mode"] - ), + + withdrawal_mode=parse_enum(WithdrawalMode, obj['request_withdrawal_input_withdrawal_mode']), idempotency_key=obj["request_withdrawal_input_idempotency_key"], - fee_target=parse_enum_optional( - OnChainFeeTarget, obj["request_withdrawal_input_fee_target"] - ), + + fee_target=parse_enum_optional(OnChainFeeTarget, obj['request_withdrawal_input_fee_target']), sats_per_vbyte=obj["request_withdrawal_input_sats_per_vbyte"], - ) + + ) + diff --git a/lightspark/objects/RequestWithdrawalOutput.py b/lightspark/objects/RequestWithdrawalOutput.py index 9ad37d4..a557538 100644 --- a/lightspark/objects/RequestWithdrawalOutput.py +++ b/lightspark/objects/RequestWithdrawalOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,18 +8,24 @@ @dataclass -class RequestWithdrawalOutput: +class RequestWithdrawalOutput(): + requester: Requester request_id: str """The request that is created for this withdrawal.""" + + def to_json(self) -> Mapping[str, Any]: return { - "request_withdrawal_output_request": {"id": self.request_id}, + "request_withdrawal_output_request": { "id": self.request_id }, + } + + FRAGMENT = """ fragment RequestWithdrawalOutputFragment on RequestWithdrawalOutput { __typename @@ -29,8 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> RequestWithdrawalOutput: return RequestWithdrawalOutput( - requester=requester, - request_id=obj["request_withdrawal_output_request"]["id"], - ) + requester=requester, request_id=obj["request_withdrawal_output_request"]["id"], + + ) + diff --git a/lightspark/objects/RichText.py b/lightspark/objects/RichText.py index 8cf3473..804728c 100644 --- a/lightspark/objects/RichText.py +++ b/lightspark/objects/RichText.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,17 +8,24 @@ @dataclass -class RichText: +class RichText(): + requester: Requester text: str + + + def to_json(self) -> Mapping[str, Any]: return { "rich_text_text": self.text, + } + + FRAGMENT = """ fragment RichTextFragment on RichText { __typename @@ -26,8 +34,10 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> RichText: return RichText( - requester=requester, - text=obj["rich_text_text"], - ) + requester=requester, text=obj["rich_text_text"], + + ) + diff --git a/lightspark/objects/RiskRating.py b/lightspark/objects/RiskRating.py index e4d0376..193bb0d 100644 --- a/lightspark/objects/RiskRating.py +++ b/lightspark/objects/RiskRating.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -11,3 +12,4 @@ class RiskRating(Enum): HIGH_RISK = "HIGH_RISK" LOW_RISK = "LOW_RISK" UNKNOWN = "UNKNOWN" + diff --git a/lightspark/objects/RoutingTransaction.py b/lightspark/objects/RoutingTransaction.py index bf0e7a3..42a818a 100644 --- a/lightspark/objects/RoutingTransaction.py +++ b/lightspark/objects/RoutingTransaction.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -61,6 +62,7 @@ class RoutingTransaction(LightningTransaction, Transaction, Entity): """If applicable, the reason why the routing failed.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "RoutingTransaction", @@ -68,27 +70,20 @@ def to_json(self) -> Mapping[str, Any]: "routing_transaction_created_at": self.created_at.isoformat(), "routing_transaction_updated_at": self.updated_at.isoformat(), "routing_transaction_status": self.status.value, - "routing_transaction_resolved_at": ( - self.resolved_at.isoformat() if self.resolved_at else None - ), + "routing_transaction_resolved_at": self.resolved_at.isoformat() if self.resolved_at else None, "routing_transaction_amount": self.amount.to_json(), "routing_transaction_transaction_hash": self.transaction_hash, - "routing_transaction_incoming_channel": ( - {"id": self.incoming_channel_id} if self.incoming_channel_id else None - ), - "routing_transaction_outgoing_channel": ( - {"id": self.outgoing_channel_id} if self.outgoing_channel_id else None - ), + "routing_transaction_incoming_channel": { "id": self.incoming_channel_id } if self.incoming_channel_id else None, + "routing_transaction_outgoing_channel": { "id": self.outgoing_channel_id } if self.outgoing_channel_id else None, "routing_transaction_fees": self.fees.to_json() if self.fees else None, - "routing_transaction_failure_message": ( - self.failure_message.to_json() if self.failure_message else None - ), - "routing_transaction_failure_reason": ( - self.failure_reason.value if self.failure_reason else None - ), + "routing_transaction_failure_message": self.failure_message.to_json() if self.failure_message else None, + "routing_transaction_failure_reason": self.failure_reason.value if self.failure_reason else None, + } + + FRAGMENT = """ fragment RoutingTransactionFragment on RoutingTransaction { __typename @@ -129,42 +124,23 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> RoutingTransaction: return RoutingTransaction( - requester=requester, - typename="RoutingTransaction", - id=obj["routing_transaction_id"], + requester=requester, typename="RoutingTransaction", id=obj["routing_transaction_id"], 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=( - datetime.fromisoformat(obj["routing_transaction_resolved_at"]) - if obj["routing_transaction_resolved_at"] - else None - ), + + status=parse_enum(TransactionStatus, obj['routing_transaction_status']), + 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"]), transaction_hash=obj["routing_transaction_transaction_hash"], - incoming_channel_id=( - obj["routing_transaction_incoming_channel"]["id"] - if obj["routing_transaction_incoming_channel"] - else None - ), - outgoing_channel_id=( - obj["routing_transaction_outgoing_channel"]["id"] - if obj["routing_transaction_outgoing_channel"] - else None - ), - fees=( - CurrencyAmount_from_json(requester, obj["routing_transaction_fees"]) - if obj["routing_transaction_fees"] - else None - ), - failure_message=( - RichText_from_json(requester, obj["routing_transaction_failure_message"]) - if obj["routing_transaction_failure_message"] - else None - ), - failure_reason=parse_enum_optional( - RoutingTransactionFailureReason, obj["routing_transaction_failure_reason"] - ), - ) + incoming_channel_id=obj["routing_transaction_incoming_channel"]["id"] if obj["routing_transaction_incoming_channel"] else None, + outgoing_channel_id=obj["routing_transaction_outgoing_channel"]["id"] if obj["routing_transaction_outgoing_channel"] else None, + fees=CurrencyAmount_from_json(requester, obj["routing_transaction_fees"]) if obj["routing_transaction_fees"] else None, + failure_message=RichText_from_json(requester, obj["routing_transaction_failure_message"]) if obj["routing_transaction_failure_message"] else None, + + failure_reason=parse_enum_optional(RoutingTransactionFailureReason, obj['routing_transaction_failure_reason']), + + ) + diff --git a/lightspark/objects/RoutingTransactionFailureReason.py b/lightspark/objects/RoutingTransactionFailureReason.py index b3affe0..1a9d93d 100644 --- a/lightspark/objects/RoutingTransactionFailureReason.py +++ b/lightspark/objects/RoutingTransactionFailureReason.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -11,3 +12,4 @@ class RoutingTransactionFailureReason(Enum): INCOMING_LINK_FAILURE = "INCOMING_LINK_FAILURE" OUTGOING_LINK_FAILURE = "OUTGOING_LINK_FAILURE" FORWARDING_FAILURE = "FORWARDING_FAILURE" + diff --git a/lightspark/objects/ScreenNodeInput.py b/lightspark/objects/ScreenNodeInput.py index d38e234..2b67b17 100644 --- a/lightspark/objects/ScreenNodeInput.py +++ b/lightspark/objects/ScreenNodeInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -9,22 +10,34 @@ @dataclass -class ScreenNodeInput: +class ScreenNodeInput(): + + provider: ComplianceProvider """The compliance provider that is going to screen the node. You need to be a customer of the selected provider and store the API key on the Lightspark account setting page.""" node_pubkey: str """The public key of the lightning node that needs to be screened.""" + + def to_json(self) -> Mapping[str, Any]: return { "screen_node_input_provider": self.provider.value, "screen_node_input_node_pubkey": self.node_pubkey, + } + + + + def from_json(obj: Mapping[str, Any]) -> ScreenNodeInput: return ScreenNodeInput( - provider=parse_enum(ComplianceProvider, obj["screen_node_input_provider"]), + + provider=parse_enum(ComplianceProvider, obj['screen_node_input_provider']), node_pubkey=obj["screen_node_input_node_pubkey"], - ) + + ) + diff --git a/lightspark/objects/ScreenNodeOutput.py b/lightspark/objects/ScreenNodeOutput.py index fb0863a..b629924 100644 --- a/lightspark/objects/ScreenNodeOutput.py +++ b/lightspark/objects/ScreenNodeOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,17 +11,24 @@ @dataclass -class ScreenNodeOutput: +class ScreenNodeOutput(): + requester: Requester rating: RiskRating + + + def to_json(self) -> Mapping[str, Any]: return { "screen_node_output_rating": self.rating.value, + } + + FRAGMENT = """ fragment ScreenNodeOutputFragment on ScreenNodeOutput { __typename @@ -29,8 +37,11 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> ScreenNodeOutput: return ScreenNodeOutput( requester=requester, - rating=parse_enum(RiskRating, obj["screen_node_output_rating"]), - ) + rating=parse_enum(RiskRating, obj['screen_node_output_rating']), + + ) + diff --git a/lightspark/objects/Secret.py b/lightspark/objects/Secret.py index 9384dca..dc71694 100644 --- a/lightspark/objects/Secret.py +++ b/lightspark/objects/Secret.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,20 +8,28 @@ @dataclass -class Secret: +class Secret(): + requester: Requester encrypted_value: str + cipher: str + + + def to_json(self) -> Mapping[str, Any]: return { "secret_encrypted_value": self.encrypted_value, "secret_cipher": self.cipher, + } + + FRAGMENT = """ fragment SecretFragment on Secret { __typename @@ -30,9 +39,11 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> Secret: return Secret( - requester=requester, - encrypted_value=obj["secret_encrypted_value"], + requester=requester, encrypted_value=obj["secret_encrypted_value"], cipher=obj["secret_cipher"], - ) + + ) + diff --git a/lightspark/objects/SendPaymentInput.py b/lightspark/objects/SendPaymentInput.py index b996b1f..1e47a82 100644 --- a/lightspark/objects/SendPaymentInput.py +++ b/lightspark/objects/SendPaymentInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,7 +6,9 @@ @dataclass -class SendPaymentInput: +class SendPaymentInput(): + + node_id: str """The node from where you want to send the payment.""" @@ -24,6 +27,8 @@ class SendPaymentInput: idempotency_key: Optional[str] """The idempotency key of the request. The same result will be returned for the same idempotency key.""" + + def to_json(self) -> Mapping[str, Any]: return { "send_payment_input_node_id": self.node_id, @@ -32,9 +37,14 @@ def to_json(self) -> Mapping[str, Any]: "send_payment_input_amount_msats": self.amount_msats, "send_payment_input_maximum_fees_msats": self.maximum_fees_msats, "send_payment_input_idempotency_key": self.idempotency_key, + } + + + + def from_json(obj: Mapping[str, Any]) -> SendPaymentInput: return SendPaymentInput( node_id=obj["send_payment_input_node_id"], @@ -43,4 +53,6 @@ def from_json(obj: Mapping[str, Any]) -> SendPaymentInput: amount_msats=obj["send_payment_input_amount_msats"], maximum_fees_msats=obj["send_payment_input_maximum_fees_msats"], idempotency_key=obj["send_payment_input_idempotency_key"], - ) + + ) + diff --git a/lightspark/objects/SendPaymentOutput.py b/lightspark/objects/SendPaymentOutput.py index ee52b72..4465b39 100644 --- a/lightspark/objects/SendPaymentOutput.py +++ b/lightspark/objects/SendPaymentOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,18 +8,24 @@ @dataclass -class SendPaymentOutput: +class SendPaymentOutput(): + requester: Requester payment_id: str """The payment that has been sent.""" + + def to_json(self) -> Mapping[str, Any]: return { - "send_payment_output_payment": {"id": self.payment_id}, + "send_payment_output_payment": { "id": self.payment_id }, + } + + FRAGMENT = """ fragment SendPaymentOutputFragment on SendPaymentOutput { __typename @@ -29,8 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> SendPaymentOutput: return SendPaymentOutput( - requester=requester, - payment_id=obj["send_payment_output_payment"]["id"], - ) + requester=requester, payment_id=obj["send_payment_output_payment"]["id"], + + ) + diff --git a/lightspark/objects/SetInvoicePaymentHashInput.py b/lightspark/objects/SetInvoicePaymentHashInput.py index 9e130ac..5590b35 100644 --- a/lightspark/objects/SetInvoicePaymentHashInput.py +++ b/lightspark/objects/SetInvoicePaymentHashInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,7 +6,9 @@ @dataclass -class SetInvoicePaymentHashInput: +class SetInvoicePaymentHashInput(): + + invoice_id: str """The invoice that needs to be updated.""" @@ -15,17 +18,26 @@ class SetInvoicePaymentHashInput: preimage_nonce: Optional[str] """The 32-byte nonce used to generate the invoice preimage if applicable. It will later be included in RELEASE_PAYMENT_PREIMAGE webhook to help recover the raw preimage.""" + + def to_json(self) -> Mapping[str, Any]: return { "set_invoice_payment_hash_input_invoice_id": self.invoice_id, "set_invoice_payment_hash_input_payment_hash": self.payment_hash, "set_invoice_payment_hash_input_preimage_nonce": self.preimage_nonce, + } + + + + def from_json(obj: Mapping[str, Any]) -> SetInvoicePaymentHashInput: return SetInvoicePaymentHashInput( invoice_id=obj["set_invoice_payment_hash_input_invoice_id"], payment_hash=obj["set_invoice_payment_hash_input_payment_hash"], preimage_nonce=obj["set_invoice_payment_hash_input_preimage_nonce"], - ) + + ) + diff --git a/lightspark/objects/SetInvoicePaymentHashOutput.py b/lightspark/objects/SetInvoicePaymentHashOutput.py index f2b8768..1d81550 100644 --- a/lightspark/objects/SetInvoicePaymentHashOutput.py +++ b/lightspark/objects/SetInvoicePaymentHashOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,17 +8,24 @@ @dataclass -class SetInvoicePaymentHashOutput: +class SetInvoicePaymentHashOutput(): + requester: Requester invoice_id: str + + + def to_json(self) -> Mapping[str, Any]: return { - "set_invoice_payment_hash_output_invoice": {"id": self.invoice_id}, + "set_invoice_payment_hash_output_invoice": { "id": self.invoice_id }, + } + + FRAGMENT = """ fragment SetInvoicePaymentHashOutputFragment on SetInvoicePaymentHashOutput { __typename @@ -28,10 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> SetInvoicePaymentHashOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> SetInvoicePaymentHashOutput: return SetInvoicePaymentHashOutput( - requester=requester, - invoice_id=obj["set_invoice_payment_hash_output_invoice"]["id"], - ) + requester=requester, invoice_id=obj["set_invoice_payment_hash_output_invoice"]["id"], + + ) + diff --git a/lightspark/objects/SignInvoiceInput.py b/lightspark/objects/SignInvoiceInput.py index f946a21..3b4ff3f 100644 --- a/lightspark/objects/SignInvoiceInput.py +++ b/lightspark/objects/SignInvoiceInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,7 +6,9 @@ @dataclass -class SignInvoiceInput: +class SignInvoiceInput(): + + invoice_id: str """The unique identifier of the invoice to be signed.""" @@ -15,17 +18,26 @@ class SignInvoiceInput: recovery_id: int """The recovery identifier for the signature.""" + + def to_json(self) -> Mapping[str, Any]: return { "sign_invoice_input_invoice_id": self.invoice_id, "sign_invoice_input_signature": self.signature, "sign_invoice_input_recovery_id": self.recovery_id, + } + + + + def from_json(obj: Mapping[str, Any]) -> SignInvoiceInput: return SignInvoiceInput( invoice_id=obj["sign_invoice_input_invoice_id"], signature=obj["sign_invoice_input_signature"], recovery_id=obj["sign_invoice_input_recovery_id"], - ) + + ) + diff --git a/lightspark/objects/SignInvoiceOutput.py b/lightspark/objects/SignInvoiceOutput.py index df2b868..b6aef8d 100644 --- a/lightspark/objects/SignInvoiceOutput.py +++ b/lightspark/objects/SignInvoiceOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,18 +8,24 @@ @dataclass -class SignInvoiceOutput: +class SignInvoiceOutput(): + requester: Requester invoice_id: str """ The signed invoice object.""" + + def to_json(self) -> Mapping[str, Any]: return { - "sign_invoice_output_invoice": {"id": self.invoice_id}, + "sign_invoice_output_invoice": { "id": self.invoice_id }, + } + + FRAGMENT = """ fragment SignInvoiceOutputFragment on SignInvoiceOutput { __typename @@ -29,8 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> SignInvoiceOutput: return SignInvoiceOutput( - requester=requester, - invoice_id=obj["sign_invoice_output_invoice"]["id"], - ) + requester=requester, invoice_id=obj["sign_invoice_output_invoice"]["id"], + + ) + diff --git a/lightspark/objects/SignMessagesInput.py b/lightspark/objects/SignMessagesInput.py index bf79191..993606a 100644 --- a/lightspark/objects/SignMessagesInput.py +++ b/lightspark/objects/SignMessagesInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -8,23 +9,30 @@ @dataclass -class SignMessagesInput: +class SignMessagesInput(): + + signatures: List[IdAndSignature] """The list of the message ids and signatures.""" + + def to_json(self) -> Mapping[str, Any]: return { "sign_messages_input_signatures": [e.to_json() for e in self.signatures], + } + + + + def from_json(obj: Mapping[str, Any]) -> SignMessagesInput: return SignMessagesInput( - signatures=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: IdAndSignature_from_json(e), - obj["sign_messages_input_signatures"], - ) - ), - ) + signatures=list(map( + # pylint: disable=unnecessary-lambda + lambda e: IdAndSignature_from_json(e), obj["sign_messages_input_signatures"])), + + ) + diff --git a/lightspark/objects/SignMessagesOutput.py b/lightspark/objects/SignMessagesOutput.py index 382e144..501517e 100644 --- a/lightspark/objects/SignMessagesOutput.py +++ b/lightspark/objects/SignMessagesOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,20 +11,24 @@ @dataclass -class SignMessagesOutput: +class SignMessagesOutput(): + requester: Requester signed_payloads: List[SignablePayload] """The list of signed payloads.""" + + def to_json(self) -> Mapping[str, Any]: return { - "sign_messages_output_signed_payloads": [ - e.to_json() for e in self.signed_payloads - ], + "sign_messages_output_signed_payloads": [e.to_json() for e in self.signed_payloads], + } + + FRAGMENT = """ fragment SignMessagesOutputFragment on SignMessagesOutput { __typename @@ -34,14 +39,12 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> SignMessagesOutput: return SignMessagesOutput( - requester=requester, - signed_payloads=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: SignablePayload_from_json(requester, e), - obj["sign_messages_output_signed_payloads"], - ) - ), - ) + requester=requester, signed_payloads=list(map( + # pylint: disable=unnecessary-lambda + lambda e: SignablePayload_from_json(requester, e), obj["sign_messages_output_signed_payloads"])), + + ) + diff --git a/lightspark/objects/Signable.py b/lightspark/objects/Signable.py index b0cc213..0e39d05 100644 --- a/lightspark/objects/Signable.py +++ b/lightspark/objects/Signable.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -11,6 +12,7 @@ @dataclass class Signable(Entity): + requester: Requester id: str @@ -23,15 +25,19 @@ class Signable(Entity): """The date and time when the entity was last updated.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "Signable", "signable_id": self.id, "signable_created_at": self.created_at.isoformat(), "signable_updated_at": self.updated_at.isoformat(), + } + + FRAGMENT = """ fragment SignableFragment on Signable { __typename @@ -42,11 +48,12 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> Signable: return Signable( - requester=requester, - typename="Signable", - id=obj["signable_id"], + requester=requester, typename="Signable", id=obj["signable_id"], created_at=datetime.fromisoformat(obj["signable_created_at"]), updated_at=datetime.fromisoformat(obj["signable_updated_at"]), - ) + + ) + diff --git a/lightspark/objects/SignablePayload.py b/lightspark/objects/SignablePayload.py index 9122895..8df2ae3 100644 --- a/lightspark/objects/SignablePayload.py +++ b/lightspark/objects/SignablePayload.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -13,6 +14,7 @@ @dataclass class SignablePayload(Entity): + requester: Requester id: str @@ -43,6 +45,7 @@ class SignablePayload(Entity): """The signable this payload belongs to.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "SignablePayload", @@ -54,10 +57,13 @@ def to_json(self) -> Mapping[str, Any]: "signable_payload_status": self.status.value, "signable_payload_add_tweak": self.add_tweak, "signable_payload_mul_tweak": self.mul_tweak, - "signable_payload_signable": {"id": self.signable_id}, + "signable_payload_signable": { "id": self.signable_id }, + } + + FRAGMENT = """ fragment SignablePayloadFragment on SignablePayload { __typename @@ -76,17 +82,19 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> SignablePayload: return SignablePayload( - requester=requester, - typename="SignablePayload", - id=obj["signable_payload_id"], + requester=requester, typename="SignablePayload", id=obj["signable_payload_id"], created_at=datetime.fromisoformat(obj["signable_payload_created_at"]), updated_at=datetime.fromisoformat(obj["signable_payload_updated_at"]), payload=obj["signable_payload_payload"], derivation_path=obj["signable_payload_derivation_path"], - status=parse_enum(SignablePayloadStatus, obj["signable_payload_status"]), + + status=parse_enum(SignablePayloadStatus, obj['signable_payload_status']), add_tweak=obj["signable_payload_add_tweak"], mul_tweak=obj["signable_payload_mul_tweak"], signable_id=obj["signable_payload_signable"]["id"], - ) + + ) + diff --git a/lightspark/objects/SignablePayloadStatus.py b/lightspark/objects/SignablePayloadStatus.py index 2818591..d609482 100644 --- a/lightspark/objects/SignablePayloadStatus.py +++ b/lightspark/objects/SignablePayloadStatus.py @@ -1,12 +1,15 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum class SignablePayloadStatus(Enum): + ___FUTURE_VALUE___ = "___FUTURE_VALUE___" """This is an enum value that represents future values that could be added in the future. Clients should support unknown values as more of them could be added without notice.""" CREATED = "CREATED" SIGNED = "SIGNED" VALIDATION_FAILED = "VALIDATION_FAILED" INVALID_SIGNATURE = "INVALID_SIGNATURE" + diff --git a/lightspark/objects/Transaction.py b/lightspark/objects/Transaction.py index 232fe69..cc1508d 100644 --- a/lightspark/objects/Transaction.py +++ b/lightspark/objects/Transaction.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -47,6 +48,7 @@ class Transaction(Entity): """The hash of this transaction, so it can be uniquely identified on the Lightning Network.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": self.typename, @@ -54,14 +56,15 @@ def to_json(self) -> Mapping[str, Any]: "transaction_created_at": self.created_at.isoformat(), "transaction_updated_at": self.updated_at.isoformat(), "transaction_status": self.status.value, - "transaction_resolved_at": ( - self.resolved_at.isoformat() if self.resolved_at else None - ), + "transaction_resolved_at": self.resolved_at.isoformat() if self.resolved_at else None, "transaction_amount": self.amount.to_json(), "transaction_transaction_hash": self.transaction_hash, + } + + FRAGMENT = """ fragment TransactionFragment on Transaction { __typename @@ -616,307 +619,159 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> Transaction: # pylint: disable=too-many-return-statements if obj["__typename"] == "ChannelClosingTransaction": - # pylint: disable=import-outside-toplevel - from lightspark.objects.ChannelClosingTransaction import ( - ChannelClosingTransaction, - ) - + # pylint: disable=import-outside-toplevel + from lightspark.objects.ChannelClosingTransaction import \ + ChannelClosingTransaction return ChannelClosingTransaction( - requester=requester, - typename="ChannelClosingTransaction", - id=obj["channel_closing_transaction_id"], - 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=( - 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"] - ), + requester=requester, typename="ChannelClosingTransaction", id=obj["channel_closing_transaction_id"], + 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=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"]), transaction_hash=obj["channel_closing_transaction_transaction_hash"], - fees=( - CurrencyAmount_from_json( - requester, obj["channel_closing_transaction_fees"] - ) - if obj["channel_closing_transaction_fees"] - else None - ), + fees=CurrencyAmount_from_json(requester, obj["channel_closing_transaction_fees"]) if obj["channel_closing_transaction_fees"] else None, block_hash=obj["channel_closing_transaction_block_hash"], block_height=obj["channel_closing_transaction_block_height"], - destination_addresses=obj[ - "channel_closing_transaction_destination_addresses" - ], + destination_addresses=obj["channel_closing_transaction_destination_addresses"], num_confirmations=obj["channel_closing_transaction_num_confirmations"], - channel_id=( - obj["channel_closing_transaction_channel"]["id"] - if obj["channel_closing_transaction_channel"] - else None - ), + channel_id=obj["channel_closing_transaction_channel"]["id"] if obj["channel_closing_transaction_channel"] else None, + ) if obj["__typename"] == "ChannelOpeningTransaction": - # pylint: disable=import-outside-toplevel - from lightspark.objects.ChannelOpeningTransaction import ( - ChannelOpeningTransaction, - ) - + # pylint: disable=import-outside-toplevel + from lightspark.objects.ChannelOpeningTransaction import \ + ChannelOpeningTransaction return ChannelOpeningTransaction( - requester=requester, - typename="ChannelOpeningTransaction", - id=obj["channel_opening_transaction_id"], - 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=( - 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"] - ), + requester=requester, typename="ChannelOpeningTransaction", id=obj["channel_opening_transaction_id"], + 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=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"]), transaction_hash=obj["channel_opening_transaction_transaction_hash"], - fees=( - CurrencyAmount_from_json( - requester, obj["channel_opening_transaction_fees"] - ) - if obj["channel_opening_transaction_fees"] - else None - ), + fees=CurrencyAmount_from_json(requester, obj["channel_opening_transaction_fees"]) if obj["channel_opening_transaction_fees"] else None, block_hash=obj["channel_opening_transaction_block_hash"], block_height=obj["channel_opening_transaction_block_height"], - destination_addresses=obj[ - "channel_opening_transaction_destination_addresses" - ], + destination_addresses=obj["channel_opening_transaction_destination_addresses"], num_confirmations=obj["channel_opening_transaction_num_confirmations"], - channel_id=( - obj["channel_opening_transaction_channel"]["id"] - if obj["channel_opening_transaction_channel"] - else None - ), + channel_id=obj["channel_opening_transaction_channel"]["id"] if obj["channel_opening_transaction_channel"] else None, + ) if obj["__typename"] == "Deposit": - # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel from lightspark.objects.Deposit import Deposit - return Deposit( - requester=requester, - typename="Deposit", - id=obj["deposit_id"], + requester=requester, typename="Deposit", id=obj["deposit_id"], 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=( - datetime.fromisoformat(obj["deposit_resolved_at"]) - if obj["deposit_resolved_at"] - else None - ), + + status=parse_enum(TransactionStatus, obj['deposit_status']), + 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"]) - if obj["deposit_fees"] - else None - ), + fees=CurrencyAmount_from_json(requester, obj["deposit_fees"]) if obj["deposit_fees"] else None, block_hash=obj["deposit_block_hash"], block_height=obj["deposit_block_height"], destination_addresses=obj["deposit_destination_addresses"], num_confirmations=obj["deposit_num_confirmations"], destination_id=obj["deposit_destination"]["id"], + ) if obj["__typename"] == "IncomingPayment": - # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel from lightspark.objects.IncomingPayment import IncomingPayment - return IncomingPayment( - requester=requester, - typename="IncomingPayment", - id=obj["incoming_payment_id"], + requester=requester, typename="IncomingPayment", id=obj["incoming_payment_id"], 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=( - datetime.fromisoformat(obj["incoming_payment_resolved_at"]) - if obj["incoming_payment_resolved_at"] - else None - ), + + status=parse_enum(TransactionStatus, obj['incoming_payment_status']), + 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"], is_uma=obj["incoming_payment_is_uma"], destination_id=obj["incoming_payment_destination"]["id"], - payment_request_id=( - obj["incoming_payment_payment_request"]["id"] - if obj["incoming_payment_payment_request"] - else None - ), - uma_post_transaction_data=( - list( - map( - # pylint: disable=unnecessary-lambda - lambda e: PostTransactionData_from_json(requester, e), - obj["incoming_payment_uma_post_transaction_data"], - ) - ) - if obj["incoming_payment_uma_post_transaction_data"] - else None - ), + payment_request_id=obj["incoming_payment_payment_request"]["id"] if obj["incoming_payment_payment_request"] else None, + uma_post_transaction_data=list(map( + # pylint: disable=unnecessary-lambda + lambda e: PostTransactionData_from_json(requester, e), obj["incoming_payment_uma_post_transaction_data"])) if obj["incoming_payment_uma_post_transaction_data"] else None, is_internal_payment=obj["incoming_payment_is_internal_payment"], + ) if obj["__typename"] == "OutgoingPayment": - # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel from lightspark.objects.OutgoingPayment import OutgoingPayment - return OutgoingPayment( - requester=requester, - typename="OutgoingPayment", - id=obj["outgoing_payment_id"], + requester=requester, typename="OutgoingPayment", id=obj["outgoing_payment_id"], 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=( - datetime.fromisoformat(obj["outgoing_payment_resolved_at"]) - if obj["outgoing_payment_resolved_at"] - else None - ), + + status=parse_enum(TransactionStatus, obj['outgoing_payment_status']), + 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"], is_uma=obj["outgoing_payment_is_uma"], origin_id=obj["outgoing_payment_origin"]["id"], - destination_id=( - obj["outgoing_payment_destination"]["id"] - if obj["outgoing_payment_destination"] - else None - ), - fees=( - CurrencyAmount_from_json(requester, obj["outgoing_payment_fees"]) - if obj["outgoing_payment_fees"] - else None - ), - payment_request_data=( - PaymentRequestData_from_json( - requester, obj["outgoing_payment_payment_request_data"] - ) - if obj["outgoing_payment_payment_request_data"] - else None - ), - failure_reason=parse_enum_optional( - PaymentFailureReason, obj["outgoing_payment_failure_reason"] - ), - failure_message=( - RichText_from_json(requester, obj["outgoing_payment_failure_message"]) - if obj["outgoing_payment_failure_message"] - else None - ), - uma_post_transaction_data=( - list( - map( - # pylint: disable=unnecessary-lambda - lambda e: PostTransactionData_from_json(requester, e), - obj["outgoing_payment_uma_post_transaction_data"], - ) - ) - if obj["outgoing_payment_uma_post_transaction_data"] - else None - ), + destination_id=obj["outgoing_payment_destination"]["id"] if obj["outgoing_payment_destination"] else None, + fees=CurrencyAmount_from_json(requester, obj["outgoing_payment_fees"]) if obj["outgoing_payment_fees"] else None, + payment_request_data=PaymentRequestData_from_json(requester, obj["outgoing_payment_payment_request_data"]) if obj["outgoing_payment_payment_request_data"] else None, + + failure_reason=parse_enum_optional(PaymentFailureReason, obj['outgoing_payment_failure_reason']), + failure_message=RichText_from_json(requester, obj["outgoing_payment_failure_message"]) if obj["outgoing_payment_failure_message"] else None, + uma_post_transaction_data=list(map( + # pylint: disable=unnecessary-lambda + lambda e: PostTransactionData_from_json(requester, e), obj["outgoing_payment_uma_post_transaction_data"])) if obj["outgoing_payment_uma_post_transaction_data"] else None, payment_preimage=obj["outgoing_payment_payment_preimage"], is_internal_payment=obj["outgoing_payment_is_internal_payment"], idempotency_key=obj["outgoing_payment_idempotency_key"], + ) if obj["__typename"] == "RoutingTransaction": - # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel from lightspark.objects.RoutingTransaction import RoutingTransaction - return RoutingTransaction( - requester=requester, - typename="RoutingTransaction", - id=obj["routing_transaction_id"], + requester=requester, typename="RoutingTransaction", id=obj["routing_transaction_id"], 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=( - datetime.fromisoformat(obj["routing_transaction_resolved_at"]) - if obj["routing_transaction_resolved_at"] - else None - ), - amount=CurrencyAmount_from_json( - requester, obj["routing_transaction_amount"] - ), + + status=parse_enum(TransactionStatus, obj['routing_transaction_status']), + 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"]), transaction_hash=obj["routing_transaction_transaction_hash"], - incoming_channel_id=( - obj["routing_transaction_incoming_channel"]["id"] - if obj["routing_transaction_incoming_channel"] - else None - ), - outgoing_channel_id=( - obj["routing_transaction_outgoing_channel"]["id"] - if obj["routing_transaction_outgoing_channel"] - else None - ), - fees=( - CurrencyAmount_from_json(requester, obj["routing_transaction_fees"]) - if obj["routing_transaction_fees"] - else None - ), - failure_message=( - RichText_from_json( - requester, obj["routing_transaction_failure_message"] - ) - if obj["routing_transaction_failure_message"] - else None - ), - failure_reason=parse_enum_optional( - RoutingTransactionFailureReason, - obj["routing_transaction_failure_reason"], - ), + incoming_channel_id=obj["routing_transaction_incoming_channel"]["id"] if obj["routing_transaction_incoming_channel"] else None, + outgoing_channel_id=obj["routing_transaction_outgoing_channel"]["id"] if obj["routing_transaction_outgoing_channel"] else None, + fees=CurrencyAmount_from_json(requester, obj["routing_transaction_fees"]) if obj["routing_transaction_fees"] else None, + failure_message=RichText_from_json(requester, obj["routing_transaction_failure_message"]) if obj["routing_transaction_failure_message"] else None, + + failure_reason=parse_enum_optional(RoutingTransactionFailureReason, obj['routing_transaction_failure_reason']), + ) if obj["__typename"] == "Withdrawal": - # pylint: disable=import-outside-toplevel + # pylint: disable=import-outside-toplevel from lightspark.objects.Withdrawal import Withdrawal - return Withdrawal( - requester=requester, - typename="Withdrawal", - id=obj["withdrawal_id"], + requester=requester, typename="Withdrawal", id=obj["withdrawal_id"], created_at=datetime.fromisoformat(obj["withdrawal_created_at"]), updated_at=datetime.fromisoformat(obj["withdrawal_updated_at"]), - status=parse_enum(TransactionStatus, obj["withdrawal_status"]), - resolved_at=( - datetime.fromisoformat(obj["withdrawal_resolved_at"]) - if obj["withdrawal_resolved_at"] - else None - ), + + status=parse_enum(TransactionStatus, obj['withdrawal_status']), + resolved_at=datetime.fromisoformat(obj["withdrawal_resolved_at"]) if obj["withdrawal_resolved_at"] else None, amount=CurrencyAmount_from_json(requester, obj["withdrawal_amount"]), transaction_hash=obj["withdrawal_transaction_hash"], - fees=( - CurrencyAmount_from_json(requester, obj["withdrawal_fees"]) - if obj["withdrawal_fees"] - else None - ), + fees=CurrencyAmount_from_json(requester, obj["withdrawal_fees"]) if obj["withdrawal_fees"] else None, block_hash=obj["withdrawal_block_hash"], block_height=obj["withdrawal_block_height"], destination_addresses=obj["withdrawal_destination_addresses"], num_confirmations=obj["withdrawal_num_confirmations"], origin_id=obj["withdrawal_origin"]["id"], + ) graphql_typename = obj["__typename"] - raise LightsparkException( - "UNKNOWN_INTERFACE", - f"Couldn't find a concrete type for interface Transaction corresponding to the typename={graphql_typename}", - ) + raise LightsparkException("UNKNOWN_INTERFACE", f"Couldn't find a concrete type for interface Transaction corresponding to the typename={graphql_typename}") diff --git a/lightspark/objects/TransactionFailures.py b/lightspark/objects/TransactionFailures.py index d5c6e63..29051c4 100644 --- a/lightspark/objects/TransactionFailures.py +++ b/lightspark/objects/TransactionFailures.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,35 +11,34 @@ @dataclass -class TransactionFailures: +class TransactionFailures(): """This object represents payment failures associated with your Lightspark Node.""" + payment_failures: Optional[List[PaymentFailureReason]] + routing_transaction_failures: Optional[List[RoutingTransactionFailureReason]] + + + def to_json(self) -> Mapping[str, Any]: return { - "transaction_failures_payment_failures": ( - [e.value for e in self.payment_failures] - if self.payment_failures - else None - ), - "transaction_failures_routing_transaction_failures": ( - [e.value for e in self.routing_transaction_failures] - if self.routing_transaction_failures - else None - ), + "transaction_failures_payment_failures": [e.value for e in self.payment_failures] if self.payment_failures else None, + "transaction_failures_routing_transaction_failures": [e.value for e in self.routing_transaction_failures] if self.routing_transaction_failures else None, + } + + + + def from_json(obj: Mapping[str, Any]) -> TransactionFailures: return TransactionFailures( - payment_failures=parse_optional_list_of_enums( - PaymentFailureReason, obj["transaction_failures_payment_failures"] - ), - routing_transaction_failures=parse_optional_list_of_enums( - RoutingTransactionFailureReason, - obj["transaction_failures_routing_transaction_failures"], - ), - ) + payment_failures=parse_optional_list_of_enums(PaymentFailureReason, obj["transaction_failures_payment_failures"]), + routing_transaction_failures=parse_optional_list_of_enums(RoutingTransactionFailureReason, obj["transaction_failures_routing_transaction_failures"]), + + ) + diff --git a/lightspark/objects/TransactionStatus.py b/lightspark/objects/TransactionStatus.py index 896c9b3..6481c98 100644 --- a/lightspark/objects/TransactionStatus.py +++ b/lightspark/objects/TransactionStatus.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -20,3 +21,4 @@ class TransactionStatus(Enum): """For transaction type PAYMENT_REQUEST only. A payment request has expired.""" CANCELLED = "CANCELLED" """For transaction type PAYMENT_REQUEST only.""" + diff --git a/lightspark/objects/TransactionType.py b/lightspark/objects/TransactionType.py index 7ea7900..a1c595f 100644 --- a/lightspark/objects/TransactionType.py +++ b/lightspark/objects/TransactionType.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -28,3 +29,4 @@ class TransactionType(Enum): """Payment requests from a Lightspark node on Lightning Network""" ROUTE = "ROUTE" """Transactions that forwarded payments through Lightspark nodes on Lightning Network.""" + diff --git a/lightspark/objects/UmaInvitation.py b/lightspark/objects/UmaInvitation.py index bb6659e..8d261d3 100644 --- a/lightspark/objects/UmaInvitation.py +++ b/lightspark/objects/UmaInvitation.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -46,6 +47,7 @@ class UmaInvitation(Entity): """The reason why the invitation is not eligible for incentives, if applicable.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "UmaInvitation", @@ -57,14 +59,13 @@ def to_json(self) -> Mapping[str, Any]: "uma_invitation_inviter_uma": self.inviter_uma, "uma_invitation_invitee_uma": self.invitee_uma, "uma_invitation_incentives_status": self.incentives_status.value, - "uma_invitation_incentives_ineligibility_reason": ( - self.incentives_ineligibility_reason.value - if self.incentives_ineligibility_reason - else None - ), + "uma_invitation_incentives_ineligibility_reason": self.incentives_ineligibility_reason.value if self.incentives_ineligibility_reason else None, + } + + FRAGMENT = """ fragment UmaInvitationFragment on UmaInvitation { __typename @@ -81,22 +82,20 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> UmaInvitation: return UmaInvitation( - requester=requester, - typename="UmaInvitation", - id=obj["uma_invitation_id"], + requester=requester, typename="UmaInvitation", id=obj["uma_invitation_id"], created_at=datetime.fromisoformat(obj["uma_invitation_created_at"]), updated_at=datetime.fromisoformat(obj["uma_invitation_updated_at"]), code=obj["uma_invitation_code"], url=obj["uma_invitation_url"], inviter_uma=obj["uma_invitation_inviter_uma"], invitee_uma=obj["uma_invitation_invitee_uma"], - incentives_status=parse_enum( - IncentivesStatus, obj["uma_invitation_incentives_status"] - ), - incentives_ineligibility_reason=parse_enum_optional( - IncentivesIneligibilityReason, - obj["uma_invitation_incentives_ineligibility_reason"], - ), - ) + + incentives_status=parse_enum(IncentivesStatus, obj['uma_invitation_incentives_status']), + + incentives_ineligibility_reason=parse_enum_optional(IncentivesIneligibilityReason, obj['uma_invitation_incentives_ineligibility_reason']), + + ) + diff --git a/lightspark/objects/UpdateChannelPerCommitmentPointInput.py b/lightspark/objects/UpdateChannelPerCommitmentPointInput.py index 3903dda..881fad5 100644 --- a/lightspark/objects/UpdateChannelPerCommitmentPointInput.py +++ b/lightspark/objects/UpdateChannelPerCommitmentPointInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,28 +6,38 @@ @dataclass -class UpdateChannelPerCommitmentPointInput: +class UpdateChannelPerCommitmentPointInput(): + + channel_id: str + per_commitment_point: str + per_commitment_point_index: int + + + def to_json(self) -> Mapping[str, Any]: return { "update_channel_per_commitment_point_input_channel_id": self.channel_id, "update_channel_per_commitment_point_input_per_commitment_point": self.per_commitment_point, "update_channel_per_commitment_point_input_per_commitment_point_index": self.per_commitment_point_index, + } + + + + def from_json(obj: Mapping[str, Any]) -> UpdateChannelPerCommitmentPointInput: return UpdateChannelPerCommitmentPointInput( channel_id=obj["update_channel_per_commitment_point_input_channel_id"], - per_commitment_point=obj[ - "update_channel_per_commitment_point_input_per_commitment_point" - ], - per_commitment_point_index=obj[ - "update_channel_per_commitment_point_input_per_commitment_point_index" - ], - ) + per_commitment_point=obj["update_channel_per_commitment_point_input_per_commitment_point"], + per_commitment_point_index=obj["update_channel_per_commitment_point_input_per_commitment_point_index"], + + ) + diff --git a/lightspark/objects/UpdateChannelPerCommitmentPointOutput.py b/lightspark/objects/UpdateChannelPerCommitmentPointOutput.py index 4836a06..8df4170 100644 --- a/lightspark/objects/UpdateChannelPerCommitmentPointOutput.py +++ b/lightspark/objects/UpdateChannelPerCommitmentPointOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,19 +8,24 @@ @dataclass -class UpdateChannelPerCommitmentPointOutput: +class UpdateChannelPerCommitmentPointOutput(): + requester: Requester channel_id: str + + + def to_json(self) -> Mapping[str, Any]: return { - "update_channel_per_commitment_point_output_channel": { - "id": self.channel_id - }, + "update_channel_per_commitment_point_output_channel": { "id": self.channel_id }, + } + + FRAGMENT = """ fragment UpdateChannelPerCommitmentPointOutputFragment on UpdateChannelPerCommitmentPointOutput { __typename @@ -30,10 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> UpdateChannelPerCommitmentPointOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> UpdateChannelPerCommitmentPointOutput: return UpdateChannelPerCommitmentPointOutput( - requester=requester, - channel_id=obj["update_channel_per_commitment_point_output_channel"]["id"], - ) + requester=requester, channel_id=obj["update_channel_per_commitment_point_output_channel"]["id"], + + ) + diff --git a/lightspark/objects/UpdateNodeSharedSecretInput.py b/lightspark/objects/UpdateNodeSharedSecretInput.py index b070987..1759df9 100644 --- a/lightspark/objects/UpdateNodeSharedSecretInput.py +++ b/lightspark/objects/UpdateNodeSharedSecretInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -5,20 +6,33 @@ @dataclass -class UpdateNodeSharedSecretInput: +class UpdateNodeSharedSecretInput(): + + node_id: str + shared_secret: str + + + def to_json(self) -> Mapping[str, Any]: return { "update_node_shared_secret_input_node_id": self.node_id, "update_node_shared_secret_input_shared_secret": self.shared_secret, + } + + + + def from_json(obj: Mapping[str, Any]) -> UpdateNodeSharedSecretInput: return UpdateNodeSharedSecretInput( node_id=obj["update_node_shared_secret_input_node_id"], shared_secret=obj["update_node_shared_secret_input_shared_secret"], - ) + + ) + diff --git a/lightspark/objects/UpdateNodeSharedSecretOutput.py b/lightspark/objects/UpdateNodeSharedSecretOutput.py index 86415fd..ad2336c 100644 --- a/lightspark/objects/UpdateNodeSharedSecretOutput.py +++ b/lightspark/objects/UpdateNodeSharedSecretOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -7,17 +8,24 @@ @dataclass -class UpdateNodeSharedSecretOutput: +class UpdateNodeSharedSecretOutput(): + requester: Requester node_id: str + + + def to_json(self) -> Mapping[str, Any]: return { - "update_node_shared_secret_output_node": {"id": self.node_id}, + "update_node_shared_secret_output_node": { "id": self.node_id }, + } + + FRAGMENT = """ fragment UpdateNodeSharedSecretOutputFragment on UpdateNodeSharedSecretOutput { __typename @@ -28,10 +36,10 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> UpdateNodeSharedSecretOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> UpdateNodeSharedSecretOutput: return UpdateNodeSharedSecretOutput( - requester=requester, - node_id=obj["update_node_shared_secret_output_node"]["id"], - ) + requester=requester, node_id=obj["update_node_shared_secret_output_node"]["id"], + + ) + diff --git a/lightspark/objects/Wallet.py b/lightspark/objects/Wallet.py index 2fe28ef..c36d709 100644 --- a/lightspark/objects/Wallet.py +++ b/lightspark/objects/Wallet.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -16,18 +17,17 @@ from .TransactionStatus import TransactionStatus from .TransactionType import TransactionType from .WalletStatus import WalletStatus -from .WalletToPaymentRequestsConnection import WalletToPaymentRequestsConnection -from .WalletToPaymentRequestsConnection import ( - from_json as WalletToPaymentRequestsConnection_from_json, -) +from .WalletToPaymentRequestsConnection import \ + WalletToPaymentRequestsConnection +from .WalletToPaymentRequestsConnection import \ + from_json as WalletToPaymentRequestsConnection_from_json from .WalletToTransactionsConnection import WalletToTransactionsConnection -from .WalletToTransactionsConnection import ( - from_json as WalletToTransactionsConnection_from_json, -) -from .WalletToWithdrawalRequestsConnection import WalletToWithdrawalRequestsConnection -from .WalletToWithdrawalRequestsConnection import ( - from_json as WalletToWithdrawalRequestsConnection_from_json, -) +from .WalletToTransactionsConnection import \ + from_json as WalletToTransactionsConnection_from_json +from .WalletToWithdrawalRequestsConnection import \ + WalletToWithdrawalRequestsConnection +from .WalletToWithdrawalRequestsConnection import \ + from_json as WalletToWithdrawalRequestsConnection_from_json from .WithdrawalRequestStatus import WithdrawalRequestStatus @@ -62,15 +62,7 @@ class Wallet(LightsparkNodeOwner, Entity): """The status of this wallet.""" typename: str - def get_transactions( - self, - first: Optional[int] = None, - after: Optional[str] = None, - created_after_date: Optional[datetime] = None, - created_before_date: Optional[datetime] = None, - statuses: Optional[List[TransactionStatus]] = None, - types: Optional[List[TransactionType]] = None, - ) -> WalletToTransactionsConnection: + def get_transactions(self, first: Optional[int]= None, after: Optional[str]= None, created_after_date: Optional[datetime]= None, created_before_date: Optional[datetime]= None, statuses: Optional[List[TransactionStatus]]= None, types: Optional[List[TransactionType]]= None) -> WalletToTransactionsConnection: json = self.requester.execute_graphql( """ query FetchWalletToTransactionsConnection($entity_id: ID!, $first: Int, $after: ID, $created_after_date: DateTime, $created_before_date: DateTime, $statuses: [TransactionStatus!], $types: [TransactionType!]) { @@ -641,26 +633,12 @@ def get_transactions( } } """, - { - "entity_id": self.id, - "first": first, - "after": after, - "created_after_date": created_after_date, - "created_before_date": created_before_date, - "statuses": statuses, - "types": types, - }, + {"entity_id": self.id, "first": first, "after": after, "created_after_date": created_after_date, "created_before_date": created_before_date, "statuses": statuses, "types": types} ) connection = json["entity"]["transactions"] return WalletToTransactionsConnection_from_json(self.requester, connection) - def get_payment_requests( - self, - first: Optional[int] = None, - after: Optional[str] = None, - created_after_date: Optional[datetime] = None, - created_before_date: Optional[datetime] = None, - ) -> WalletToPaymentRequestsConnection: + def get_payment_requests(self, first: Optional[int]= None, after: Optional[str]= None, created_after_date: Optional[datetime]= None, created_before_date: Optional[datetime]= None) -> WalletToPaymentRequestsConnection: json = self.requester.execute_graphql( """ query FetchWalletToPaymentRequestsConnection($entity_id: ID!, $first: Int, $after: ID, $created_after_date: DateTime, $created_before_date: DateTime) { @@ -992,22 +970,12 @@ def get_payment_requests( } } """, - { - "entity_id": self.id, - "first": first, - "after": after, - "created_after_date": created_after_date, - "created_before_date": created_before_date, - }, + {"entity_id": self.id, "first": first, "after": after, "created_after_date": created_after_date, "created_before_date": created_before_date} ) connection = json["entity"]["payment_requests"] return WalletToPaymentRequestsConnection_from_json(self.requester, connection) - def get_total_amount_received( - self, - created_after_date: Optional[datetime] = None, - created_before_date: Optional[datetime] = None, - ) -> CurrencyAmount: + def get_total_amount_received(self, created_after_date: Optional[datetime]= None, created_before_date: Optional[datetime]= None) -> CurrencyAmount: json = self.requester.execute_graphql( """ query FetchWalletTotalAmountReceived($entity_id: ID!, $created_after_date: DateTime, $created_before_date: DateTime) { @@ -1025,23 +993,12 @@ def get_total_amount_received( } } """, - { - "entity_id": self.id, - "created_after_date": created_after_date, - "created_before_date": created_before_date, - }, + {"entity_id": self.id, "created_after_date": created_after_date, "created_before_date": created_before_date} ) connection = json["entity"]["total_amount_received"] return CurrencyAmount_from_json(self.requester, connection) - def get_withdrawal_requests( - self, - first: Optional[int] = None, - after: Optional[str] = None, - statuses: Optional[List[WithdrawalRequestStatus]] = None, - created_after_date: Optional[datetime] = None, - created_before_date: Optional[datetime] = None, - ) -> WalletToWithdrawalRequestsConnection: + def get_withdrawal_requests(self, first: Optional[int]= None, after: Optional[str]= None, statuses: Optional[List[WithdrawalRequestStatus]]= None, created_after_date: Optional[datetime]= None, created_before_date: Optional[datetime]= None) -> WalletToWithdrawalRequestsConnection: json = self.requester.execute_graphql( """ query FetchWalletToWithdrawalRequestsConnection($entity_id: ID!, $first: Int, $after: ID, $statuses: [WithdrawalRequestStatus!], $created_after_date: DateTime, $created_before_date: DateTime) { @@ -1117,25 +1074,12 @@ def get_withdrawal_requests( } } """, - { - "entity_id": self.id, - "first": first, - "after": after, - "statuses": statuses, - "created_after_date": created_after_date, - "created_before_date": created_before_date, - }, + {"entity_id": self.id, "first": first, "after": after, "statuses": statuses, "created_after_date": created_after_date, "created_before_date": created_before_date} ) connection = json["entity"]["withdrawal_requests"] - return WalletToWithdrawalRequestsConnection_from_json( - self.requester, connection - ) + return WalletToWithdrawalRequestsConnection_from_json(self.requester, connection) - def get_total_amount_sent( - self, - created_after_date: Optional[datetime] = None, - created_before_date: Optional[datetime] = None, - ) -> CurrencyAmount: + def get_total_amount_sent(self, created_after_date: Optional[datetime]= None, created_before_date: Optional[datetime]= None) -> CurrencyAmount: json = self.requester.execute_graphql( """ query FetchWalletTotalAmountSent($entity_id: ID!, $created_after_date: DateTime, $created_before_date: DateTime) { @@ -1153,31 +1097,29 @@ def get_total_amount_sent( } } """, - { - "entity_id": self.id, - "created_after_date": created_after_date, - "created_before_date": created_before_date, - }, + {"entity_id": self.id, "created_after_date": created_after_date, "created_before_date": created_before_date} ) connection = json["entity"]["total_amount_sent"] return CurrencyAmount_from_json(self.requester, connection) + def to_json(self) -> Mapping[str, Any]: return { "__typename": "Wallet", "wallet_id": self.id, "wallet_created_at": self.created_at.isoformat(), "wallet_updated_at": self.updated_at.isoformat(), - "wallet_last_login_at": ( - self.last_login_at.isoformat() if self.last_login_at else None - ), + "wallet_last_login_at": self.last_login_at.isoformat() if self.last_login_at else None, "wallet_balances": self.balances.to_json() if self.balances else None, "wallet_third_party_identifier": self.third_party_identifier, - "wallet_account": {"id": self.account_id} if self.account_id else None, + "wallet_account": { "id": self.account_id } if self.account_id else None, "wallet_status": self.status.value, + } + + FRAGMENT = """ fragment WalletFragment on Wallet { __typename @@ -1221,24 +1163,18 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> Wallet: return Wallet( - requester=requester, - typename="Wallet", - id=obj["wallet_id"], + requester=requester, typename="Wallet", id=obj["wallet_id"], 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 - ), + 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, third_party_identifier=obj["wallet_third_party_identifier"], account_id=obj["wallet_account"]["id"] if obj["wallet_account"] else None, - status=parse_enum(WalletStatus, obj["wallet_status"]), - ) + + status=parse_enum(WalletStatus, obj['wallet_status']), + + ) + diff --git a/lightspark/objects/WalletStatus.py b/lightspark/objects/WalletStatus.py index 012e932..507aa5c 100644 --- a/lightspark/objects/WalletStatus.py +++ b/lightspark/objects/WalletStatus.py @@ -1,10 +1,11 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum class WalletStatus(Enum): - """This is an enum of the potential statuses that your Lightspark wallet can take.""" + """This is an enum of the potential statuses that your Lightspark wallet can take. """ ___FUTURE_VALUE___ = "___FUTURE_VALUE___" """This is an enum value that represents future values that could be added in the future. Clients should support unknown values as more of them could be added without notice.""" @@ -26,3 +27,4 @@ class WalletStatus(Enum): """The wallet is being terminated.""" TERMINATED = "TERMINATED" """The wallet has been terminated and is not available in the Lightspark infrastructure anymore. It is not connected to the Lightning network and its funds can only be accessed using the Funds Recovery flow.""" + diff --git a/lightspark/objects/WalletToPaymentRequestsConnection.py b/lightspark/objects/WalletToPaymentRequestsConnection.py index 3ce6f8d..6a9850a 100644 --- a/lightspark/objects/WalletToPaymentRequestsConnection.py +++ b/lightspark/objects/WalletToPaymentRequestsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -14,6 +15,7 @@ @dataclass class WalletToPaymentRequestsConnection(Connection): + requester: Requester count: int @@ -26,17 +28,19 @@ class WalletToPaymentRequestsConnection(Connection): """The payment requests for the current page of this connection.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "WalletToPaymentRequestsConnection", "wallet_to_payment_requests_connection_count": self.count, "wallet_to_payment_requests_connection_page_info": self.page_info.to_json(), - "wallet_to_payment_requests_connection_entities": [ - e.to_json() for e in self.entities - ], + "wallet_to_payment_requests_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment WalletToPaymentRequestsConnectionFragment on WalletToPaymentRequestsConnection { __typename @@ -55,21 +59,14 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> WalletToPaymentRequestsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> WalletToPaymentRequestsConnection: return WalletToPaymentRequestsConnection( - requester=requester, - typename="WalletToPaymentRequestsConnection", - count=obj["wallet_to_payment_requests_connection_count"], - page_info=PageInfo_from_json( - requester, obj["wallet_to_payment_requests_connection_page_info"] - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: PaymentRequest_from_json(requester, e), - obj["wallet_to_payment_requests_connection_entities"], - ) - ), - ) + requester=requester, typename="WalletToPaymentRequestsConnection", count=obj["wallet_to_payment_requests_connection_count"], + page_info=PageInfo_from_json(requester, obj["wallet_to_payment_requests_connection_page_info"]), + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: PaymentRequest_from_json(requester, e), obj["wallet_to_payment_requests_connection_entities"])), + + ) + diff --git a/lightspark/objects/WalletToTransactionsConnection.py b/lightspark/objects/WalletToTransactionsConnection.py index da95d27..429d5ad 100644 --- a/lightspark/objects/WalletToTransactionsConnection.py +++ b/lightspark/objects/WalletToTransactionsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -14,6 +15,7 @@ @dataclass class WalletToTransactionsConnection(Connection): + requester: Requester count: int @@ -26,17 +28,19 @@ class WalletToTransactionsConnection(Connection): """The transactions for the current page of this connection.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "WalletToTransactionsConnection", "wallet_to_transactions_connection_count": self.count, "wallet_to_transactions_connection_page_info": self.page_info.to_json(), - "wallet_to_transactions_connection_entities": [ - e.to_json() for e in self.entities - ], + "wallet_to_transactions_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment WalletToTransactionsConnectionFragment on WalletToTransactionsConnection { __typename @@ -55,21 +59,14 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> WalletToTransactionsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> WalletToTransactionsConnection: return WalletToTransactionsConnection( - requester=requester, - typename="WalletToTransactionsConnection", - count=obj["wallet_to_transactions_connection_count"], - page_info=PageInfo_from_json( - requester, obj["wallet_to_transactions_connection_page_info"] - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: Transaction_from_json(requester, e), - obj["wallet_to_transactions_connection_entities"], - ) - ), - ) + requester=requester, typename="WalletToTransactionsConnection", count=obj["wallet_to_transactions_connection_count"], + page_info=PageInfo_from_json(requester, obj["wallet_to_transactions_connection_page_info"]), + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: Transaction_from_json(requester, e), obj["wallet_to_transactions_connection_entities"])), + + ) + diff --git a/lightspark/objects/WalletToWithdrawalRequestsConnection.py b/lightspark/objects/WalletToWithdrawalRequestsConnection.py index e7ce6ad..3bc7249 100644 --- a/lightspark/objects/WalletToWithdrawalRequestsConnection.py +++ b/lightspark/objects/WalletToWithdrawalRequestsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -14,6 +15,7 @@ @dataclass class WalletToWithdrawalRequestsConnection(Connection): + requester: Requester count: int @@ -26,17 +28,19 @@ class WalletToWithdrawalRequestsConnection(Connection): """The withdrawal requests for the current page of this connection.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "WalletToWithdrawalRequestsConnection", "wallet_to_withdrawal_requests_connection_count": self.count, "wallet_to_withdrawal_requests_connection_page_info": self.page_info.to_json(), - "wallet_to_withdrawal_requests_connection_entities": [ - e.to_json() for e in self.entities - ], + "wallet_to_withdrawal_requests_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment WalletToWithdrawalRequestsConnectionFragment on WalletToWithdrawalRequestsConnection { __typename @@ -55,21 +59,14 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> WalletToWithdrawalRequestsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> WalletToWithdrawalRequestsConnection: return WalletToWithdrawalRequestsConnection( - requester=requester, - typename="WalletToWithdrawalRequestsConnection", - count=obj["wallet_to_withdrawal_requests_connection_count"], - page_info=PageInfo_from_json( - requester, obj["wallet_to_withdrawal_requests_connection_page_info"] - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: WithdrawalRequest_from_json(requester, e), - obj["wallet_to_withdrawal_requests_connection_entities"], - ) - ), - ) + requester=requester, typename="WalletToWithdrawalRequestsConnection", count=obj["wallet_to_withdrawal_requests_connection_count"], + page_info=PageInfo_from_json(requester, obj["wallet_to_withdrawal_requests_connection_page_info"]), + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: WithdrawalRequest_from_json(requester, e), obj["wallet_to_withdrawal_requests_connection_entities"])), + + ) + diff --git a/lightspark/objects/WebhookEventType.py b/lightspark/objects/WebhookEventType.py index 957bd4a..496d34e 100644 --- a/lightspark/objects/WebhookEventType.py +++ b/lightspark/objects/WebhookEventType.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -23,3 +24,4 @@ class WebhookEventType(Enum): LOW_BALANCE = "LOW_BALANCE" HIGH_BALANCE = "HIGH_BALANCE" CHANNEL_OPENING_FEES = "CHANNEL_OPENING_FEES" + diff --git a/lightspark/objects/Withdrawal.py b/lightspark/objects/Withdrawal.py index 3569632..fbfb830 100644 --- a/lightspark/objects/Withdrawal.py +++ b/lightspark/objects/Withdrawal.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -61,6 +62,7 @@ class Withdrawal(OnChainTransaction, Transaction, Entity): """The Lightspark node this withdrawal originated from.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "Withdrawal", @@ -68,9 +70,7 @@ def to_json(self) -> Mapping[str, Any]: "withdrawal_created_at": self.created_at.isoformat(), "withdrawal_updated_at": self.updated_at.isoformat(), "withdrawal_status": self.status.value, - "withdrawal_resolved_at": ( - self.resolved_at.isoformat() if self.resolved_at else None - ), + "withdrawal_resolved_at": self.resolved_at.isoformat() if self.resolved_at else None, "withdrawal_amount": self.amount.to_json(), "withdrawal_transaction_hash": self.transaction_hash, "withdrawal_fees": self.fees.to_json() if self.fees else None, @@ -78,10 +78,13 @@ def to_json(self) -> Mapping[str, Any]: "withdrawal_block_height": self.block_height, "withdrawal_destination_addresses": self.destination_addresses, "withdrawal_num_confirmations": self.num_confirmations, - "withdrawal_origin": {"id": self.origin_id}, + "withdrawal_origin": { "id": self.origin_id }, + } + + FRAGMENT = """ fragment WithdrawalFragment on Withdrawal { __typename @@ -118,29 +121,23 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> Withdrawal: return Withdrawal( - requester=requester, - typename="Withdrawal", - id=obj["withdrawal_id"], + requester=requester, typename="Withdrawal", id=obj["withdrawal_id"], created_at=datetime.fromisoformat(obj["withdrawal_created_at"]), updated_at=datetime.fromisoformat(obj["withdrawal_updated_at"]), - status=parse_enum(TransactionStatus, obj["withdrawal_status"]), - resolved_at=( - datetime.fromisoformat(obj["withdrawal_resolved_at"]) - if obj["withdrawal_resolved_at"] - else None - ), + + status=parse_enum(TransactionStatus, obj['withdrawal_status']), + resolved_at=datetime.fromisoformat(obj["withdrawal_resolved_at"]) if obj["withdrawal_resolved_at"] else None, amount=CurrencyAmount_from_json(requester, obj["withdrawal_amount"]), transaction_hash=obj["withdrawal_transaction_hash"], - fees=( - CurrencyAmount_from_json(requester, obj["withdrawal_fees"]) - if obj["withdrawal_fees"] - else None - ), + fees=CurrencyAmount_from_json(requester, obj["withdrawal_fees"]) if obj["withdrawal_fees"] else None, block_hash=obj["withdrawal_block_hash"], block_height=obj["withdrawal_block_height"], destination_addresses=obj["withdrawal_destination_addresses"], num_confirmations=obj["withdrawal_num_confirmations"], origin_id=obj["withdrawal_origin"]["id"], - ) + + ) + diff --git a/lightspark/objects/WithdrawalFeeEstimateInput.py b/lightspark/objects/WithdrawalFeeEstimateInput.py index 24ee7b8..315b731 100644 --- a/lightspark/objects/WithdrawalFeeEstimateInput.py +++ b/lightspark/objects/WithdrawalFeeEstimateInput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -9,7 +10,9 @@ @dataclass -class WithdrawalFeeEstimateInput: +class WithdrawalFeeEstimateInput(): + + node_id: str """The node from which you'd like to make the withdrawal.""" @@ -19,19 +22,27 @@ class WithdrawalFeeEstimateInput: withdrawal_mode: WithdrawalMode """The strategy that should be used to withdraw the funds from this node.""" + + def to_json(self) -> Mapping[str, Any]: return { "withdrawal_fee_estimate_input_node_id": self.node_id, "withdrawal_fee_estimate_input_amount_sats": self.amount_sats, "withdrawal_fee_estimate_input_withdrawal_mode": self.withdrawal_mode.value, + } + + + + def from_json(obj: Mapping[str, Any]) -> WithdrawalFeeEstimateInput: return WithdrawalFeeEstimateInput( node_id=obj["withdrawal_fee_estimate_input_node_id"], amount_sats=obj["withdrawal_fee_estimate_input_amount_sats"], - withdrawal_mode=parse_enum( - WithdrawalMode, obj["withdrawal_fee_estimate_input_withdrawal_mode"] - ), - ) + + withdrawal_mode=parse_enum(WithdrawalMode, obj['withdrawal_fee_estimate_input_withdrawal_mode']), + + ) + diff --git a/lightspark/objects/WithdrawalFeeEstimateOutput.py b/lightspark/objects/WithdrawalFeeEstimateOutput.py index 659bebc..862f6b5 100644 --- a/lightspark/objects/WithdrawalFeeEstimateOutput.py +++ b/lightspark/objects/WithdrawalFeeEstimateOutput.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,18 +11,24 @@ @dataclass -class WithdrawalFeeEstimateOutput: +class WithdrawalFeeEstimateOutput(): + requester: Requester fee_estimate: CurrencyAmount """The estimated fee for the withdrawal.""" + + def to_json(self) -> Mapping[str, Any]: return { "withdrawal_fee_estimate_output_fee_estimate": self.fee_estimate.to_json(), + } + + FRAGMENT = """ fragment WithdrawalFeeEstimateOutputFragment on WithdrawalFeeEstimateOutput { __typename @@ -37,12 +44,10 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> WithdrawalFeeEstimateOutput: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> WithdrawalFeeEstimateOutput: return WithdrawalFeeEstimateOutput( - requester=requester, - fee_estimate=CurrencyAmount_from_json( - requester, obj["withdrawal_fee_estimate_output_fee_estimate"] - ), - ) + requester=requester, fee_estimate=CurrencyAmount_from_json(requester, obj["withdrawal_fee_estimate_output_fee_estimate"]), + + ) + diff --git a/lightspark/objects/WithdrawalMode.py b/lightspark/objects/WithdrawalMode.py index 270e064..032ff57 100644 --- a/lightspark/objects/WithdrawalMode.py +++ b/lightspark/objects/WithdrawalMode.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -10,3 +11,4 @@ class WithdrawalMode(Enum): """This is an enum value that represents future values that could be added in the future. Clients should support unknown values as more of them could be added without notice.""" WALLET_ONLY = "WALLET_ONLY" WALLET_THEN_CHANNELS = "WALLET_THEN_CHANNELS" + diff --git a/lightspark/objects/WithdrawalRequest.py b/lightspark/objects/WithdrawalRequest.py index 71909d0..51ae55b 100644 --- a/lightspark/objects/WithdrawalRequest.py +++ b/lightspark/objects/WithdrawalRequest.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -13,24 +14,20 @@ from .RequestInitiator import RequestInitiator from .WithdrawalMode import WithdrawalMode from .WithdrawalRequestStatus import WithdrawalRequestStatus -from .WithdrawalRequestToChannelClosingTransactionsConnection import ( - WithdrawalRequestToChannelClosingTransactionsConnection, -) -from .WithdrawalRequestToChannelClosingTransactionsConnection import ( - from_json as WithdrawalRequestToChannelClosingTransactionsConnection_from_json, -) -from .WithdrawalRequestToChannelOpeningTransactionsConnection import ( - WithdrawalRequestToChannelOpeningTransactionsConnection, -) -from .WithdrawalRequestToChannelOpeningTransactionsConnection import ( - from_json as WithdrawalRequestToChannelOpeningTransactionsConnection_from_json, -) -from .WithdrawalRequestToWithdrawalsConnection import ( - WithdrawalRequestToWithdrawalsConnection, -) -from .WithdrawalRequestToWithdrawalsConnection import ( - from_json as WithdrawalRequestToWithdrawalsConnection_from_json, -) +from .WithdrawalRequestToChannelClosingTransactionsConnection import \ + WithdrawalRequestToChannelClosingTransactionsConnection +from .WithdrawalRequestToChannelClosingTransactionsConnection import \ + from_json as \ + WithdrawalRequestToChannelClosingTransactionsConnection_from_json +from .WithdrawalRequestToChannelOpeningTransactionsConnection import \ + WithdrawalRequestToChannelOpeningTransactionsConnection +from .WithdrawalRequestToChannelOpeningTransactionsConnection import \ + from_json as \ + WithdrawalRequestToChannelOpeningTransactionsConnection_from_json +from .WithdrawalRequestToWithdrawalsConnection import \ + WithdrawalRequestToWithdrawalsConnection +from .WithdrawalRequestToWithdrawalsConnection import \ + from_json as WithdrawalRequestToWithdrawalsConnection_from_json @dataclass @@ -85,9 +82,7 @@ class WithdrawalRequest(Entity): """The initiator of the withdrawal.""" typename: str - def get_channel_closing_transactions( - self, first: Optional[int] = None, after: Optional[str] = None - ) -> WithdrawalRequestToChannelClosingTransactionsConnection: + def get_channel_closing_transactions(self, first: Optional[int]= None, after: Optional[str]= None) -> WithdrawalRequestToChannelClosingTransactionsConnection: json = self.requester.execute_graphql( """ query FetchWithdrawalRequestToChannelClosingTransactionsConnection($entity_id: ID!, $first: Int, $after: String) { @@ -140,16 +135,12 @@ def get_channel_closing_transactions( } } """, - {"entity_id": self.id, "first": first, "after": after}, + {"entity_id": self.id, "first": first, "after": after} ) connection = json["entity"]["channel_closing_transactions"] - return WithdrawalRequestToChannelClosingTransactionsConnection_from_json( - self.requester, connection - ) + return WithdrawalRequestToChannelClosingTransactionsConnection_from_json(self.requester, connection) - def get_channel_opening_transactions( - self, first: Optional[int] = None, after: Optional[str] = None - ) -> WithdrawalRequestToChannelOpeningTransactionsConnection: + def get_channel_opening_transactions(self, first: Optional[int]= None, after: Optional[str]= None) -> WithdrawalRequestToChannelOpeningTransactionsConnection: json = self.requester.execute_graphql( """ query FetchWithdrawalRequestToChannelOpeningTransactionsConnection($entity_id: ID!, $first: Int, $after: String) { @@ -202,16 +193,12 @@ def get_channel_opening_transactions( } } """, - {"entity_id": self.id, "first": first, "after": after}, + {"entity_id": self.id, "first": first, "after": after} ) connection = json["entity"]["channel_opening_transactions"] - return WithdrawalRequestToChannelOpeningTransactionsConnection_from_json( - self.requester, connection - ) + return WithdrawalRequestToChannelOpeningTransactionsConnection_from_json(self.requester, connection) - def get_withdrawals( - self, first: Optional[int] = None - ) -> WithdrawalRequestToWithdrawalsConnection: + def get_withdrawals(self, first: Optional[int]= None) -> WithdrawalRequestToWithdrawalsConnection: json = self.requester.execute_graphql( """ query FetchWithdrawalRequestToWithdrawalsConnection($entity_id: ID!, $first: Int) { @@ -257,12 +244,11 @@ def get_withdrawals( } } """, - {"entity_id": self.id, "first": first}, + {"entity_id": self.id, "first": first} ) connection = json["entity"]["withdrawals"] - return WithdrawalRequestToWithdrawalsConnection_from_json( - self.requester, connection - ) + return WithdrawalRequestToWithdrawalsConnection_from_json(self.requester, connection) + def to_json(self) -> Mapping[str, Any]: return { @@ -272,29 +258,22 @@ def to_json(self) -> Mapping[str, Any]: "withdrawal_request_updated_at": self.updated_at.isoformat(), "withdrawal_request_requested_amount": self.requested_amount.to_json(), "withdrawal_request_amount": self.amount.to_json(), - "withdrawal_request_estimated_amount": ( - self.estimated_amount.to_json() if self.estimated_amount else None - ), - "withdrawal_request_amount_withdrawn": ( - self.amount_withdrawn.to_json() if self.amount_withdrawn else None - ), - "withdrawal_request_total_fees": ( - self.total_fees.to_json() if self.total_fees else None - ), + "withdrawal_request_estimated_amount": self.estimated_amount.to_json() if self.estimated_amount else None, + "withdrawal_request_amount_withdrawn": self.amount_withdrawn.to_json() if self.amount_withdrawn else None, + "withdrawal_request_total_fees": self.total_fees.to_json() if self.total_fees else None, "withdrawal_request_bitcoin_address": self.bitcoin_address, "withdrawal_request_withdrawal_mode": self.withdrawal_mode.value, "withdrawal_request_status": self.status.value, - "withdrawal_request_completed_at": ( - self.completed_at.isoformat() if self.completed_at else None - ), - "withdrawal_request_withdrawal": ( - {"id": self.withdrawal_id} if self.withdrawal_id else None - ), + "withdrawal_request_completed_at": self.completed_at.isoformat() if self.completed_at else None, + "withdrawal_request_withdrawal": { "id": self.withdrawal_id } if self.withdrawal_id else None, "withdrawal_request_idempotency_key": self.idempotency_key, "withdrawal_request_initiator": self.initiator.value, + } + + FRAGMENT = """ fragment WithdrawalRequestFragment on WithdrawalRequest { __typename @@ -354,51 +333,27 @@ def to_json(self) -> Mapping[str, Any]: """ + def from_json(requester: Requester, obj: Mapping[str, Any]) -> WithdrawalRequest: return WithdrawalRequest( - requester=requester, - typename="WithdrawalRequest", - id=obj["withdrawal_request_id"], + requester=requester, typename="WithdrawalRequest", id=obj["withdrawal_request_id"], created_at=datetime.fromisoformat(obj["withdrawal_request_created_at"]), updated_at=datetime.fromisoformat(obj["withdrawal_request_updated_at"]), - requested_amount=CurrencyAmount_from_json( - requester, obj["withdrawal_request_requested_amount"] - ), + requested_amount=CurrencyAmount_from_json(requester, obj["withdrawal_request_requested_amount"]), amount=CurrencyAmount_from_json(requester, obj["withdrawal_request_amount"]), - estimated_amount=( - CurrencyAmount_from_json( - requester, obj["withdrawal_request_estimated_amount"] - ) - if obj["withdrawal_request_estimated_amount"] - else None - ), - amount_withdrawn=( - CurrencyAmount_from_json( - requester, obj["withdrawal_request_amount_withdrawn"] - ) - if obj["withdrawal_request_amount_withdrawn"] - else None - ), - total_fees=( - CurrencyAmount_from_json(requester, obj["withdrawal_request_total_fees"]) - if obj["withdrawal_request_total_fees"] - else None - ), + estimated_amount=CurrencyAmount_from_json(requester, obj["withdrawal_request_estimated_amount"]) if obj["withdrawal_request_estimated_amount"] else None, + amount_withdrawn=CurrencyAmount_from_json(requester, obj["withdrawal_request_amount_withdrawn"]) if obj["withdrawal_request_amount_withdrawn"] else None, + total_fees=CurrencyAmount_from_json(requester, obj["withdrawal_request_total_fees"]) if obj["withdrawal_request_total_fees"] else None, bitcoin_address=obj["withdrawal_request_bitcoin_address"], - withdrawal_mode=parse_enum( - WithdrawalMode, obj["withdrawal_request_withdrawal_mode"] - ), - status=parse_enum(WithdrawalRequestStatus, obj["withdrawal_request_status"]), - completed_at=( - datetime.fromisoformat(obj["withdrawal_request_completed_at"]) - if obj["withdrawal_request_completed_at"] - else None - ), - withdrawal_id=( - obj["withdrawal_request_withdrawal"]["id"] - if obj["withdrawal_request_withdrawal"] - else None - ), + + withdrawal_mode=parse_enum(WithdrawalMode, obj['withdrawal_request_withdrawal_mode']), + + status=parse_enum(WithdrawalRequestStatus, obj['withdrawal_request_status']), + completed_at=datetime.fromisoformat(obj["withdrawal_request_completed_at"]) if obj["withdrawal_request_completed_at"] else None, + withdrawal_id=obj["withdrawal_request_withdrawal"]["id"] if obj["withdrawal_request_withdrawal"] else None, idempotency_key=obj["withdrawal_request_idempotency_key"], - initiator=parse_enum(RequestInitiator, obj["withdrawal_request_initiator"]), - ) + + initiator=parse_enum(RequestInitiator, obj['withdrawal_request_initiator']), + + ) + diff --git a/lightspark/objects/WithdrawalRequestStatus.py b/lightspark/objects/WithdrawalRequestStatus.py index 874212e..0386579 100644 --- a/lightspark/objects/WithdrawalRequestStatus.py +++ b/lightspark/objects/WithdrawalRequestStatus.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from enum import Enum @@ -14,3 +15,4 @@ class WithdrawalRequestStatus(Enum): IN_PROGRESS = "IN_PROGRESS" SUCCESSFUL = "SUCCESSFUL" PARTIALLY_SUCCESSFUL = "PARTIALLY_SUCCESSFUL" + diff --git a/lightspark/objects/WithdrawalRequestToChannelClosingTransactionsConnection.py b/lightspark/objects/WithdrawalRequestToChannelClosingTransactionsConnection.py index 07ba02a..c98ffd7 100644 --- a/lightspark/objects/WithdrawalRequestToChannelClosingTransactionsConnection.py +++ b/lightspark/objects/WithdrawalRequestToChannelClosingTransactionsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -6,7 +7,8 @@ from lightspark.requests.requester import Requester from .ChannelClosingTransaction import ChannelClosingTransaction -from .ChannelClosingTransaction import from_json as ChannelClosingTransaction_from_json +from .ChannelClosingTransaction import \ + from_json as ChannelClosingTransaction_from_json from .Connection import Connection from .PageInfo import PageInfo from .PageInfo import from_json as PageInfo_from_json @@ -14,6 +16,7 @@ @dataclass class WithdrawalRequestToChannelClosingTransactionsConnection(Connection): + requester: Requester count: int @@ -26,17 +29,19 @@ class WithdrawalRequestToChannelClosingTransactionsConnection(Connection): """The channel closing transactions for the current page of this connection.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "WithdrawalRequestToChannelClosingTransactionsConnection", "withdrawal_request_to_channel_closing_transactions_connection_count": self.count, "withdrawal_request_to_channel_closing_transactions_connection_page_info": self.page_info.to_json(), - "withdrawal_request_to_channel_closing_transactions_connection_entities": [ - e.to_json() for e in self.entities - ], + "withdrawal_request_to_channel_closing_transactions_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment WithdrawalRequestToChannelClosingTransactionsConnectionFragment on WithdrawalRequestToChannelClosingTransactionsConnection { __typename @@ -55,28 +60,14 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> WithdrawalRequestToChannelClosingTransactionsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> WithdrawalRequestToChannelClosingTransactionsConnection: return WithdrawalRequestToChannelClosingTransactionsConnection( - requester=requester, - typename="WithdrawalRequestToChannelClosingTransactionsConnection", - count=obj[ - "withdrawal_request_to_channel_closing_transactions_connection_count" - ], - page_info=PageInfo_from_json( - requester, - obj[ - "withdrawal_request_to_channel_closing_transactions_connection_page_info" - ], - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: ChannelClosingTransaction_from_json(requester, e), - obj[ - "withdrawal_request_to_channel_closing_transactions_connection_entities" - ], - ) - ), - ) + requester=requester, typename="WithdrawalRequestToChannelClosingTransactionsConnection", count=obj["withdrawal_request_to_channel_closing_transactions_connection_count"], + page_info=PageInfo_from_json(requester, obj["withdrawal_request_to_channel_closing_transactions_connection_page_info"]), + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: ChannelClosingTransaction_from_json(requester, e), obj["withdrawal_request_to_channel_closing_transactions_connection_entities"])), + + ) + diff --git a/lightspark/objects/WithdrawalRequestToChannelOpeningTransactionsConnection.py b/lightspark/objects/WithdrawalRequestToChannelOpeningTransactionsConnection.py index a68e1b4..c654ba1 100644 --- a/lightspark/objects/WithdrawalRequestToChannelOpeningTransactionsConnection.py +++ b/lightspark/objects/WithdrawalRequestToChannelOpeningTransactionsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -6,7 +7,8 @@ from lightspark.requests.requester import Requester from .ChannelOpeningTransaction import ChannelOpeningTransaction -from .ChannelOpeningTransaction import from_json as ChannelOpeningTransaction_from_json +from .ChannelOpeningTransaction import \ + from_json as ChannelOpeningTransaction_from_json from .Connection import Connection from .PageInfo import PageInfo from .PageInfo import from_json as PageInfo_from_json @@ -14,6 +16,7 @@ @dataclass class WithdrawalRequestToChannelOpeningTransactionsConnection(Connection): + requester: Requester count: int @@ -26,17 +29,19 @@ class WithdrawalRequestToChannelOpeningTransactionsConnection(Connection): """The channel opening transactions for the current page of this connection.""" typename: str + def to_json(self) -> Mapping[str, Any]: return { "__typename": "WithdrawalRequestToChannelOpeningTransactionsConnection", "withdrawal_request_to_channel_opening_transactions_connection_count": self.count, "withdrawal_request_to_channel_opening_transactions_connection_page_info": self.page_info.to_json(), - "withdrawal_request_to_channel_opening_transactions_connection_entities": [ - e.to_json() for e in self.entities - ], + "withdrawal_request_to_channel_opening_transactions_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment WithdrawalRequestToChannelOpeningTransactionsConnectionFragment on WithdrawalRequestToChannelOpeningTransactionsConnection { __typename @@ -55,28 +60,14 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> WithdrawalRequestToChannelOpeningTransactionsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> WithdrawalRequestToChannelOpeningTransactionsConnection: return WithdrawalRequestToChannelOpeningTransactionsConnection( - requester=requester, - typename="WithdrawalRequestToChannelOpeningTransactionsConnection", - count=obj[ - "withdrawal_request_to_channel_opening_transactions_connection_count" - ], - page_info=PageInfo_from_json( - requester, - obj[ - "withdrawal_request_to_channel_opening_transactions_connection_page_info" - ], - ), - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: ChannelOpeningTransaction_from_json(requester, e), - obj[ - "withdrawal_request_to_channel_opening_transactions_connection_entities" - ], - ) - ), - ) + requester=requester, typename="WithdrawalRequestToChannelOpeningTransactionsConnection", count=obj["withdrawal_request_to_channel_opening_transactions_connection_count"], + page_info=PageInfo_from_json(requester, obj["withdrawal_request_to_channel_opening_transactions_connection_page_info"]), + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: ChannelOpeningTransaction_from_json(requester, e), obj["withdrawal_request_to_channel_opening_transactions_connection_entities"])), + + ) + diff --git a/lightspark/objects/WithdrawalRequestToWithdrawalsConnection.py b/lightspark/objects/WithdrawalRequestToWithdrawalsConnection.py index 6f2844f..f1e8824 100644 --- a/lightspark/objects/WithdrawalRequestToWithdrawalsConnection.py +++ b/lightspark/objects/WithdrawalRequestToWithdrawalsConnection.py @@ -1,3 +1,4 @@ + # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved from dataclasses import dataclass @@ -10,7 +11,8 @@ @dataclass -class WithdrawalRequestToWithdrawalsConnection: +class WithdrawalRequestToWithdrawalsConnection(): + requester: Requester count: int @@ -19,15 +21,18 @@ class WithdrawalRequestToWithdrawalsConnection: entities: List[Withdrawal] """The withdrawals for the current page of this connection.""" + + def to_json(self) -> Mapping[str, Any]: return { "withdrawal_request_to_withdrawals_connection_count": self.count, - "withdrawal_request_to_withdrawals_connection_entities": [ - e.to_json() for e in self.entities - ], + "withdrawal_request_to_withdrawals_connection_entities": [e.to_json() for e in self.entities], + } + + FRAGMENT = """ fragment WithdrawalRequestToWithdrawalsConnectionFragment on WithdrawalRequestToWithdrawalsConnection { __typename @@ -39,17 +44,13 @@ def to_json(self) -> Mapping[str, Any]: """ -def from_json( - requester: Requester, obj: Mapping[str, Any] -) -> WithdrawalRequestToWithdrawalsConnection: + +def from_json(requester: Requester, obj: Mapping[str, Any]) -> WithdrawalRequestToWithdrawalsConnection: return WithdrawalRequestToWithdrawalsConnection( - requester=requester, - count=obj["withdrawal_request_to_withdrawals_connection_count"], - entities=list( - map( - # pylint: disable=unnecessary-lambda - lambda e: Withdrawal_from_json(requester, e), - obj["withdrawal_request_to_withdrawals_connection_entities"], - ) - ), - ) + requester=requester, count=obj["withdrawal_request_to_withdrawals_connection_count"], + entities=list(map( + # pylint: disable=unnecessary-lambda + lambda e: Withdrawal_from_json(requester, e), obj["withdrawal_request_to_withdrawals_connection_entities"])), + + ) + diff --git a/lightspark/objects/__init__.py b/lightspark/objects/__init__.py index 4d95f8f..0771aa8 100644 --- a/lightspark/objects/__init__.py +++ b/lightspark/objects/__init__.py @@ -1 +1,2 @@ # Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved + diff --git a/lightspark/objects/all_entities.py b/lightspark/objects/all_entities.py index cda88db..51125cb 100644 --- a/lightspark/objects/all_entities.py +++ b/lightspark/objects/all_entities.py @@ -10,27 +10,28 @@ from lightspark.objects.ApiToken import from_json as ApiToken_from_json from lightspark.objects.AuditLogActor import FRAGMENT as AuditLogActorFragment from lightspark.objects.AuditLogActor import AuditLogActor -from lightspark.objects.AuditLogActor import from_json as AuditLogActor_from_json +from lightspark.objects.AuditLogActor import \ + from_json as AuditLogActor_from_json from lightspark.objects.Channel import FRAGMENT as ChannelFragment from lightspark.objects.Channel import Channel from lightspark.objects.Channel import from_json as Channel_from_json -from lightspark.objects.ChannelClosingTransaction import ( - FRAGMENT as ChannelClosingTransactionFragment, -) -from lightspark.objects.ChannelClosingTransaction import ChannelClosingTransaction -from lightspark.objects.ChannelClosingTransaction import ( - from_json as ChannelClosingTransaction_from_json, -) -from lightspark.objects.ChannelOpeningTransaction import ( - FRAGMENT as ChannelOpeningTransactionFragment, -) -from lightspark.objects.ChannelOpeningTransaction import ChannelOpeningTransaction -from lightspark.objects.ChannelOpeningTransaction import ( - from_json as ChannelOpeningTransaction_from_json, -) -from lightspark.objects.ChannelSnapshot import FRAGMENT as ChannelSnapshotFragment +from lightspark.objects.ChannelClosingTransaction import \ + FRAGMENT as ChannelClosingTransactionFragment +from lightspark.objects.ChannelClosingTransaction import \ + ChannelClosingTransaction +from lightspark.objects.ChannelClosingTransaction import \ + from_json as ChannelClosingTransaction_from_json +from lightspark.objects.ChannelOpeningTransaction import \ + FRAGMENT as ChannelOpeningTransactionFragment +from lightspark.objects.ChannelOpeningTransaction import \ + ChannelOpeningTransaction +from lightspark.objects.ChannelOpeningTransaction import \ + from_json as ChannelOpeningTransaction_from_json +from lightspark.objects.ChannelSnapshot import \ + FRAGMENT as ChannelSnapshotFragment from lightspark.objects.ChannelSnapshot import ChannelSnapshot -from lightspark.objects.ChannelSnapshot import from_json as ChannelSnapshot_from_json +from lightspark.objects.ChannelSnapshot import \ + from_json as ChannelSnapshot_from_json from lightspark.objects.Deposit import FRAGMENT as DepositFragment from lightspark.objects.Deposit import Deposit from lightspark.objects.Deposit import from_json as Deposit_from_json @@ -42,101 +43,105 @@ from lightspark.objects.Hop import FRAGMENT as HopFragment from lightspark.objects.Hop import Hop from lightspark.objects.Hop import from_json as Hop_from_json -from lightspark.objects.IncomingPayment import FRAGMENT as IncomingPaymentFragment +from lightspark.objects.IncomingPayment import \ + FRAGMENT as IncomingPaymentFragment from lightspark.objects.IncomingPayment import IncomingPayment -from lightspark.objects.IncomingPayment import from_json as IncomingPayment_from_json -from lightspark.objects.IncomingPaymentAttempt import ( - FRAGMENT as IncomingPaymentAttemptFragment, -) +from lightspark.objects.IncomingPayment import \ + from_json as IncomingPayment_from_json +from lightspark.objects.IncomingPaymentAttempt import \ + FRAGMENT as IncomingPaymentAttemptFragment from lightspark.objects.IncomingPaymentAttempt import IncomingPaymentAttempt -from lightspark.objects.IncomingPaymentAttempt import ( - from_json as IncomingPaymentAttempt_from_json, -) +from lightspark.objects.IncomingPaymentAttempt import \ + from_json as IncomingPaymentAttempt_from_json from lightspark.objects.Invoice import FRAGMENT as InvoiceFragment from lightspark.objects.Invoice import Invoice from lightspark.objects.Invoice import from_json as Invoice_from_json -from lightspark.objects.LightningTransaction import ( - FRAGMENT as LightningTransactionFragment, -) +from lightspark.objects.LightningTransaction import \ + FRAGMENT as LightningTransactionFragment from lightspark.objects.LightningTransaction import LightningTransaction -from lightspark.objects.LightningTransaction import ( - from_json as LightningTransaction_from_json, -) -from lightspark.objects.LightsparkNode import FRAGMENT as LightsparkNodeFragment +from lightspark.objects.LightningTransaction import \ + from_json as LightningTransaction_from_json +from lightspark.objects.LightsparkNode import \ + FRAGMENT as LightsparkNodeFragment from lightspark.objects.LightsparkNode import LightsparkNode -from lightspark.objects.LightsparkNode import from_json as LightsparkNode_from_json -from lightspark.objects.LightsparkNodeOwner import ( - FRAGMENT as LightsparkNodeOwnerFragment, -) +from lightspark.objects.LightsparkNode import \ + from_json as LightsparkNode_from_json +from lightspark.objects.LightsparkNodeOwner import \ + FRAGMENT as LightsparkNodeOwnerFragment from lightspark.objects.LightsparkNodeOwner import LightsparkNodeOwner -from lightspark.objects.LightsparkNodeOwner import ( - from_json as LightsparkNodeOwner_from_json, -) -from lightspark.objects.LightsparkNodeWithOSK import ( - FRAGMENT as LightsparkNodeWithOSKFragment, -) +from lightspark.objects.LightsparkNodeOwner import \ + from_json as LightsparkNodeOwner_from_json +from lightspark.objects.LightsparkNodeWithOSK import \ + FRAGMENT as LightsparkNodeWithOSKFragment from lightspark.objects.LightsparkNodeWithOSK import LightsparkNodeWithOSK -from lightspark.objects.LightsparkNodeWithOSK import ( - from_json as LightsparkNodeWithOSK_from_json, -) -from lightspark.objects.LightsparkNodeWithRemoteSigning import ( - FRAGMENT as LightsparkNodeWithRemoteSigningFragment, -) -from lightspark.objects.LightsparkNodeWithRemoteSigning import ( - LightsparkNodeWithRemoteSigning, -) -from lightspark.objects.LightsparkNodeWithRemoteSigning import ( - from_json as LightsparkNodeWithRemoteSigning_from_json, -) +from lightspark.objects.LightsparkNodeWithOSK import \ + from_json as LightsparkNodeWithOSK_from_json +from lightspark.objects.LightsparkNodeWithRemoteSigning import \ + FRAGMENT as LightsparkNodeWithRemoteSigningFragment +from lightspark.objects.LightsparkNodeWithRemoteSigning import \ + LightsparkNodeWithRemoteSigning +from lightspark.objects.LightsparkNodeWithRemoteSigning import \ + from_json as LightsparkNodeWithRemoteSigning_from_json from lightspark.objects.Node import FRAGMENT as NodeFragment from lightspark.objects.Node import Node from lightspark.objects.Node import from_json as Node_from_json -from lightspark.objects.OnChainTransaction import FRAGMENT as OnChainTransactionFragment +from lightspark.objects.Offer import FRAGMENT as OfferFragment +from lightspark.objects.Offer import Offer +from lightspark.objects.Offer import from_json as Offer_from_json +from lightspark.objects.OfferData import FRAGMENT as OfferDataFragment +from lightspark.objects.OfferData import OfferData +from lightspark.objects.OfferData import from_json as OfferData_from_json +from lightspark.objects.OnChainTransaction import \ + FRAGMENT as OnChainTransactionFragment from lightspark.objects.OnChainTransaction import OnChainTransaction -from lightspark.objects.OnChainTransaction import ( - from_json as OnChainTransaction_from_json, -) -from lightspark.objects.OutgoingPayment import FRAGMENT as OutgoingPaymentFragment +from lightspark.objects.OnChainTransaction import \ + from_json as OnChainTransaction_from_json +from lightspark.objects.OutgoingPayment import \ + FRAGMENT as OutgoingPaymentFragment from lightspark.objects.OutgoingPayment import OutgoingPayment -from lightspark.objects.OutgoingPayment import from_json as OutgoingPayment_from_json -from lightspark.objects.OutgoingPaymentAttempt import ( - FRAGMENT as OutgoingPaymentAttemptFragment, -) +from lightspark.objects.OutgoingPayment import \ + from_json as OutgoingPayment_from_json +from lightspark.objects.OutgoingPaymentAttempt import \ + FRAGMENT as OutgoingPaymentAttemptFragment from lightspark.objects.OutgoingPaymentAttempt import OutgoingPaymentAttempt -from lightspark.objects.OutgoingPaymentAttempt import ( - from_json as OutgoingPaymentAttempt_from_json, -) -from lightspark.objects.PaymentRequest import FRAGMENT as PaymentRequestFragment +from lightspark.objects.OutgoingPaymentAttempt import \ + from_json as OutgoingPaymentAttempt_from_json +from lightspark.objects.PaymentRequest import \ + FRAGMENT as PaymentRequestFragment from lightspark.objects.PaymentRequest import PaymentRequest -from lightspark.objects.PaymentRequest import from_json as PaymentRequest_from_json -from lightspark.objects.RoutingTransaction import FRAGMENT as RoutingTransactionFragment +from lightspark.objects.PaymentRequest import \ + from_json as PaymentRequest_from_json +from lightspark.objects.RoutingTransaction import \ + FRAGMENT as RoutingTransactionFragment from lightspark.objects.RoutingTransaction import RoutingTransaction -from lightspark.objects.RoutingTransaction import ( - from_json as RoutingTransaction_from_json, -) +from lightspark.objects.RoutingTransaction import \ + from_json as RoutingTransaction_from_json from lightspark.objects.Signable import FRAGMENT as SignableFragment from lightspark.objects.Signable import Signable from lightspark.objects.Signable import from_json as Signable_from_json -from lightspark.objects.SignablePayload import FRAGMENT as SignablePayloadFragment +from lightspark.objects.SignablePayload import \ + FRAGMENT as SignablePayloadFragment from lightspark.objects.SignablePayload import SignablePayload -from lightspark.objects.SignablePayload import from_json as SignablePayload_from_json +from lightspark.objects.SignablePayload import \ + from_json as SignablePayload_from_json from lightspark.objects.Transaction import FRAGMENT as TransactionFragment from lightspark.objects.Transaction import Transaction from lightspark.objects.Transaction import from_json as Transaction_from_json from lightspark.objects.UmaInvitation import FRAGMENT as UmaInvitationFragment from lightspark.objects.UmaInvitation import UmaInvitation -from lightspark.objects.UmaInvitation import from_json as UmaInvitation_from_json +from lightspark.objects.UmaInvitation import \ + from_json as UmaInvitation_from_json from lightspark.objects.Wallet import FRAGMENT as WalletFragment from lightspark.objects.Wallet import Wallet from lightspark.objects.Wallet import from_json as Wallet_from_json from lightspark.objects.Withdrawal import FRAGMENT as WithdrawalFragment from lightspark.objects.Withdrawal import Withdrawal from lightspark.objects.Withdrawal import from_json as Withdrawal_from_json -from lightspark.objects.WithdrawalRequest import FRAGMENT as WithdrawalRequestFragment +from lightspark.objects.WithdrawalRequest import \ + FRAGMENT as WithdrawalRequestFragment from lightspark.objects.WithdrawalRequest import WithdrawalRequest -from lightspark.objects.WithdrawalRequest import ( - from_json as WithdrawalRequest_from_json, -) +from lightspark.objects.WithdrawalRequest import \ + from_json as WithdrawalRequest_from_json from lightspark.requests.requester import Requester ENTITY = TypeVar("ENTITY", bound=Entity) @@ -221,6 +226,14 @@ Node: """ ... on Node { ...NodeFragment } +""", + Offer: """ ... on Offer { + ...OfferFragment + } +""", + OfferData: """ ... on OfferData { + ...OfferDataFragment + } """, OnChainTransaction: """ ... on OnChainTransaction { ...OnChainTransactionFragment @@ -272,77 +285,78 @@ """, } ALL_FRAGMENTS: Mapping[Type, str] = { - Account: AccountFragment, - ApiToken: ApiTokenFragment, - AuditLogActor: AuditLogActorFragment, - Channel: ChannelFragment, - ChannelClosingTransaction: ChannelClosingTransactionFragment, - ChannelOpeningTransaction: ChannelOpeningTransactionFragment, - ChannelSnapshot: ChannelSnapshotFragment, - Deposit: DepositFragment, - Entity: EntityFragment, - GraphNode: GraphNodeFragment, - Hop: HopFragment, - IncomingPayment: IncomingPaymentFragment, - IncomingPaymentAttempt: IncomingPaymentAttemptFragment, - Invoice: InvoiceFragment, - LightningTransaction: LightningTransactionFragment, - LightsparkNode: LightsparkNodeFragment, - LightsparkNodeOwner: LightsparkNodeOwnerFragment, - LightsparkNodeWithOSK: LightsparkNodeWithOSKFragment, - LightsparkNodeWithRemoteSigning: LightsparkNodeWithRemoteSigningFragment, - Node: NodeFragment, - OnChainTransaction: OnChainTransactionFragment, - OutgoingPayment: OutgoingPaymentFragment, - OutgoingPaymentAttempt: OutgoingPaymentAttemptFragment, - PaymentRequest: PaymentRequestFragment, - RoutingTransaction: RoutingTransactionFragment, - Signable: SignableFragment, - SignablePayload: SignablePayloadFragment, - Transaction: TransactionFragment, - UmaInvitation: UmaInvitationFragment, - Wallet: WalletFragment, - Withdrawal: WithdrawalFragment, - WithdrawalRequest: WithdrawalRequestFragment, + Account: AccountFragment, + ApiToken: ApiTokenFragment, + AuditLogActor: AuditLogActorFragment, + Channel: ChannelFragment, + ChannelClosingTransaction: ChannelClosingTransactionFragment, + ChannelOpeningTransaction: ChannelOpeningTransactionFragment, + ChannelSnapshot: ChannelSnapshotFragment, + Deposit: DepositFragment, + Entity: EntityFragment, + GraphNode: GraphNodeFragment, + Hop: HopFragment, + IncomingPayment: IncomingPaymentFragment, + IncomingPaymentAttempt: IncomingPaymentAttemptFragment, + Invoice: InvoiceFragment, + LightningTransaction: LightningTransactionFragment, + LightsparkNode: LightsparkNodeFragment, + LightsparkNodeOwner: LightsparkNodeOwnerFragment, + LightsparkNodeWithOSK: LightsparkNodeWithOSKFragment, + LightsparkNodeWithRemoteSigning: LightsparkNodeWithRemoteSigningFragment, + Node: NodeFragment, + Offer: OfferFragment, + OfferData: OfferDataFragment, + OnChainTransaction: OnChainTransactionFragment, + OutgoingPayment: OutgoingPaymentFragment, + OutgoingPaymentAttempt: OutgoingPaymentAttemptFragment, + PaymentRequest: PaymentRequestFragment, + RoutingTransaction: RoutingTransactionFragment, + Signable: SignableFragment, + SignablePayload: SignablePayloadFragment, + Transaction: TransactionFragment, + UmaInvitation: UmaInvitationFragment, + Wallet: WalletFragment, + Withdrawal: WithdrawalFragment, + WithdrawalRequest: WithdrawalRequestFragment, } ALL_JSON_LOADERS: Mapping[Type, Callable] = { - Account: Account_from_json, - ApiToken: ApiToken_from_json, - AuditLogActor: AuditLogActor_from_json, - Channel: Channel_from_json, - ChannelClosingTransaction: ChannelClosingTransaction_from_json, - ChannelOpeningTransaction: ChannelOpeningTransaction_from_json, - ChannelSnapshot: ChannelSnapshot_from_json, - Deposit: Deposit_from_json, - GraphNode: GraphNode_from_json, - Hop: Hop_from_json, - IncomingPayment: IncomingPayment_from_json, - IncomingPaymentAttempt: IncomingPaymentAttempt_from_json, - Invoice: Invoice_from_json, - LightningTransaction: LightningTransaction_from_json, - LightsparkNode: LightsparkNode_from_json, - LightsparkNodeOwner: LightsparkNodeOwner_from_json, - LightsparkNodeWithOSK: LightsparkNodeWithOSK_from_json, - LightsparkNodeWithRemoteSigning: LightsparkNodeWithRemoteSigning_from_json, - Node: Node_from_json, - OnChainTransaction: OnChainTransaction_from_json, - OutgoingPayment: OutgoingPayment_from_json, - OutgoingPaymentAttempt: OutgoingPaymentAttempt_from_json, - PaymentRequest: PaymentRequest_from_json, - RoutingTransaction: RoutingTransaction_from_json, - Signable: Signable_from_json, - SignablePayload: SignablePayload_from_json, - Transaction: Transaction_from_json, - UmaInvitation: UmaInvitation_from_json, - Wallet: Wallet_from_json, - Withdrawal: Withdrawal_from_json, - WithdrawalRequest: WithdrawalRequest_from_json, + Account: Account_from_json, + ApiToken: ApiToken_from_json, + AuditLogActor: AuditLogActor_from_json, + Channel: Channel_from_json, + ChannelClosingTransaction: ChannelClosingTransaction_from_json, + ChannelOpeningTransaction: ChannelOpeningTransaction_from_json, + ChannelSnapshot: ChannelSnapshot_from_json, + Deposit: Deposit_from_json, + GraphNode: GraphNode_from_json, + Hop: Hop_from_json, + IncomingPayment: IncomingPayment_from_json, + IncomingPaymentAttempt: IncomingPaymentAttempt_from_json, + Invoice: Invoice_from_json, + LightningTransaction: LightningTransaction_from_json, + LightsparkNode: LightsparkNode_from_json, + LightsparkNodeOwner: LightsparkNodeOwner_from_json, + LightsparkNodeWithOSK: LightsparkNodeWithOSK_from_json, + LightsparkNodeWithRemoteSigning: LightsparkNodeWithRemoteSigning_from_json, + Node: Node_from_json, + Offer: Offer_from_json, + OfferData: OfferData_from_json, + OnChainTransaction: OnChainTransaction_from_json, + OutgoingPayment: OutgoingPayment_from_json, + OutgoingPaymentAttempt: OutgoingPaymentAttempt_from_json, + PaymentRequest: PaymentRequest_from_json, + RoutingTransaction: RoutingTransaction_from_json, + Signable: Signable_from_json, + SignablePayload: SignablePayload_from_json, + Transaction: Transaction_from_json, + UmaInvitation: UmaInvitation_from_json, + Wallet: Wallet_from_json, + Withdrawal: Withdrawal_from_json, + WithdrawalRequest: WithdrawalRequest_from_json, } - -def get_entity( - requester: Requester, entity_id: str, entity_class: Type[ENTITY] -) -> Optional[ENTITY]: +def get_entity(requester: Requester, entity_id: str, entity_class: Type[ENTITY]) -> Optional[ENTITY]: json = requester.execute_graphql( f""" query GetEntity($id: ID!) {{