added more endpoints, fixed some bugs with code generator

This commit is contained in:
Daniel 2019-08-18 22:30:31 -04:00
parent 599ea9163c
commit d1666beace
9 changed files with 62 additions and 20 deletions

View File

@ -1,3 +1,3 @@
@property @property
def {{method_name}}(self): def {{method_name}}(self):
return self.general.{{method_name}} return self.{{subdir}}.{{method_name}}

View File

@ -7,8 +7,8 @@ print("Which category does this endpoint fall under?")
subdir_index = int(input("1: accounts, 2: call_detail_records, 3: dids, 4: general, 5: voicemail: ")) subdir_index = int(input("1: accounts, 2: call_detail_records, 3: dids, 4: general, 5: voicemail: "))
subdir = ("accounts", "call_detail_records", "dids", "general", "voicemail")[subdir_index - 1] subdir = ("accounts", "call_detail_records", "dids", "general", "voicemail")[subdir_index - 1]
endpoint = "getLanguages" endpoint = "getRegistrationStatus"
method = "languages" method = "registration_status"
filename = "../voipms/api/{}/{}.py".format(subdir, method) filename = "../voipms/api/{}/{}.py".format(subdir, method)
@ -60,7 +60,7 @@ with open(filename, 'w') as file:
filename = "../voipms/api/__init__.py" filename = "../voipms/api/__init__.py"
template = env.get_template('dir_init.j2') template = env.get_template('dir_init.j2')
output = template.render(method_name=method) output = template.render(subdir=subdir, method_name=method)
with open(filename, 'a') as file: with open(filename, 'a') as file:
file.writelines("\n\n" + output) file.writelines("\n\n" + output)

View File

@ -95,3 +95,11 @@ class Client(object):
@property @property
def languages(self): def languages(self):
return self.general.languages return self.general.languages
@property
def subaccount(self):
return self.accounts.subaccount
@property
def registration_status(self):
return self.accounts.registration_status

View File

@ -1,4 +1,21 @@
from voipms.api.accounts.subaccount import Subaccount
from voipms.api.accounts.registration_status import RegistrationStatus
class Accounts(): class Accounts():
def __init__(self, base): def __init__(self, base):
self._balance = None self._subaccount = None
self._registration_status = None
self.base = base self.base = base
@property
def subaccount(self):
if self._subaccount is None:
self._subaccount = Subaccount(self.base)
return self._subaccount
@property
def registration_status(self):
if self._registration_status is None:
self._registration_status = RegistrationStatus(self.base)
return self._registration_status

View File

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

View File

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

View File

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

View File

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

View File

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