Coverage for graphqler / utils / protocols / request_utils_protocol.py: 100%
12 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-18 23:20 -0400
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-18 23:20 -0400
1from typing import Protocol, Callable, Union, Tuple, runtime_checkable
2from requests import Session, Response
4@runtime_checkable
5class RequestUtilsProtocol(Protocol):
6 # Global variables
7 last_request_time: float
8 session: Union[Session, None]
10 # Functions
11 def get_headers(self) -> dict:
12 """Get the headers for the request"""
13 ...
15 def get_proxies(self) -> dict:
16 """Get the proxies for the request"""
17 ...
19 def send_graphql_request(
20 self,
21 url: str,
22 payload: Union[str, dict, list],
23 next: Callable[[dict], dict] | None = None
24 ) -> Tuple[dict, Response]:
25 """Send GraphQL request to the specified endpoint"""
26 ...
28 def parse_response(self, response_text: str) -> dict:
29 """Parse the response and try to jsonify it"""
30 ...
32 def get_or_create_session(self) -> Session:
33 """Gets an existing session or creates a new one"""
34 ...
36 def create_new_session(self) -> Session:
37 """Create a new session"""
38 ...