From d2cfe29daadf4a208b55218b86a365716847c05b Mon Sep 17 00:00:00 2001 From: Edwin Eames Date: Sun, 12 Oct 2025 12:11:06 -0400 Subject: [PATCH] added main route --- app/main.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/app/main.py b/app/main.py index 0717938..61f6e9e 100644 --- a/app/main.py +++ b/app/main.py @@ -69,15 +69,34 @@ def test_did_info(): } try: response = requests.get(settings.voipms_api_url, params=params) - print(f"Test Request URL: {response.request.url}") - print(f"Test Response: {response.json()}") return response.json() except requests.exceptions.RequestException as e: return {"error": f"Failed to connect to VoIP.ms API: {str(e)}", "params": params} except Exception as e: return {"error": f"Unexpected error: {str(e)}", "params": params} - +@app.post("/route/main", status_code=status.HTTP_200_OK, tags=["DID Routing"]) +def route_to_sip_account(): + """ + Routes the target DID to the pre-configured SIP account. + """ + try: + # Use sub-account ID from TARGET_SIP_ACCOUNT + sip_account_id = '407323' + routing_string = f"account:{407323}" # e.g., 'account:407323_auburnoil' + result = update_did_routing(did=settings.target_did, routing=routing_string) + target_phone = sip_account_id + db = Session() + db.add(Call(current_phone=target_phone)) + db.commit() + db.close() + return { + "message": f"Successfully routed DID {settings.target_did} to SIP account {settings.target_sip_account}", + "voipms_response": result + } + except HTTPException as e: + raise e + @app.post("/route/sip", status_code=status.HTTP_200_OK, tags=["DID Routing"]) def route_to_sip_account(): """