-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add classes necessary for range method of PriceInfo
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,58 @@ | ||
from __future__ import annotations | ||
|
||
"""A class representing the SubscriptionPriceConnectionPageInfo type from the GraphQL Tibber API.""" | ||
from typing import TYPE_CHECKING | ||
|
||
|
||
class SubscriptionPriceConnectionPageInfo: | ||
def __init__(self, data: dict, tibber_client: "Account"): | ||
self.cache: dict = data or {} | ||
self.tibber_client: "Account" = tibber_client | ||
|
||
@property | ||
def end_cursor(self) -> str: | ||
return self.cache.get("endCursor") | ||
|
||
@property | ||
def has_next_page(self) -> bool: | ||
return self.cache.get("hasNextPage") | ||
|
||
@property | ||
def has_previous_page(self) -> bool: | ||
return self.cache.get("hasPreviousPage") | ||
|
||
@property | ||
def start_cursor(self) -> str: | ||
return self.cache.get("startCursor") | ||
|
||
@property | ||
def resolution(self) -> str: | ||
return self.cache.get("resolution") | ||
|
||
@property | ||
def currency(self) -> str: | ||
return self.cache.get("currency") | ||
|
||
@property | ||
def count(self) -> int: | ||
return self.cache.get("count") | ||
|
||
@property | ||
def precision(self) -> int: | ||
return self.cache.get("precision") | ||
|
||
@property | ||
def min_energy(self) -> float: | ||
return self.cache.get("minEnergy") | ||
|
||
@property | ||
def min_total(self) -> float: | ||
return self.cache.get("minTotal") | ||
|
||
@property | ||
def max_energy(self) -> float: | ||
return self.cache.get("maxEnergy") | ||
|
||
@property | ||
def max_total(self) -> float: | ||
return self.cache.get("maxTotal") |
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,20 @@ | ||
from __future__ import annotations | ||
|
||
"""A class representing the SubscriptionPriceEdge type from the GraphQL Tibber API.""" | ||
from typing import TYPE_CHECKING | ||
|
||
from tibber.types.price import Price | ||
|
||
|
||
class SubscriptionPriceEdge: | ||
def __init__(self, data: dict, tibber_client: "Account"): | ||
self.cache: dict = data or {} | ||
self.tibber_client: "Account" = tibber_client | ||
|
||
@property | ||
def cursor(self) -> str: | ||
return self.cache.get("cursor") | ||
|
||
@property | ||
def node(self) -> Price: | ||
return Price(self.cache.get("node"), self.tibber_client) |