getIP endpoint now reachable

This commit is contained in:
Daniel 2019-08-17 22:34:44 -04:00
parent f605b65b6c
commit 297a67f57e
9 changed files with 78 additions and 69 deletions

63
.gitignore vendored
View File

@ -3,58 +3,35 @@ __pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Installer logs
pip-log.txt
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
dist
build
eggs
parts
bin
develop-eggs
.installed.cfg
*.egg
MANIFEST
scratch
env
venv*
wheels
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
.tox
test.py
.DS_Store
#htmlcov
htmlcov*
# pyenv
.python-version
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.vscode/

View File

@ -1,6 +1,8 @@
import os
import platform
import json
import requests
from voipms.base.exceptions import VoipException
class Client(object):
@ -30,8 +32,14 @@ class Client(object):
params["method"] = method
params["content_type"] = "json"
response = requests.get(self.api_base, params=params).json()
return response
response = requests.get(self.api_base, params=params)
data = json.loads(response.text)
if data['status'] and data['status'] != 'success':
err = data['status']
raise VoipException("API Call failed with exception: {}".format(err))
return data
@property
def accounts(self):
@ -44,30 +52,34 @@ class Client(object):
def call_detail_records(self):
if self._call_detail_records is None:
from voipms.api.call_detail_records import CallDetailRecords
self._call_detail_records = CallDetailRecords()
self._call_detail_records = CallDetailRecords(self)
return self._call_detail_records
@property
def dids(self):
if self._dids is None:
from voipms.api.dids import DIDs
self._dids = DIDs()
self._dids = DIDs(self)
return self._dids
@property
def general(self):
if self._general is None:
from voipms.api.general import General
self._general = General()
self._general = General(self)
return self._general
@property
def voicemail(self):
if self._voicemail is None:
from voipms.api.voicemail import Voicemail
self._voicemail = Voicemail()
self._voicemail = Voicemail(self)
return self._voicemail
@property
def balance(self):
return self.accounts.balance
return self.general.balance
@property
def ip(self):
return self.general.ip

View File

@ -1,12 +1,4 @@
from voipms.api.accounts.balance import Balance
class Accounts():
def __init__(self, base):
self._balance = None
self.base = base
@property
def balance(self):
if self._balance is None:
self._balance = Balance(self.base)
return self._balance
def __init__(self, base):
self._balance = None
self.base = base

View File

@ -1,3 +1,4 @@
class CallDetailRecords():
def __init__(self):
pass
def __init__(self, base):
self._balance = None
self.base = base

View File

@ -1,3 +1,4 @@
class DIDs():
def __init__(self):
pass
def __init__(self, base):
self._balance = None
self.base = base

View File

@ -1,3 +1,21 @@
from voipms.api.general.balance import Balance
from voipms.api.general.ip import IP
class General():
def __init__(self):
pass
def __init__(self, base):
self._balance = None
self._ip = None
self.base = base
@property
def balance(self):
if self._balance is None:
self._balance = Balance(self.base)
return self._balance
@property
def ip(self):
if self._ip is None:
self._ip = IP(self.base)
return self._ip

7
voipms/api/general/ip.py Normal file
View File

@ -0,0 +1,7 @@
class IP():
def __init__(self, base):
self.method = "getIP"
self.base = base
def fetch(self, params={}):
return self.base.request(self.method)

View File

@ -1,3 +1,4 @@
class Voicemail():
def __init__(self):
self._balance = None
def __init__(self, base):
self._balance = None
self.base = base