added main route
This commit is contained in:
25
app/main.py
25
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():
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user