add create voter call

This commit is contained in:
nolan 2023-12-08 23:27:19 -08:00
parent 1d0fe2dced
commit 1d547c26ad
2 changed files with 33 additions and 1 deletions

View File

@ -120,3 +120,35 @@ class Voter():
# Log error and retunr null
logging.error("[AFVOTER UPDATE] [%s]", response.text)
return None
def post(self, voter_key, post_data):
"""
post Post the Voter
:param voter_key: The Voter key to update with API
:param post_data: The data to create the Voter
"""
# Set the headers for the request
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': f'Bearer {self.jwt}'
}
# Run the GET
response = requests.post(
f'{self.base_url}/api/v1/voters',
headers=headers,
timeout=300,
json=post_data
)
# Good response. Return Voter
if response.ok:
return response.json()
# Log error and retunr null
logging.error("[AFVOTER CREATE] [%s]", response.text)
return None

View File

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