Skip to content

Commit

Permalink
parse modeus.py
Browse files Browse the repository at this point in the history
  • Loading branch information
depocoder committed Sep 24, 2024
1 parent b9d8ad6 commit 10141c5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
41 changes: 35 additions & 6 deletions backend/app/controllers/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from datetime import datetime
import datetime
import uuid
from typing import Any, Optional

from pydantic import BaseModel, Field
from pydantic import BaseModel, Field, computed_field


class NetologyCreds(BaseModel):
Expand All @@ -25,7 +27,34 @@ class ModeusCreds(BaseModel):
class ModeusSearchEvents(BaseModel):
"""Modeus search events body."""

size: int
time_min: datetime = Field(alias="timeMin")
time_max: datetime = Field(alias="timeMax")
attendee_person_id: list[str] = Field(alias="attendeePersonId")
size : int = 50
time_min: datetime.datetime = Field(alias="timeMin", default=datetime.datetime.now())
time_max: datetime.datetime = Field(alias="timeMax", default=datetime.datetime.now() - datetime.timedelta(days=7))
attendee_person_id: list[str] = Field(alias="attendeePersonId", default="d69c87c8-aece-4f39-b6a2-7b467b968211")

class Location(BaseModel):
event_id: str = Field(alias="eventId")
custom_location: str = Field(alias="customLocation")

@computed_field
@property
def is_lxp(self) -> float:
return self.custom_location == 'LXP'

class Event(BaseModel):
name: str = Field(alias="name")
name_short: str = Field(alias="nameShort")
description: Optional[str] = Field(alias="description")
start_time: datetime.datetime = Field(alias="start")
end_time: datetime.datetime = Field(alias="end")
id: uuid.UUID

class Embedded(BaseModel):
event: list[Event] = Field(alias="events")
locations: list[Location] = Field(alias="event-locations")

class ModeusCalendar(BaseModel):
"""Modeus calendar response."""

embedded: Embedded = Field(alias="_embedded")

2 changes: 1 addition & 1 deletion backend/app/controllers/modeus.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


class FromAuthorizationHeader(FromHeader[str]):
name = "Authorization"
name = "bearer-token"


class ModeusController(Controller):
Expand Down

0 comments on commit 10141c5

Please sign in to comment.