|
|
@ -403,6 +403,21 @@ class Sms(APIObject):
|
|
|
|
# return self.parent._request(self.uri, method="POST", data=data)
|
|
|
|
# return self.parent._request(self.uri, method="POST", data=data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_available_numbers(areaCode, location="GB", country="44", pageSize=10):
|
|
|
|
|
|
|
|
while areaCode.startswith("0"):
|
|
|
|
|
|
|
|
areaCode = areaCode[1:]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
url = 'https://pbx.sipcentric.com/api/v1/availablenumbers?location=%s&country=%s&areaCode=%s&pageSize=%d' % (location,country,areaCode, pageSize)
|
|
|
|
|
|
|
|
while url:
|
|
|
|
|
|
|
|
r = requests.get(url, verify=True, timeout=3.0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (r.status_code == 200) or (r.status_code == 201):
|
|
|
|
|
|
|
|
response = r.json()
|
|
|
|
|
|
|
|
for item in response.get('items', []):
|
|
|
|
|
|
|
|
yield item
|
|
|
|
|
|
|
|
url = response.get('nextPage', None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|
logging.error("Do not run directly, import module first!")
|
|
|
|
logging.error("Do not run directly, import module first!")
|
|
|
|
sys.exit()
|
|
|
|
sys.exit()
|
|
|
|