Skip to content

Commit eeb1809

Browse files
committed
feat: add classes necessary for range method of PriceInfo
1 parent 79f532c commit eeb1809

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

tibber/types/subscription_price_connection.py

Whitespace-only changes.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
from __future__ import annotations
2+
3+
"""A class representing the SubscriptionPriceConnectionPageInfo type from the GraphQL Tibber API."""
4+
from typing import TYPE_CHECKING
5+
6+
7+
class SubscriptionPriceConnectionPageInfo:
8+
def __init__(self, data: dict, tibber_client: "Account"):
9+
self.cache: dict = data or {}
10+
self.tibber_client: "Account" = tibber_client
11+
12+
@property
13+
def end_cursor(self) -> str:
14+
return self.cache.get("endCursor")
15+
16+
@property
17+
def has_next_page(self) -> bool:
18+
return self.cache.get("hasNextPage")
19+
20+
@property
21+
def has_previous_page(self) -> bool:
22+
return self.cache.get("hasPreviousPage")
23+
24+
@property
25+
def start_cursor(self) -> str:
26+
return self.cache.get("startCursor")
27+
28+
@property
29+
def resolution(self) -> str:
30+
return self.cache.get("resolution")
31+
32+
@property
33+
def currency(self) -> str:
34+
return self.cache.get("currency")
35+
36+
@property
37+
def count(self) -> int:
38+
return self.cache.get("count")
39+
40+
@property
41+
def precision(self) -> int:
42+
return self.cache.get("precision")
43+
44+
@property
45+
def min_energy(self) -> float:
46+
return self.cache.get("minEnergy")
47+
48+
@property
49+
def min_total(self) -> float:
50+
return self.cache.get("minTotal")
51+
52+
@property
53+
def max_energy(self) -> float:
54+
return self.cache.get("maxEnergy")
55+
56+
@property
57+
def max_total(self) -> float:
58+
return self.cache.get("maxTotal")
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from __future__ import annotations
2+
3+
"""A class representing the SubscriptionPriceEdge type from the GraphQL Tibber API."""
4+
from typing import TYPE_CHECKING
5+
6+
from tibber.types.price import Price
7+
8+
9+
class SubscriptionPriceEdge:
10+
def __init__(self, data: dict, tibber_client: "Account"):
11+
self.cache: dict = data or {}
12+
self.tibber_client: "Account" = tibber_client
13+
14+
@property
15+
def cursor(self) -> str:
16+
return self.cache.get("cursor")
17+
18+
@property
19+
def node(self) -> Price:
20+
return Price(self.cache.get("node"), self.tibber_client)

0 commit comments

Comments
 (0)