add create voter call
This commit is contained in:
parent
1d0fe2dced
commit
1d547c26ad
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue