aboutsummaryrefslogtreecommitdiff
path: root/jb/managers
diff options
context:
space:
mode:
authorstuppie2026-04-11 10:43:53 -0600
committerstuppie2026-04-11 10:43:53 -0600
commitd0af0c38d7b59013e35eca4e2679a509b56f5980 (patch)
tree1e3583308abf151d7ad1fe7c8875aa00214f344d /jb/managers
parent07bde156894db70ce92fabf67938770fac8f81b9 (diff)
downloadamt-jb-d0af0c38d7b59013e35eca4e2679a509b56f5980.tar.gz
amt-jb-d0af0c38d7b59013e35eca4e2679a509b56f5980.zip
get_wallet_balance_if_non_negative
Diffstat (limited to 'jb/managers')
-rw-r--r--jb/managers/thl.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/jb/managers/thl.py b/jb/managers/thl.py
index c1cd672..6e8effc 100644
--- a/jb/managers/thl.py
+++ b/jb/managers/thl.py
@@ -35,7 +35,7 @@ def get_user_profile(amt_worker_id: str) -> UserProfile:
# todo: this contains computed fields inside each streak object
user_profile.pop("streaks", None)
# todo: this shouldn't be in here anyways ---v
- user_profile['user'].pop("id", None)
+ user_profile["user"].pop("id", None)
return UserProfile.model_validate(user_profile)
@@ -104,6 +104,16 @@ def manage_pending_cashout(
def get_wallet_balance(amt_worker_id: str) -> USDCent:
+ # This will raise an Exception if wallet balance is negative
url = f"{settings.fsb_host}{settings.product_id}/wallet/"
params = {"bpuid": amt_worker_id}
return USDCent(requests.get(url, params=params).json()["wallet"]["amount"])
+
+
+def get_wallet_balance_if_non_negative(amt_worker_id: str) -> Optional[USDCent]:
+ url = f"{settings.fsb_host}{settings.product_id}/wallet/"
+ params = {"bpuid": amt_worker_id}
+ amt = requests.get(url, params=params).json()["wallet"]["amount"]
+ if amt >= 0:
+ return USDCent(amt)
+ return None