Skip to content

Commit

Permalink
read and write to API
Browse files Browse the repository at this point in the history
  • Loading branch information
aquamatthias committed Oct 1, 2024
1 parent 9fe243b commit a403607
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fixbackend/auth/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ class UserNotificationSettingsRead(BaseModel):
weekly_report: bool = Field(description="Whether to receive a weekly report")
inactivity_reminder: bool = Field(description="Whether to receive a reminder for open incidents")
tutorial: bool = Field(description="Whether to receive tutorial emails")
marketing: bool = Field(description="Whether to receive marketing emails")

@staticmethod
def from_model(model: UserNotificationSettings) -> "UserNotificationSettingsRead":
return UserNotificationSettingsRead(
weekly_report=model.weekly_report,
inactivity_reminder=model.inactivity_reminder,
tutorial=model.tutorial,
marketing=model.marketing,
)

def to_model(self, user_id: UserId) -> UserNotificationSettings:
Expand All @@ -95,6 +97,7 @@ def to_model(self, user_id: UserId) -> UserNotificationSettings:
weekly_report=self.weekly_report,
inactivity_reminder=self.inactivity_reminder,
tutorial=self.tutorial,
marketing=self.marketing,
)


Expand All @@ -104,6 +107,7 @@ class UserNotificationSettingsWrite(BaseModel):
default=None, description="Whether to receive a reminder for open incidents"
)
tutorial: Optional[bool] = Field(default=None, description="Whether to receive tutorial emails")
marketing: Optional[bool] = Field(default=None, description="Whether to receive marketing emails")


class OTPConfig(BaseModel):
Expand Down

0 comments on commit a403607

Please sign in to comment.