Skip to content

Commit

Permalink
Add Event attributes: cancelled, created_time, end_time, `inv…
Browse files Browse the repository at this point in the history
…ite_time`, `type` and property `url`; add `EventType` to public API
  • Loading branch information
elliot-100 committed Jul 13, 2024
1 parent 473f9e7 commit 45eac6a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ Historic and pre-release versions aren't necessarily included.

## UNRELEASED - TBC

### Added

- `Event` attributes: `cancelled`, `created_time`, `end_time`, `invite_time`, `type`,
property `url`. Tests and docs pending.

### Changed

- Consistent pattern for all classes' string representation, including full `uid`
- Dependencies: remove upper bounds for simplicity
- Dependencies: remove upper bounds for simplicity; drop redundant python-dateutil
- Dev dependencies: drop redundant types-python-dateutil


## [0.10.1] - 2024-07-02
Expand Down
3 changes: 2 additions & 1 deletion spond_classes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

# Explicitly import all classes and functions into the package namespace.

from .event import Event
from .event import Event, EventType
from .group import Group
from .member import Member
from .role import Role
from .subgroup import Subgroup

__all__ = [
"Event",
"EventType",
"Group",
"Member",
"Role",
Expand Down
28 changes: 27 additions & 1 deletion spond_classes/event.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Module containing `Event` class and nested `Responses` class."""
"""Module containing `Event` class and nested `EventType`,`Responses` classes."""

from datetime import datetime
from enum import Enum

from pydantic import BaseModel, Field

Expand All @@ -21,6 +22,13 @@ class Responses(BaseModel):
"""`unconfirmedIds` in API."""


class EventType(Enum):
"""Represents the kind of `Event`."""

EVENT = "EVENT"
RECURRING = "RECURRING"


class Event(BaseModel):
"""Represents an event in the Spond system.
Expand All @@ -32,10 +40,23 @@ class Event(BaseModel):
uses `uid`."""
heading: str
responses: Responses
type: EventType
created_time: datetime = Field(alias="createdTime")
"""Derived from `createdTime` in API."""
end_time: datetime = Field(alias="endTimestamp")
"""Datetime at which the `Event` ends.
Derived from `endTimestamp` in API."""
start_time: datetime = Field(alias="startTimestamp")
"""Datetime at which the `Event` starts.
Derived from `startTimestamp` in API."""

# Optional in API data
cancelled: bool | None = Field(default=None)
"""Optional."""
invite_time: datetime | None = Field(alias="inviteTime", default=None)
"""Optional.
Derived from `inviteTime` in API."""

def __str__(self) -> str:
"""Return simple human-readable description.
Expand All @@ -48,3 +69,8 @@ def __str__(self) -> str:
f"start_time: {start_time_tag},"
f" …)"
)

@property
def url(self) -> str:
"""Return the URL of the `Event`."""
return f"https://spond.com/client/sponds/{self.uid}/"

0 comments on commit 45eac6a

Please sign in to comment.