Skip to content
This repository has been archived by the owner on Jan 18, 2025. It is now read-only.

Commit

Permalink
feat: create_Getdata class to get data with a single Config object
Browse files Browse the repository at this point in the history
  • Loading branch information
NTGNguyen committed Dec 22, 2024
1 parent 7eb0def commit 75f11f3
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/gcpn/modules/get_data.py
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

0 comments on commit 75f11f3

Please sign in to comment.