55from lago_python_client .exceptions import LagoApiError
66from lago_python_client .models import (
77 Alert ,
8+ AlertsList ,
89 AlertThreshold ,
910 AlertThresholdList ,
1011)
@@ -176,6 +177,7 @@ def test_valid_find_all_customer_wallet_alerts_request_with_options(httpx_mock:
176177 "customer_id" , "wallet_code" , options = {"per_page" : 2 , "page" : 1 }
177178 )
178179
180+ assert len (response ) == 2
179181 assert response ["alerts" ][0 ].lago_id == "1a901a90-1a90-1a90-1a90-1a901a901a90"
180182 assert response ["meta" ]["current_page" ] == 1
181183
@@ -192,3 +194,86 @@ def test_invalid_find_all_wallet_alerts_request(httpx_mock: HTTPXMock):
192194
193195 with pytest .raises (LagoApiError ):
194196 client .customers .wallets .alerts .find_all ("customer_id" , "wallet_code" )
197+
198+
199+ def test_valid_create_batch_request (httpx_mock : HTTPXMock ):
200+ client = Client (api_key = "886fe239-927d-4072-ab72-6dd345e8dd0d" )
201+
202+ httpx_mock .add_response (
203+ method = "POST" ,
204+ url = "https://api.getlago.com/api/v1/customers/customer_id/wallets/wallet_code/alerts" ,
205+ content = mock_response ("wallet_alert_index" ),
206+ )
207+
208+ input = AlertsList (
209+ alerts = [
210+ Alert (
211+ alert_type = "wallet_balance_amount" ,
212+ code = "wallet_balance_alert" ,
213+ name = "Balance Amount Alert" ,
214+ thresholds = [AlertThreshold (code = "warn" , value = "1000" )],
215+ ),
216+ Alert (
217+ alert_type = "wallet_credits_balance" ,
218+ code = "wallet_credits_alert" ,
219+ name = "Credits Balance Alert" ,
220+ thresholds = [AlertThreshold (value = "2000" )],
221+ ),
222+ ]
223+ )
224+
225+ response = client .customers .wallets .alerts .create_batch ("customer_id" , "wallet_code" , input )
226+
227+ assert len (response ["alerts" ]) == 2
228+
229+ assert response ["alerts" ][0 ].lago_id == "1a901a90-1a90-1a90-1a90-1a901a901a90"
230+ assert response ["alerts" ][0 ].wallet_code == "wallet_code"
231+ assert response ["alerts" ][0 ].code == "wallet_balance_alert"
232+ assert response ["alerts" ][0 ].alert_type == "wallet_balance_amount"
233+
234+ assert response ["alerts" ][1 ].lago_id == "1a921a92-1a92-1a92-1a92-1a921a921a92"
235+ assert response ["alerts" ][1 ].wallet_code == "wallet_code"
236+ assert response ["alerts" ][1 ].code == "wallet_credits_alert"
237+ assert response ["alerts" ][1 ].alert_type == "wallet_credits_balance"
238+
239+
240+ def test_invalid_create_batch_request (httpx_mock : HTTPXMock ):
241+ client = Client (api_key = "invalid" )
242+
243+ httpx_mock .add_response (
244+ method = "POST" ,
245+ url = "https://api.getlago.com/api/v1/customers/customer_id/wallets/wallet_code/alerts" ,
246+ status_code = 401 ,
247+ content = b"" ,
248+ )
249+
250+ with pytest .raises (LagoApiError ):
251+ client .customers .wallets .alerts .create_batch ("customer_id" , "wallet_code" , AlertsList (alerts = []))
252+
253+
254+ def test_valid_destroy_all_request (httpx_mock : HTTPXMock ):
255+ client = Client (api_key = "886fe239-927d-4072-ab72-6dd345e8dd0d" )
256+
257+ httpx_mock .add_response (
258+ method = "DELETE" ,
259+ url = "https://api.getlago.com/api/v1/customers/customer_id/wallets/wallet_code/alerts" ,
260+ status_code = 200 ,
261+ content = b"" ,
262+ )
263+
264+ response = client .customers .wallets .alerts .destroy_all ("customer_id" , "wallet_code" )
265+ assert response is None
266+
267+
268+ def test_invalid_destroy_all_request (httpx_mock : HTTPXMock ):
269+ client = Client (api_key = "invalid" )
270+
271+ httpx_mock .add_response (
272+ method = "DELETE" ,
273+ url = "https://api.getlago.com/api/v1/customers/customer_id/wallets/wallet_code/alerts" ,
274+ status_code = 404 ,
275+ content = b"" ,
276+ )
277+
278+ with pytest .raises (LagoApiError ):
279+ client .customers .wallets .alerts .destroy_all ("customer_id" , "wallet_code" )
0 commit comments