commit
56be2cea63
1 changed files with 5 additions and 4 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
"""Run My Accounts (Infoniqa) accounting connector.
|
"""Run My Accounts (Infoniqa) accounting connector.
|
||||||
|
|
||||||
API docs: https://runmyaccountsag.github.io/runmyaccounts-rest-api/
|
API docs: https://runmyaccountsag.github.io/runmyaccounts-rest-api/
|
||||||
Auth: Static API key via X-RMA-KEY header.
|
Auth: API key (incl. ``pat_`` tokens since Sep 2025) via ``X-RMA-KEY`` request header.
|
||||||
Base URL: https://service.runmyaccounts.com/api/latest/clients/{clientName}/
|
Base URL: https://service.runmyaccounts.com/api/latest/clients/{clientName}/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -59,11 +59,10 @@ class AccountingConnectorRma(BaseAccountingConnector):
|
||||||
return f"{_BASE_URL}/{clientName}/{resource}"
|
return f"{_BASE_URL}/{clientName}/{resource}"
|
||||||
|
|
||||||
def _buildHeaders(self, config: Dict[str, Any]) -> Dict[str, str]:
|
def _buildHeaders(self, config: Dict[str, Any]) -> Dict[str, str]:
|
||||||
"""PAT must not be in query params; RMA expects Authorization header."""
|
|
||||||
apiKey = config.get("apiKey", "")
|
apiKey = config.get("apiKey", "")
|
||||||
return {
|
return {
|
||||||
"Authorization": f"Bearer {apiKey}",
|
"X-RMA-KEY": apiKey,
|
||||||
"Accept": "application/json, application/xml, */*", # RMA may return XML on error (e.g. 406)
|
"Accept": "application/json, application/xml, */*",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,6 +75,7 @@ class AccountingConnectorRma(BaseAccountingConnector):
|
||||||
|
|
||||||
url = self._buildUrl(config, "customers")
|
url = self._buildUrl(config, "customers")
|
||||||
headers = self._buildHeaders(config)
|
headers = self._buildHeaders(config)
|
||||||
|
logger.info("RMA testConnection: url=%s, clientName=%s, apiKey=%s...", url, clientName, apiKey[:6] if len(apiKey) > 6 else "***")
|
||||||
try:
|
try:
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.get(url, headers=headers, timeout=aiohttp.ClientTimeout(total=15)) as resp:
|
async with session.get(url, headers=headers, timeout=aiohttp.ClientTimeout(total=15)) as resp:
|
||||||
|
|
@ -83,6 +83,7 @@ class AccountingConnectorRma(BaseAccountingConnector):
|
||||||
logger.info("RMA connection successful")
|
logger.info("RMA connection successful")
|
||||||
return SyncResult(success=True)
|
return SyncResult(success=True)
|
||||||
body = await resp.text()
|
body = await resp.text()
|
||||||
|
logger.warning("RMA testConnection failed: status=%s, url=%s, body=%s", resp.status, url, body[:500])
|
||||||
return SyncResult(success=False, errorMessage=f"HTTP {resp.status}: {body[:300]}")
|
return SyncResult(success=False, errorMessage=f"HTTP {resp.status}: {body[:300]}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return SyncResult(success=False, errorMessage=str(e))
|
return SyncResult(success=False, errorMessage=str(e))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue