-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapi_response.py
More file actions
27 lines (22 loc) · 893 Bytes
/
api_response.py
File metadata and controls
27 lines (22 loc) · 893 Bytes
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
"""API response object."""
from __future__ import annotations
from typing import Any, Dict, Optional
from pydantic import Field, StrictInt, StrictStr
# Updated imports for Pydantic v2 compatibility
class ApiResponse:
"""
API response object
"""
status_code: Optional[StrictInt] = Field(None, description="HTTP status code")
headers: Optional[Dict[StrictStr, StrictStr]] = Field(None, description="HTTP headers")
data: Optional[Any] = Field(None, description="Deserialized data given the data type")
raw_data: Optional[Any] = Field(None, description="Raw data (HTTP response body)")
def __init__(self,
status_code=None,
headers=None,
data=None,
raw_data=None):
self.status_code = status_code
self.headers = headers
self.data = data
self.raw_data = raw_data