Compare commits
2 Commits
898c195ede
...
6f56643466
| Author | SHA1 | Date |
|---|---|---|
|
|
6f56643466 | |
|
|
5fb79ba2d7 |
|
|
@ -21,6 +21,40 @@ class Event():
|
||||||
self.jwt = jwt
|
self.jwt = jwt
|
||||||
|
|
||||||
|
|
||||||
|
def get_all(self, args = None):
|
||||||
|
"""
|
||||||
|
get_all Get the events
|
||||||
|
|
||||||
|
:param args: Dict of args to add as URL params
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Set the headers for the request
|
||||||
|
headers = {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Authorization': f'Bearer {self.jwt}'
|
||||||
|
}
|
||||||
|
|
||||||
|
if not isinstance(args, dict):
|
||||||
|
args = {}
|
||||||
|
|
||||||
|
# Run the GET
|
||||||
|
response = requests.get(
|
||||||
|
f'{self.base_url}/api/v1/events',
|
||||||
|
params=args,
|
||||||
|
headers=headers,
|
||||||
|
timeout=300
|
||||||
|
)
|
||||||
|
|
||||||
|
# Good response. Return Events
|
||||||
|
if response.ok:
|
||||||
|
return response.json()
|
||||||
|
|
||||||
|
# Log error and retunr null
|
||||||
|
logging.error("[AFEVENT GET ALL] [%s]", response.text)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get(self, event_key):
|
def get(self, event_key):
|
||||||
"""
|
"""
|
||||||
get Get the event
|
get Get the event
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ class Voter():
|
||||||
|
|
||||||
def get_all(self, args = None):
|
def get_all(self, args = None):
|
||||||
"""
|
"""
|
||||||
get Get the voter
|
get_all Get the voter
|
||||||
|
|
||||||
:param args: Dict of args to add as URL params
|
:param args: Dict of args to add as URL params
|
||||||
"""
|
"""
|
||||||
|
|
@ -35,16 +35,13 @@ class Voter():
|
||||||
'Authorization': f'Bearer {self.jwt}'
|
'Authorization': f'Bearer {self.jwt}'
|
||||||
}
|
}
|
||||||
|
|
||||||
url_args = ""
|
if not isinstance(args, dict):
|
||||||
prefix = ""
|
args = {}
|
||||||
if isinstance(args, dict):
|
|
||||||
for k in args:
|
|
||||||
url_args += f"{prefix}{k}={args[k]}"
|
|
||||||
prefix = "&"
|
|
||||||
|
|
||||||
# Run the GET
|
# Run the GET
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
f'{self.base_url}/api/v1/voters?{url_args}',
|
f'{self.base_url}/api/v1/voters',
|
||||||
|
params=args,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
timeout=300
|
timeout=300
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue