Skip to content

Commit

Permalink
fix: use v2 to get exophones list
Browse files Browse the repository at this point in the history
  • Loading branch information
shariquerik committed Jan 23, 2025
1 parent 6b23b29 commit 703b39a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions crm/integrations/exotel/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 703b39a

Please sign in to comment.