Skip to content

Commit

Permalink
Merge branch 'feature/upgrade-dependencies-python-version' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
goranvrbaski committed Oct 8, 2024
2 parents 8a4dc73 + 1d9efad commit 906597c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 25 deletions.
59 changes: 35 additions & 24 deletions namesilo/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def check_error_code(error_code: tuple):
else:
raise exception_codes[error_code[0]](error_code[1])

def _get_content_xml(self, url):
def _get_content_xml(self, url: str) -> dict:
api_request = requests.get(os.path.join(self._base_url, url))
if api_request.status_code != 200:
raise Exception(
Expand All @@ -112,7 +112,7 @@ def _get_content_xml(self, url):
content = xmltodict.parse(api_request.content.decode())
return content

def check_domain(self, domain_name):
def check_domain(self, domain_name: str) -> bool:
"""
Check if domain name is available
Expand All @@ -128,7 +128,7 @@ def check_domain(self, domain_name):

return False

def get_domain_info(self, domain_name):
def get_domain_info(self, domain_name: str) -> DomainInfo:
"""
Returns information about specified domain
Expand All @@ -141,7 +141,7 @@ def get_domain_info(self, domain_name):
parsed_content = self._process_data(url_extend)
return DomainInfo(parsed_content)

def change_domain_nameservers(self, domain, primary_ns, secondary_ns):
def change_domain_nameservers(self, domain: str, primary_ns: str, secondary_ns: str) -> bool:
"""
Change name server for specified domain
Expand All @@ -157,7 +157,7 @@ def change_domain_nameservers(self, domain, primary_ns, secondary_ns):
self._process_data(url_extend)
return True

def list_domains(self):
def list_domains(self) -> list:
"""
List all domains registered with current account
Expand All @@ -168,7 +168,7 @@ def list_domains(self):
parsed_content = self._process_data(url_extend)
return parsed_content['namesilo']['reply']['domains']['domain']

def register_domain(self, domain_name, years=1, auto_renew=0, private=0):
def register_domain(self, domain_name: str, years: int = 1, auto_renew: int =0, private: int = 0) -> bool:
"""
Register a new domain name
Expand All @@ -185,7 +185,7 @@ def register_domain(self, domain_name, years=1, auto_renew=0, private=0):
self._process_data(url_extend)
return True

def renew_domain(self, domain_name, years=1):
def renew_domain(self, domain_name: str, years: int = 1) -> bool:
"""
Renew domain name
Expand All @@ -199,7 +199,7 @@ def renew_domain(self, domain_name, years=1):
self._process_data(url_extend)
return True

def lock_domain(self, domain_name: str):
def lock_domain(self, domain_name: str) -> bool:
"""
:param str domain_name:
Expand All @@ -210,7 +210,7 @@ def lock_domain(self, domain_name: str):
self._process_data(url_extend)
return True

def unlock_domain(self, domain_name: str):
def unlock_domain(self, domain_name: str) -> bool:
"""
:param str domain_name:
Expand All @@ -221,7 +221,7 @@ def unlock_domain(self, domain_name: str):
self._process_data(url_extend)
return True

def auto_renew_domain(self, domain_name: str):
def auto_renew_domain(self, domain_name: str) -> bool:
"""
Set auto-renew to specific domain
Expand All @@ -234,7 +234,7 @@ def auto_renew_domain(self, domain_name: str):
self._process_data(url_extend)
return True

def remove_auto_renew_domain(self, domain_name: str):
def remove_auto_renew_domain(self, domain_name: str) -> bool:
"""
Remove auto-renew to specific domain
Expand All @@ -258,7 +258,7 @@ def get_prices(self):
parsed_content = self._process_data(url_extend)
return parsed_content['namesilo']['reply']

def list_contacts(self):
def list_contacts(self) -> list[ContactModel]:
"""
Returns list of all contacts for current account
Expand All @@ -279,7 +279,7 @@ def list_contacts(self):

return contacts

def add_contact(self, contact):
def add_contact(self, contact: ContactModel) -> bool:
"""
Adding new contact for current account
Expand All @@ -296,7 +296,7 @@ def add_contact(self, contact):
self._process_data(url_extend)
return True

def update_contact(self, contact: ContactModel):
def update_contact(self, contact: ContactModel) -> bool:
"""
Update existing contact with new information
Expand All @@ -315,7 +315,7 @@ def update_contact(self, contact: ContactModel):
self._process_data(url_extend)
return True

def delete_contact(self, contact_id):
def delete_contact(self, contact_id) -> bool:
"""
Delete contact from NameSilo account
Expand All @@ -328,7 +328,7 @@ def delete_contact(self, contact_id):
parsed_context = self._process_data(url_extend)
return parsed_context

def add_account_funds(self, amount, payment_id):
def add_account_funds(self, amount: float, payment_id: int) -> tuple[bool, float]:
"""
Adding funds to Namesilo account
Expand All @@ -343,7 +343,7 @@ def add_account_funds(self, amount, payment_id):
amount = parsed_context['namesilo']['reply']['new_balance']
return True, float(amount.replace(",", ""))

def get_account_balance(self):
def get_account_balance(self) -> float:
"""
Returns current account balance
Expand All @@ -355,7 +355,7 @@ def get_account_balance(self):
amount = parsed_context['namesilo']['reply']['balance']
return float(amount.replace(",", ""))

def add_domain_privacy(self, domain_name):
def add_domain_privacy(self, domain_name: str) -> bool:
"""
Adds privacy to specified domain name
Expand All @@ -368,7 +368,7 @@ def add_domain_privacy(self, domain_name):
self._process_data(url_extend)
return True

def remove_domain_privacy(self, domain_name):
def remove_domain_privacy(self, domain_name: str) -> bool:
"""
Removes privacy for specified domain name
Expand All @@ -381,7 +381,7 @@ def remove_domain_privacy(self, domain_name):
self._process_data(url_extend)
return True

def list_dns_records(self, domain_name):
def list_dns_records(self, domain_name) -> list:
"""
List all DNS records for specified domain name
Expand All @@ -397,8 +397,13 @@ def list_dns_records(self, domain_name):
return records

def add_dns_records(
self, domain_name, record_type, record_host, record_value,
ttl=7207):
self,
domain_name: str,
record_type: str,
record_host: str,
record_value: str,
ttl: int = 7207
) -> int:
"""
Add DNS record to specified domain name
Expand All @@ -419,8 +424,14 @@ def add_dns_records(
return record_id

def update_dns_records(
self, domain_name, record_id, record_host, record_value,
ttl=7207):
self,
domain_name:
str,
record_id: str,
record_host: str,
record_value: str,
ttl: int = 7207
) -> int:
"""
Update an existing DNS resource record
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
version='1.5.0',
packages=find_packages(exclude=['docs', 'tests']),
install_requires=['requests', 'xmltodict'],
python_requires='>=3.7,<=3.10',
python_requires='>=3.7,<=3.12',
py_modules=['namesilo'],
classifiers=[
'Development Status :: 5 - Production/Stable',
Expand All @@ -23,6 +23,8 @@
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Software Development :: Libraries :: Python Modules'
],
Expand Down

0 comments on commit 906597c

Please sign in to comment.