Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/publish_account_facts_from_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
SOURCE_BINDING_KIND = "deployment_runtime_account"
IBKR_ACCOUNT_FACTS_SYNC_TOKEN_ENV = "IBKR_ACCOUNT_FACTS_SYNC_TOKEN"
IBKR_ACCOUNT_FACTS_SYNC_URL = "https://qsl-strategy-switch-console.pigbibi.workers.dev/api/account-facts/sync"
IBKR_ACCOUNT_FACTS_USER_AGENT = "QSL-IBKR-AccountFacts/1.0"
IBKR_ACCOUNT_FACTS_INGRESS_DIAGNOSTIC_TARGET = "ingress-diagnostic"
_INGRESS_DIAGNOSTIC_BODY = b"{}"
_INGRESS_DIAGNOSTIC_ERROR = "invalid_account_facts_history"
Expand Down Expand Up @@ -287,6 +288,7 @@ def publish_ibkr_account_facts_history(
headers={
"Authorization": f"Bearer {_text(sync_token)}",
"Content-Type": "application/json",
"User-Agent": IBKR_ACCOUNT_FACTS_USER_AGENT,
},
method="POST",
)
Expand Down Expand Up @@ -400,6 +402,7 @@ def diagnose_account_facts_ingress(*, sync_token: str) -> dict[str, Any]:
headers={
"Authorization": f"Bearer {_text(sync_token)}",
"Content-Type": "application/json",
"User-Agent": IBKR_ACCOUNT_FACTS_USER_AGENT,
},
method="POST",
)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_publish_ibkr_account_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def open(self, request, *, timeout):
request = observed["request"]
assert request.get_method() == "POST"
assert request.get_header("Authorization") == "Bearer dedicated-test-token"
assert request.get_header("User-agent") == publisher.IBKR_ACCOUNT_FACTS_USER_AGENT
assert json.loads(request.data)["account_ids"] == ["U16608560"]
assert observed["timeout"] == 15

Expand Down Expand Up @@ -499,6 +500,7 @@ def open(self, request, *, timeout):
assert request.data == b"{}"
assert request.get_method() == "POST"
assert request.get_header("Authorization") == "Bearer TOKEN_SENTINEL"
assert request.get_header("User-agent") == publisher.IBKR_ACCOUNT_FACTS_USER_AGENT
assert request.get_header("Content-type") == "application/json"
assert observed["calls"] == 1
assert observed["timeout"] == 15
Expand Down
Loading