diff --git a/lib_af_api/business.py b/lib_af_api/business.py index ce519c7..e31fdb4 100644 --- a/lib_af_api/business.py +++ b/lib_af_api/business.py @@ -21,6 +21,40 @@ class Business(): self.jwt = jwt + def get_all(self, args = None): + """ + get_all Get the businesses + + :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/businesses', + params=args, + headers=headers, + timeout=300 + ) + + # Good response. Return Events + if response.ok: + return response.json() + + # Log error and return null + logging.error("[AFBUSINESS GET ALL] [%s]", response.text) + return None + + def get(self, business_key): """ get Get the business diff --git a/lib_af_api/campaign.py b/lib_af_api/campaign.py index 0738ce8..39e6c7e 100644 --- a/lib_af_api/campaign.py +++ b/lib_af_api/campaign.py @@ -21,6 +21,40 @@ class Campaign(): self.jwt = jwt + def get_all(self, args = None): + """ + get_all Get the campaigns + + :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/campaigns', + params=args, + headers=headers, + timeout=300 + ) + + # Good response. Return Events + if response.ok: + return response.json() + + # Log error and return null + logging.error("[AFCAMPAIGN GET ALL] [%s]", response.text) + return None + + def get(self, campaign_key): """ get Get the campaign