From 703b39a3c5530a412c3eb0227eaa3d8f69482759 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 24 Jan 2025 00:15:52 +0530 Subject: [PATCH] fix: use v2 to get exophones list --- crm/integrations/exotel/handler.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/crm/integrations/exotel/handler.py b/crm/integrations/exotel/handler.py index 6629570d..d24613c9 100644 --- a/crm/integrations/exotel/handler.py +++ b/crm/integrations/exotel/handler.py @@ -130,24 +130,22 @@ def make_a_call(to_number, from_number=None, caller_id=None): return call_details -def get_exotel_endpoint(action=None): +def get_exotel_endpoint(action=None, version="v1"): settings = get_exotel_settings() - return "https://{api_key}:{api_token}@{subdomain}/v1/Accounts/{sid}/{action}".format( + return "https://{api_key}:{api_token}@{subdomain}/{version}/Accounts/{sid}/{action}".format( api_key=settings.api_key, api_token=settings.get_password("api_token"), subdomain=settings.subdomain, + version=version, sid=settings.account_sid, action=action, ) def get_all_exophones(): - endpoint = get_exotel_endpoint("IncomingPhoneNumbers.json") + endpoint = get_exotel_endpoint("IncomingPhoneNumbers", "v2_beta") response = requests.get(endpoint) - return [ - phone.get("IncomingPhoneNumber", {}).get("PhoneNumber") - for phone in response.json().get("IncomingPhoneNumbers", []) - ] + return [phone.get("sid") for phone in response.json().get("incoming_phone_numbers", [])] def get_status_updater_url():