More email SKU shenanigans, now with more TEST labels!
This commit is contained in:
@@ -75,6 +75,54 @@ SETTINGS_SCHEMA: Dict[str, tuple[str, str, bool]] = {
|
||||
False,
|
||||
),
|
||||
|
||||
"SHIPSTATION_TEST_MODE": (
|
||||
"Use ShipStation test/sandbox API key instead of production (true/false) - "
|
||||
"also toggleable from the Data menu",
|
||||
"ShipStation Test Mode",
|
||||
False,
|
||||
),
|
||||
"TEST_SHIPSTATION_API_KEY": ("ShipStation Test/Sandbox API Key", "ShipStation Test Mode", True),
|
||||
"TEST_SHIPSTATION_SIGNIFY_STORE_ID": (
|
||||
"Test override: Signify Store ID (blank = use production value)",
|
||||
"ShipStation Test Mode",
|
||||
False,
|
||||
),
|
||||
"TEST_SHIPSTATION_OAKSTREET_STORE_ID": (
|
||||
"Test override: Oak Street Store ID (blank = use production value)",
|
||||
"ShipStation Test Mode",
|
||||
False,
|
||||
),
|
||||
"TEST_SHIPSTATION_SIGNIFY_WAREHOUSE_ID": (
|
||||
"Test override: Signify Warehouse ID (blank = use production value)",
|
||||
"ShipStation Test Mode",
|
||||
False,
|
||||
),
|
||||
"TEST_SHIPSTATION_OAKSTREET_WAREHOUSE_ID": (
|
||||
"Test override: Oak Street Warehouse ID (blank = use production value)",
|
||||
"ShipStation Test Mode",
|
||||
False,
|
||||
),
|
||||
"TEST_SIGNIFY_RETURN_CARRIER_ID": (
|
||||
"Test override: Signify Return Carrier ID (blank = use production value)",
|
||||
"ShipStation Test Mode",
|
||||
False,
|
||||
),
|
||||
"TEST_SIGNIFY_RETURN_SERVICE_CODE": (
|
||||
"Test override: Signify Return Service Code (blank = use production value)",
|
||||
"ShipStation Test Mode",
|
||||
False,
|
||||
),
|
||||
"TEST_OAKSTREET_RETURN_CARRIER_ID": (
|
||||
"Test override: Oak Street Return Carrier ID (blank = use production value)",
|
||||
"ShipStation Test Mode",
|
||||
False,
|
||||
),
|
||||
"TEST_OAKSTREET_RETURN_SERVICE_CODE": (
|
||||
"Test override: Oak Street Return Service Code (blank = use production value)",
|
||||
"ShipStation Test Mode",
|
||||
False,
|
||||
),
|
||||
|
||||
"COMPANY_SKU_MAP": (
|
||||
"SKU Prefix -> Company (e.g. SH:Signify Health,OK:Oak Street Health)",
|
||||
"Companies",
|
||||
@@ -262,3 +310,25 @@ def save_settings(values: Dict[str, str]) -> None:
|
||||
def get(key: str, default: str = "") -> str:
|
||||
"""Convenience getter, e.g. config.get('DB_URL')."""
|
||||
return load_settings().get(key, default) or default
|
||||
|
||||
|
||||
def is_shipstation_test_mode() -> bool:
|
||||
return get("SHIPSTATION_TEST_MODE", "").strip().lower() in ("true", "1", "yes")
|
||||
|
||||
|
||||
def get_shipstation_setting(key: str) -> str:
|
||||
"""
|
||||
Test-mode-aware lookup for ShipStation-related settings (API key,
|
||||
store/warehouse/carrier IDs). When SHIPSTATION_TEST_MODE is on, looks
|
||||
for a TEST_{key} override first, falling back to the normal {key}
|
||||
value if the override is blank - so test mode works immediately if
|
||||
your test/sandbox account mirrors production's store/warehouse/
|
||||
carrier IDs, while still letting you override specific values if your
|
||||
test account uses different ones. When test mode is off, this is
|
||||
identical to config.get(key).
|
||||
"""
|
||||
if is_shipstation_test_mode():
|
||||
test_value = get(f"TEST_{key}", "")
|
||||
if test_value:
|
||||
return test_value
|
||||
return get(key, "")
|
||||
|
||||
Reference in New Issue
Block a user