@@ -24,6 +24,7 @@ def wallet_object():
2424 target_ongoing_balance = "105.0" ,
2525 transaction_name = "Recurring Transaction Rule" ,
2626 ignore_paid_top_up_limits = True ,
27+ grants_target_top_up = True ,
2728 )
2829 rules_list = RecurringTransactionRuleList (__root__ = [rule ])
2930 applies_to = AppliesTo (
@@ -73,6 +74,7 @@ def test_valid_create_wallet_request(httpx_mock: HTTPXMock):
7374 "target_ongoing_balance" : "105.0" ,
7475 "transaction_name" : "Recurring Transaction Rule" ,
7576 "ignore_paid_top_up_limits" : True ,
77+ "grants_target_top_up" : True ,
7678 }
7779 ],
7880 "invoice_requires_successful_payment" : False ,
@@ -88,6 +90,7 @@ def test_valid_create_wallet_request(httpx_mock: HTTPXMock):
8890 assert response .recurring_transaction_rules .__root__ [0 ].trigger == "interval"
8991 assert response .recurring_transaction_rules .__root__ [0 ].interval == "monthly"
9092 assert response .recurring_transaction_rules .__root__ [0 ].ignore_paid_top_up_limits is True
93+ assert response .recurring_transaction_rules .__root__ [0 ].grants_target_top_up is True
9194 assert response .applies_to .fee_types [0 ] == "charge"
9295 assert response .applies_to .billable_metric_codes [0 ] == "usage"
9396 assert response .paid_top_up_max_amount_cents == 10000
@@ -348,3 +351,41 @@ def test_valid_update_customer_wallet_with_invoice_custom_section_on_recurring_t
348351 .invoice_custom_section_id
349352 == "section_rule_001"
350353 )
354+
355+
356+ def test_valid_update_wallet_with_grants_target_top_up_on_recurring_transaction_rule (httpx_mock : HTTPXMock ):
357+ client = Client (api_key = "886fe239-927d-4072-ab72-6dd345e8dd0d" )
358+ wallet_id = "b7ab2926-1de8-4428-9bcd-779314ac129b"
359+ rule = RecurringTransactionRule (
360+ trigger = "interval" ,
361+ interval = "monthly" ,
362+ method = "target" ,
363+ target_ongoing_balance = "200.0" ,
364+ grants_target_top_up = True ,
365+ )
366+ rules_list = RecurringTransactionRuleList (__root__ = [rule ])
367+
368+ httpx_mock .add_response (
369+ method = "PUT" ,
370+ url = "https://api.getlago.com/api/v1/customers/customer_id/wallets/" + wallet_id ,
371+ content = mock_response ("wallet" ),
372+ match_json = {
373+ "wallet" : {
374+ "name" : "name" ,
375+ "recurring_transaction_rules" : [
376+ {
377+ "interval" : "monthly" ,
378+ "trigger" : "interval" ,
379+ "method" : "target" ,
380+ "target_ongoing_balance" : "200.0" ,
381+ "grants_target_top_up" : True ,
382+ }
383+ ],
384+ }
385+ },
386+ )
387+ wallet = Wallet (name = "name" , recurring_transaction_rules = rules_list )
388+ response = client .customers .wallets .update ("customer_id" , wallet_id , wallet )
389+
390+ assert response .lago_id == "b7ab2926-1de8-4428-9bcd-779314ac129b"
391+ assert response .recurring_transaction_rules .__root__ [0 ].grants_target_top_up is True
0 commit comments