-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbaseModel.py
More file actions
69 lines (56 loc) · 1.57 KB
/
Copy pathbaseModel.py
File metadata and controls
69 lines (56 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from __future__ import annotations
from typing import TypeVar, Generic
from enum import Enum
from pydantic import BaseModel
T = TypeVar('T')
class RequestMethod(Enum):
GET = 'get'
POST = 'post'
PUT = 'put'
HEAD = 'head'
DELETE = 'delete'
OPTIONS = 'options'
class ResponsePaginationLinks(BaseModel):
"""Pagination links
:param next_page: str | None
Next page link
:param prev_page: str | None
Previous page link
"""
next_page: str | None
prev_page: str | None
class ResponsePagination(BaseModel):
"""Request pagination
:param total: int
Total items in all pages
:param count: int
Count of items at current page
:param per_page: int
Limit of served items at one page
:param current_page: int
Current page
:param total_pages: int
Total pages at pagination
:param links: ResponsePaginationLinks
Pagination links (next page, previous page)
"""
total: int
count: int
per_page: int
current_page: int
total_pages: int
links: ResponsePaginationLinks
class Response(Generic[T]):
"""Request response
:param success: bool
Determinate if request has been procesed successfully
:param data: any
Response body data, data can be list of items or object of item
:param pagination: ResponsePagination | none
Pagination
"""
success: bool = False
data: T | None = None
pagination: ResponsePagination | None
def has_pagination(self) -> bool:
return self.pagination is not None