@@ -12,12 +12,12 @@ class Client:
12
12
13
13
Methods:
14
14
__init__(api_token: str): Initialize the UkraineAlertApiClient with an API token.
15
- _make_request(method: str, endpoint: str, params: Optional[dict] = None, data: Optional[dict] = None) -> Union[types.Alert , types.AlertModification, types.RegionAlarmsHistory, types.RegionsView , types.WebHook]: Make a request to the UkraineAlert API.
16
- get_alerts() -> List[types.Alert ]: Get a list of alerts.
17
- get_region_alerts(region_id: str|int) -> List[types.Alert ]: Get alerts for a specific region.
15
+ _make_request(method: str, endpoint: str, params: Optional[dict] = None, data: Optional[dict] = None) -> Union[types.AlertRegionModel , types.AlertModification, types.RegionAlarmsHistory, types.RegionsViewModel , types.WebHook]: Make a request to the UkraineAlert API.
16
+ get_alerts() -> List[types.AlertRegionModel ]: Get a list of alerts.
17
+ get_region_alerts(region_id: str|int) -> List[types.AlertRegionModel ]: Get alerts for a specific region.
18
18
get_alert_status() -> types.AlertModification: Get the status of alerts.
19
19
get_region_history(region_id: str|int) -> types.RegionAlarmsHistory: Get the history of alerts for a specific region.
20
- get_regions() -> types.RegionsView : Get information about regions.
20
+ get_regions() -> types.RegionsViewModel : Get information about regions.
21
21
subscribe_to_webhook(webhook_data: dict) -> types.WebHook: Subscribe to a webhook.
22
22
update_webhook(webhook_data: dict) -> None: Update an existing webhook.
23
23
unsubscribe_from_webhook(webhook_data: dict) -> None: Unsubscribe from a webhook.
@@ -35,7 +35,7 @@ def __init__(self, api_token: str):
35
35
"Authorization" : api_token
36
36
}
37
37
38
- async def _make_request (self , method : str , endpoint : str , params : Optional [dict ] = None , data : Optional [dict ] = None ) -> Union [types .Alert , types .AlertModification , types .RegionAlarmsHistory , types .RegionsView , types .WebHook ]:
38
+ async def _make_request (self , method : str , endpoint : str , params : Optional [dict ] = None , data : Optional [dict ] = None ) -> Union [types .AlertRegionModel , types .AlertModification , types .RegionAlarmsHistory , types .RegionsViewModel , types .WebHook ]:
39
39
"""
40
40
Makes a request to the UkraineAlert API.
41
41
@@ -46,7 +46,7 @@ async def _make_request(self, method: str, endpoint: str, params: Optional[dict]
46
46
data (Optional[dict]): Optional data payload for the request.
47
47
48
48
Returns:
49
- Union[types.Alert , types.AlertModification, types.RegionAlarmsHistory, types.RegionsView , types.WebHook]: The response from the API based on the endpoint accessed.
49
+ Union[types.AlertRegionModel , types.AlertModification, types.RegionAlarmsHistory, types.RegionsViewModel , types.WebHook]: The response from the API based on the endpoint accessed.
50
50
"""
51
51
url = f"{ self .base_url } { endpoint } "
52
52
async with ClientSession (headers = self .headers ) as session :
@@ -59,30 +59,30 @@ async def _make_request(self, method: str, endpoint: str, params: Optional[dict]
59
59
elif endpoint == "/api/v3/alerts/regionHistory" :
60
60
return [types .RegionAlarmsHistory (** item ) for item in response_json ]
61
61
elif endpoint == "/api/v3/regions" :
62
- return types .RegionsView (** response_json )
62
+ return types .RegionsViewModel (** response_json )
63
63
elif endpoint == "/api/v3/webhook" :
64
64
return types .WebHook (** response_json )
65
65
elif "/api/v3/alerts" in endpoint :
66
- return [types .Alert (** item ) for item in response_json ]
66
+ return [types .AlertRegionModel (** item ) for item in response_json ]
67
67
68
- async def get_alerts (self ) -> List [types .Alert ]:
68
+ async def get_alerts (self ) -> List [types .AlertRegionModel ]:
69
69
"""
70
70
Retrieves a list of alerts from the UkraineAlert API.
71
71
72
72
Returns:
73
- List[types.Alert ]: A list of types.Alert objects.
73
+ List[types.AlertRegionModel ]: A list of types.AlertRegionModel objects.
74
74
"""
75
75
return await self ._make_request ("GET" , "/api/v3/alerts" )
76
76
77
- async def get_region_alerts (self , region_id : str | int ) -> List [types .Alert ]:
77
+ async def get_region_alerts (self , region_id : str | int ) -> List [types .AlertRegionModel ]:
78
78
"""
79
79
Retrieves alerts for a specific region from the UkraineAlert API.
80
80
81
81
Args:
82
82
region_id (str or int): The ID of the region for which alerts are requested.
83
83
84
84
Returns:
85
- List[types.Alert ]: A list of types.Alert objects for the specified region.
85
+ List[types.AlertRegionModel ]: A list of types.AlertRegionModel objects for the specified region.
86
86
"""
87
87
return await self ._make_request ("GET" , f"/api/v3/alerts/{ region_id } " )
88
88
@@ -108,12 +108,12 @@ async def get_region_history(self, region_id: str|int) -> types.RegionAlarmsHist
108
108
params = {"regionId" : region_id }
109
109
return await self ._make_request ("GET" , "/api/v3/alerts/regionHistory" , params = params )
110
110
111
- async def get_regions (self ) -> types .RegionsView :
111
+ async def get_regions (self ) -> types .RegionsViewModel :
112
112
"""
113
113
Retrieves information about regions from the UkraineAlert API.
114
114
115
115
Returns:
116
- types.RegionsView : An object representing information about regions.
116
+ types.RegionsViewModel : An object representing information about regions.
117
117
"""
118
118
return await self ._make_request ("GET" , "/api/v3/regions" )
119
119
0 commit comments