Skip to content

Commit

Permalink
Support both userfiles and uploadedfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Feb 9, 2024
1 parent 38c9830 commit 81c2205
Show file tree
Hide file tree
Showing 3 changed files with 346 additions and 300 deletions.
15 changes: 13 additions & 2 deletions aiochris/models/collection_links.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dataclasses
import functools
from dataclasses import dataclass
from typing import Iterator
from typing import Iterator, Optional

from serde import deserialize

Expand Down Expand Up @@ -53,7 +53,18 @@ class AnonymousCollectionLinks(AbstractCollectionLinks):
@dataclass(frozen=True)
class CollectionLinks(AnonymousCollectionLinks):
user: UserUrl
userfiles: ApiUrl
userfiles: Optional[ApiUrl]
uploadedfiles: Optional[ApiUrl]

def __post_init__(self):
if (self.userfiles is None) ^ (self.uploadedfiles is None):
raise ValueError("Either userfiles or uploadefiles link must be present")

@property
def useruploadedfiles(self) -> ApiUrl:
if self.userfiles is None:
return self.uploadedfiles
return self.userfiles


@deserialize
Expand Down
Loading

0 comments on commit 81c2205

Please sign in to comment.