fix: use v2 to get exophones list
This commit is contained in:
parent
6b23b29a6a
commit
703b39a3c5
@ -130,24 +130,22 @@ def make_a_call(to_number, from_number=None, caller_id=None):
|
|||||||
return call_details
|
return call_details
|
||||||
|
|
||||||
|
|
||||||
def get_exotel_endpoint(action=None):
|
def get_exotel_endpoint(action=None, version="v1"):
|
||||||
settings = get_exotel_settings()
|
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_key=settings.api_key,
|
||||||
api_token=settings.get_password("api_token"),
|
api_token=settings.get_password("api_token"),
|
||||||
subdomain=settings.subdomain,
|
subdomain=settings.subdomain,
|
||||||
|
version=version,
|
||||||
sid=settings.account_sid,
|
sid=settings.account_sid,
|
||||||
action=action,
|
action=action,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_all_exophones():
|
def get_all_exophones():
|
||||||
endpoint = get_exotel_endpoint("IncomingPhoneNumbers.json")
|
endpoint = get_exotel_endpoint("IncomingPhoneNumbers", "v2_beta")
|
||||||
response = requests.get(endpoint)
|
response = requests.get(endpoint)
|
||||||
return [
|
return [phone.get("sid") for phone in response.json().get("incoming_phone_numbers", [])]
|
||||||
phone.get("IncomingPhoneNumber", {}).get("PhoneNumber")
|
|
||||||
for phone in response.json().get("IncomingPhoneNumbers", [])
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def get_status_updater_url():
|
def get_status_updater_url():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user