Skip to content

Commit

Permalink
feat: add classes necessary for range method of PriceInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
BeatsuDev committed Jan 6, 2025
1 parent 79f532c commit 5bc058c
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
Empty file.
58 changes: 58 additions & 0 deletions tibber/types/subscription_price_connection_page_info.py
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")
20 changes: 20 additions & 0 deletions tibber/types/subscription_price_edge.py
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)

0 comments on commit 5bc058c

Please sign in to comment.