Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 0.33.0 (2025-10-01)

Feature:
- Add SportType enum for ResourceGroup
- Add raw_attributes property to TeamTVObject

## 0.32.0 (2025-04-04)

Feature:
- Add more person information to the DF

## 0.31.0 (2025-02-19)

Feature:
- Add get_home_team + get_away_team to SportingEvent

## 0.30.3 (2024-11-18)

Bugfix:
Expand Down
46 changes: 46 additions & 0 deletions pyteamtv/models/resource_group/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,50 @@
from enum import Enum
from ..teamtv_object import TeamTVObject
from .capabilities import _HasStorage


class SportType(Enum):
KORFBALL = "korfball"
SOCCER = "soccer"
HOCKEY = "hockey"
HANDBALL = "handball"
VOLLEYBALL = "volleyball"
ATHLETICS = "athletics"
TENNIS = "tennis"
BASKETBALL = "basketball"
RUGBY = "rugby"
OTHER = "other"

@classmethod
def from_sport_name(cls, sport_name: str) -> "SportType":
"""Create SportType from sport name like 'korfball', 'handball', etc.
Returns SportType.OTHER for unknown sport types."""
sport_name_lower = sport_name.lower()
for sport_type in cls:
if sport_type.value == sport_name_lower:
return sport_type
return cls.OTHER

@classmethod
def from_tenant_id(cls, tenant_id: str) -> "SportType":
"""Create SportType from tenant_id like 'nl_korfball_rustroest'."""
parts = tenant_id.split("_")
if len(parts) < 2:
raise ValueError(f"Invalid tenant_id format: {tenant_id}")

sport_name = parts[1]
return cls.from_sport_name(sport_name)


class _ResourceGroup(TeamTVObject, _HasStorage):
def _use_attributes(self, attributes: dict):
super()._use_attributes(attributes)

self._name = attributes["targetResourceName"]
self._tenant_id = attributes["tenantId"]
self._resource_group_id = attributes["resourceGroupId"]
self._tags = attributes.get("tags", {})
self._sport_type_value = attributes.get("sportType")

@property
def resource_group_id(self):
Expand All @@ -22,6 +58,16 @@ def name(self):
def tenant_id(self):
return self._tenant_id

@property
def tags(self):
return self._tags

@property
def sport_type(self) -> SportType:
if self._sport_type_value:
return SportType.from_sport_name(self._sport_type_value)
return SportType.OTHER

def __repr__(self):
return f"<ResourceGroup name='{self.name}'>"

Expand Down
4 changes: 4 additions & 0 deletions pyteamtv/models/teamtv_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ def __init__(self, requester: Requester, attributes: dict):

self._use_attributes(attributes)

@property
def raw_attributes(self):
return self.__attributes

@property
def metadata(self):
return self._metadata
Expand Down
Loading