Workflow-App/Workflow/scripts/_inspect_tesh.py

31 lines
1.2 KiB
Python
Raw Normal View History

import os, requests, pathlib
for line in pathlib.Path(r'C:\Users\SJ\.minimax-agent\projects\Workflow\.env.local').read_text().splitlines():
if line.strip() and '=' in line and not line.startswith('#'):
k, v = line.split('=', 1)
os.environ.setdefault(k.strip(), v.strip())
token = os.environ['PB_TOKEN']
h = {'Authorization': f'Bearer {token}'}
# TESHUVA's record
r = requests.get(
'https://pb.agent.apphub.co.za/api/collections/ysterbaard_companies/records/nidis1m4669zk1y',
headers=h, timeout=15,
)
r.raise_for_status()
co = r.json()
print('=== TESHUVA PB record ===')
print(f" enterprise_name: {co.get('enterprise_name')}")
print(f" sars_paye_no: {co.get('sars_paye_no')}")
print(f" sars_login_username: {co.get('sars_login_username')}")
print(f" groups: {co.get('groups')}")
# Resolve the group name
gid = (co.get('groups') or [None])[0]
if gid:
r2 = requests.get(f'https://pb.agent.apphub.co.za/api/collections/ysterbaard_groups/records/{gid}', headers=h, timeout=15)
if r2.status_code == 200:
g = r2.json()
print(f" group.name: {g.get('name')}")
print(f" group.sars_login: {g.get('sars_login')}")
else:
print(f" group {gid}: HTTP {r2.status_code}")