Add optional API upload alongside SMTP, Nextcloud/WebDAV as a document source with the same dedup/retry flow as IMAP, stricter invoice file checks for images, and admin UI for source and delivery modes.
72 lines
2.0 KiB
Python
72 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Probe BizDocs mobile API (GetRoute, login, companies).
|
|
|
|
Usage:
|
|
PYTHONPATH=src python tools/probe_bizdocs_api.py --email [email protected] --password 'secret'
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT / "src"))
|
|
|
|
from forwarder.bizdocs.client import BizdocsClient, BizdocsCredentials
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description="Probe BizDocs API login and routing")
|
|
parser.add_argument("--email", required=True)
|
|
parser.add_argument("--password", required=True)
|
|
parser.add_argument("--company-id", default="")
|
|
parser.add_argument("--api-base", default="", help="Skip identity router when set")
|
|
args = parser.parse_args()
|
|
|
|
client = BizdocsClient()
|
|
credentials = BizdocsCredentials(
|
|
email=args.email,
|
|
password=args.password,
|
|
company_id=args.company_id,
|
|
api_base_url=args.api_base or None,
|
|
)
|
|
|
|
print("=== Resolve mobile API URL ===")
|
|
try:
|
|
mobile_url = client.resolve_mobile_api_url(
|
|
credentials.email,
|
|
credentials.api_base_url,
|
|
)
|
|
print("mobileApiUrl:", mobile_url)
|
|
except Exception as exc:
|
|
print("FAILED:", exc)
|
|
if not args.api_base:
|
|
print("Tip: pass --api-base if you know the tenant API URL")
|
|
return 1
|
|
|
|
print("\n=== Login ===")
|
|
try:
|
|
session = client.login(credentials)
|
|
print("access_token:", session.access_token[:24] + "…")
|
|
if session.refresh_token:
|
|
print("refresh_token: present")
|
|
except Exception as exc:
|
|
print("FAILED:", exc)
|
|
return 1
|
|
|
|
print("\n=== Companies ===")
|
|
try:
|
|
companies = client.list_companies(session)
|
|
print(json.dumps(companies, indent=2, ensure_ascii=False))
|
|
except Exception as exc:
|
|
print("FAILED:", exc)
|
|
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|