diff --git a/lib_af_api/voter.py b/lib_af_api/voter.py index c3087de..ebb7c61 100644 --- a/lib_af_api/voter.py +++ b/lib_af_api/voter.py @@ -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 diff --git a/setup.py b/setup.py index 3925f3f..5a46f4f 100644 --- a/setup.py +++ b/setup.py @@ -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='',