This repository has been archived by the owner on Jan 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create_Getdata class to get data with a single Config object
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"""Get datas""" | ||
import requests | ||
import json | ||
import threading | ||
from requests import Response | ||
|
||
from ..types.config import Config | ||
from ..constants import URL | ||
|
||
from typing import Dict | ||
|
||
|
||
class _GetData: | ||
"""Get data by sending a request""" | ||
|
||
def __init__(self, config: Config, url=URL) -> None: | ||
"""The initialise for GetData class | ||
Args: | ||
config: config object | ||
""" | ||
self._config: Config = config | ||
self._url = url | ||
|
||
def _get_data(self) -> None | Dict: | ||
"""Get data with a single object | ||
Returns: | ||
None | Dict: _description_ | ||
""" | ||
payload: dict[str, str] = { | ||
"bienso": self._config.bien_so | ||
} | ||
try: | ||
response: Response = requests.post( | ||
url=self.url, json=payload) | ||
response.raise_for_status() | ||
response_data: Dict = response.json() | ||
if response_data.get("data") is None: | ||
return None | ||
else: | ||
return response_data | ||
except: | ||
return None | ||
|
||
|
||
class _GetDataThread(threading.Thread): | ||
pass | ||
|
||
|
||
class GetDataMultiThread(): | ||
pass |