From 5fb79ba2d77ffdae80b536543605cb8cc46aa5d7 Mon Sep 17 00:00:00 2001 From: nolan Date: Sat, 9 Dec 2023 23:03:04 -0800 Subject: [PATCH] add event get all --- lib_af_api/event.py | 34 ++++++++++++++++++++++++++++++++++ setup.py | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/lib_af_api/event.py b/lib_af_api/event.py index 745d9a7..d47f799 100644 --- a/lib_af_api/event.py +++ b/lib_af_api/event.py @@ -21,6 +21,40 @@ class Event(): 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): """ get Get the event diff --git a/setup.py b/setup.py index f178167..b1b430e 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.4', + version='0.1.5', author='', author_email='', description='',