- Advoware API Proxy für alle HTTP-Methoden (GET/POST/PUT/DELETE) - EspoCRM Webhook-Receiver für Beteiligte CRUD-Operationen - Redis-basierte Deduplikation für Webhook-Events - Event-driven Synchronisations-Handler (Placeholder) - Detaillierte README.md mit Setup und Verwendungsanleitung - Fehlerbehebungen für Context-Attribute und Redis-Verbindungen
34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
from services.advoware import AdvowareAPI
|
|
|
|
config = {
|
|
'type': 'api',
|
|
'name': 'Advoware Proxy DELETE',
|
|
'description': 'Universal proxy for Advoware API (DELETE)',
|
|
'path': '/advoware/proxy',
|
|
'method': 'DELETE',
|
|
'emits': [],
|
|
'flows': ['basic-tutorial', 'advoware']
|
|
}
|
|
|
|
async def handler(req, context):
|
|
try:
|
|
# Endpoint aus Query-Parametern
|
|
endpoint = req.get('queryParams', {}).get('endpoint', '')
|
|
if not endpoint:
|
|
return {'status': 400, 'body': {'error': 'Endpoint required as query param'}}
|
|
|
|
advoware = AdvowareAPI(context)
|
|
method = 'DELETE' # Feste Methode für diesen Step
|
|
params = {k: v for k, v in req.get('queryParams', {}).items() if k != 'endpoint'}
|
|
json_data = None
|
|
|
|
context.logger.info(f"Proxying request to Advoware: {method} {endpoint}")
|
|
context.logger.info(f"Query params: {params}")
|
|
result = await advoware.api_call(endpoint, method=method, params=params, json_data=json_data)
|
|
context.logger.info(f"Advoware API response received, length: {len(str(result)) if result else 0}")
|
|
context.logger.info(f"Response preview: {str(result)[:500] if result else 'None'}")
|
|
|
|
return {'status': 200, 'body': {'result': result}}
|
|
except Exception as e:
|
|
context.logger.error(f"Proxy error: {e}")
|
|
return {'status': 500, 'body': {'error': 'Internal server error', 'details': str(e)}} |