Add a release date precision enum

This commit is contained in:
Bradlee Speice 2021-07-03 23:57:24 -04:00
parent 2337838886
commit ad39ddf83f
3 changed files with 18 additions and 2 deletions

View File

@ -3,6 +3,7 @@ Client-agnostic model for marshalling Spotify data types.
""" """
from .album import SearchAlbum from .album import SearchAlbum
from .extra import ReleaseDatePrecision
from .paging import Paging from .paging import Paging
__all__ = ["Paging", "SearchAlbum"] __all__ = ["Paging", "ReleaseDatePrecision", "SearchAlbum"]

View File

@ -6,6 +6,8 @@ from typing import Any, Dict, List, Union
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
from .extra import ReleaseDatePrecision
class SearchAlbum(BaseModel): class SearchAlbum(BaseModel):
"Album as returned by the search API. Doesn't quite return a SimplifiedAlbum." "Album as returned by the search API. Doesn't quite return a SimplifiedAlbum."
@ -19,7 +21,7 @@ class SearchAlbum(BaseModel):
images: List[Dict[str, Any]] images: List[Dict[str, Any]]
name: str name: str
release_date: str release_date: str
release_date_precision: str release_date_precision: ReleaseDatePrecision
total_tracks: int total_tracks: int
type_: str = Field(alias="type") type_: str = Field(alias="type")
uri: str uri: str

13
spotify_model/extra.py Normal file
View File

@ -0,0 +1,13 @@
"""
Extra type definitions that don't necessarily belong in other categories.
"""
from enum import Enum
class ReleaseDatePrecision(Enum):
"Release date precision"
YEAR = "year"
MONTH = "month"
DAY = "day"