add voter delete call

This commit is contained in:
nolan 2023-12-09 10:29:51 -08:00
parent 63d8376b05
commit 898c195ede
2 changed files with 36 additions and 5 deletions

View File

@ -21,7 +21,7 @@ class Voter():
self.jwt = jwt self.jwt = jwt
def get_all(self, args = {}): def get_all(self, args = None):
""" """
get Get the voter get Get the voter
@ -37,6 +37,7 @@ class Voter():
url_args = "" url_args = ""
prefix = "" prefix = ""
if isinstance(args, dict):
for k in args: for k in args:
url_args += f"{prefix}{k}={args[k]}" url_args += f"{prefix}{k}={args[k]}"
prefix = "&" prefix = "&"
@ -151,3 +152,33 @@ class Voter():
# Log error and retunr null # Log error and retunr null
logging.error("[AFVOTER CREATE] [%s]", response.text) logging.error("[AFVOTER CREATE] [%s]", response.text)
return None return None
def delete(self, voter_key):
"""
delete Delete the Voter
:param voter_key: The Voter key to delete with API
"""
# Set the headers for the request
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': f'Bearer {self.jwt}'
}
# Run the GET
response = requests.delete(
f'{self.base_url}/api/v1/voters/{voter_key}',
headers=headers,
timeout=300
)
# Good response. Return Voter
if response.ok:
return response.json()
# Log error and retunr null
logging.error("[AFVOTER DELETE] [%s]", response.text)
return None

View File

@ -9,7 +9,7 @@ with open('README.md', 'r') as f:
setup( setup(
name='lib_af_api', name='lib_af_api',
version='0.1.3', version='0.1.4',
author='', author='',
author_email='', author_email='',
description='', description='',