Coverage for src/lanraragi_api/entity/tankoubon.py: 95%

22 statements  

« prev     ^ index     » next       coverage.py v7.16.0, created at 2026-09-22 23:19 +0000

1from pydantic import AliasChoices, BaseModel, Field 

2 

3from lanraragi_api.entity.archive import ArchiveMetadata 

4from lanraragi_api.entity.base import DictLikeModel 

5 

6 

7class TankoubonMetadata(BaseModel): 

8 """Metadata of a single Tankoubon. 

9 

10 Tankoubon metadata as returned by the list endpoint, with the archive IDs 

11 it contains and optional full archive metadata. 

12 

13 Attributes: 

14 archives: Array of archive IDs contained in this Tankoubon. 

15 full_data: Archive metadata of the archives, filled by the full detail 

16 endpoint only. 

17 tankid: ID of the tankoubon. 

18 name: Name of the tankoubon. 

19 summary: Summary of the tankoubon. 

20 tags: Tags associated with the tankoubon. 

21 progress: Reading progress (page number) for this Tankoubon. 

22 """ 

23 

24 archives: list[str] = Field(...) 

25 full_data: list[ArchiveMetadata] | None = Field(default=None) 

26 tankid: str = Field(..., validation_alias=AliasChoices("tankid", "id")) 

27 name: str = Field(...) 

28 summary: str | None = Field(default=None) 

29 tags: str | None = Field(default=None) 

30 progress: int | None = Field(default=None) 

31 

32 @property 

33 def id(self) -> str: 

34 """Return the ID of the tankoubon. 

35 

36 This is a backward-compatible alias for the ``tankid`` field. 

37 

38 Returns: 

39 str: ID of the tankoubon. 

40 """ 

41 return self.tankid 

42 

43 

44class TankoubonListResponse(DictLikeModel): 

45 """Paginated list of Tankoubons returned by the list endpoint. 

46 

47 Attributes: 

48 result: Tankoubons of the current page. 

49 total: Total count of Tankoubons on the server. 

50 filtered: Number of Tankoubons on the current page. 

51 """ 

52 

53 result: list[TankoubonMetadata] = Field(default_factory=list) 

54 total: int | None = Field(default=None) 

55 filtered: int | None = Field(default=None) 

56 

57 

58class TankoubonDetailResponse(DictLikeModel): 

59 """Tankoubon returned by the full detail endpoint. 

60 

61 Attributes: 

62 result: Tankoubon metadata, with ``full_data`` filled in. 

63 total: Total amount of archives in this Tankoubon. 

64 filtered: Amount of archives in the current page. 

65 """ 

66 

67 result: TankoubonMetadata = Field(...) 

68 total: int | None = Field(default=None) 

69 filtered: int | None = Field(default=None)