Added get_all() to the business and campaign classes

This commit is contained in:
Rick Ross 2024-03-04 10:30:18 -08:00
parent 40e4ffa750
commit 0bc6905e79
2 changed files with 68 additions and 0 deletions

View File

@ -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

View File

@ -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