diff --git a/templates/dir_init.j2 b/templates/dir_init.j2 index 038a6e7..bf178cf 100644 --- a/templates/dir_init.j2 +++ b/templates/dir_init.j2 @@ -1,3 +1,3 @@ @property def {{method_name}}(self): - return self.general.{{method_name}} \ No newline at end of file + return self.{{subdir}}.{{method_name}} \ No newline at end of file diff --git a/templates/method_generator.py b/templates/method_generator.py index 082347f..fd4b484 100644 --- a/templates/method_generator.py +++ b/templates/method_generator.py @@ -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 = ("accounts", "call_detail_records", "dids", "general", "voicemail")[subdir_index - 1] -endpoint = "getLanguages" -method = "languages" +endpoint = "getRegistrationStatus" +method = "registration_status" filename = "../voipms/api/{}/{}.py".format(subdir, method) @@ -60,7 +60,7 @@ with open(filename, 'w') as file: filename = "../voipms/api/__init__.py" 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: file.writelines("\n\n" + output) \ No newline at end of file diff --git a/voipms/api/__init__.py b/voipms/api/__init__.py index a57af24..6bb676f 100644 --- a/voipms/api/__init__.py +++ b/voipms/api/__init__.py @@ -86,12 +86,20 @@ class Client(object): @property def transaction_history(self): - return self.general.transaction_history - - @property - def countries(self): - return self.general.countries - - @property - def languages(self): - return self.general.languages \ No newline at end of file + return self.general.transaction_history + + @property + def countries(self): + return self.general.countries + + @property + def languages(self): + return self.general.languages + + @property + def subaccount(self): + return self.accounts.subaccount + + @property + def registration_status(self): + return self.accounts.registration_status \ No newline at end of file diff --git a/voipms/api/accounts/__init__.py b/voipms/api/accounts/__init__.py index b3beea9..96e8103 100644 --- a/voipms/api/accounts/__init__.py +++ b/voipms/api/accounts/__init__.py @@ -1,4 +1,21 @@ -class Accounts(): - def __init__(self, base): - self._balance = None - self.base = base \ No newline at end of file +from voipms.api.accounts.subaccount import Subaccount +from voipms.api.accounts.registration_status import RegistrationStatus + +class Accounts(): + def __init__(self, base): + self._subaccount = None + self._registration_status = None + + 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 \ No newline at end of file diff --git a/voipms/api/accounts/registration_status.py b/voipms/api/accounts/registration_status.py new file mode 100644 index 0000000..6f7466d --- /dev/null +++ b/voipms/api/accounts/registration_status.py @@ -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) \ No newline at end of file diff --git a/voipms/api/accounts/subaccount.py b/voipms/api/accounts/subaccount.py new file mode 100644 index 0000000..1f0a872 --- /dev/null +++ b/voipms/api/accounts/subaccount.py @@ -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) \ No newline at end of file diff --git a/voipms/api/call_detail_records/__init__.py b/voipms/api/call_detail_records/__init__.py index 558addf..6bc83fc 100644 --- a/voipms/api/call_detail_records/__init__.py +++ b/voipms/api/call_detail_records/__init__.py @@ -1,4 +1,5 @@ + class CallDetailRecords(): def __init__(self, base): - self._balance = None + self.base = base \ No newline at end of file diff --git a/voipms/api/dids/__init__.py b/voipms/api/dids/__init__.py index 6bb48d2..f53977b 100644 --- a/voipms/api/dids/__init__.py +++ b/voipms/api/dids/__init__.py @@ -1,4 +1,5 @@ + class DIDs(): def __init__(self, base): - self._balance = None + self.base = base \ No newline at end of file diff --git a/voipms/api/voicemail/__init__.py b/voipms/api/voicemail/__init__.py index 00e23aa..741dd7e 100644 --- a/voipms/api/voicemail/__init__.py +++ b/voipms/api/voicemail/__init__.py @@ -1,4 +1,5 @@ + class Voicemail(): def __init__(self, base): - self._balance = None + self.base = base \ No newline at end of file