-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
459 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved | ||
|
||
from dataclasses import dataclass | ||
from datetime import datetime | ||
from typing import Any, Mapping | ||
|
||
from lightspark.objects.LightningPaymentDirection import LightningPaymentDirection | ||
from lightspark.requests.requester import Requester | ||
from lightspark.utils.enums import parse_enum | ||
|
||
from .CurrencyAmount import CurrencyAmount | ||
from .CurrencyAmount import from_json as CurrencyAmount_from_json | ||
from .LightningPaymentDirection import LightningPaymentDirection | ||
|
||
|
||
@dataclass | ||
class DailyLiquidityForecast: | ||
requester: Requester | ||
|
||
date: datetime | ||
"""The date for which this forecast was generated.""" | ||
|
||
direction: LightningPaymentDirection | ||
"""The direction for which this forecast was generated.""" | ||
|
||
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 | ||
daily_liquidity_forecast_date: date | ||
daily_liquidity_forecast_direction: direction | ||
daily_liquidity_forecast_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 | ||
} | ||
} | ||
""" | ||
|
||
|
||
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"] | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved | ||
|
||
from enum import Enum | ||
|
||
|
||
class LightningPaymentDirection(Enum): | ||
"""This is an enum identifying the payment direction.""" | ||
|
||
___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.""" | ||
INCOMING = "INCOMING" | ||
"""A payment that is received by the node.""" | ||
OUTGOING = "OUTGOING" | ||
"""A payment that is sent by the node.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
lightspark/objects/LightsparkNodeToDailyLiquidityForecastsConnection.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved | ||
|
||
from dataclasses import dataclass | ||
from datetime import datetime | ||
from typing import Any, List, Mapping | ||
|
||
from lightspark.objects.LightningPaymentDirection import LightningPaymentDirection | ||
from lightspark.requests.requester import Requester | ||
from lightspark.utils.enums import parse_enum | ||
|
||
from .DailyLiquidityForecast import DailyLiquidityForecast | ||
from .DailyLiquidityForecast import from_json as DailyLiquidityForecast_from_json | ||
from .LightningPaymentDirection import LightningPaymentDirection | ||
|
||
|
||
@dataclass | ||
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 | ||
], | ||
} | ||
|
||
|
||
FRAGMENT = """ | ||
fragment LightsparkNodeToDailyLiquidityForecastsConnectionFragment on LightsparkNodeToDailyLiquidityForecastsConnection { | ||
__typename | ||
lightspark_node_to_daily_liquidity_forecasts_connection_from_date: from_date | ||
lightspark_node_to_daily_liquidity_forecasts_connection_to_date: to_date | ||
lightspark_node_to_daily_liquidity_forecasts_connection_direction: direction | ||
lightspark_node_to_daily_liquidity_forecasts_connection_entities: entities { | ||
__typename | ||
daily_liquidity_forecast_date: date | ||
daily_liquidity_forecast_direction: direction | ||
daily_liquidity_forecast_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 | ||
} | ||
} | ||
} | ||
""" | ||
|
||
|
||
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" | ||
], | ||
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"], | ||
) | ||
), | ||
) |
Oops, something went wrong.