Added get_all() to the business and campaign classes
This commit is contained in:
parent
40e4ffa750
commit
0bc6905e79
|
|
@ -21,6 +21,40 @@ class Business():
|
||||||
self.jwt = jwt
|
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):
|
def get(self, business_key):
|
||||||
"""
|
"""
|
||||||
get Get the business
|
get Get the business
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,40 @@ class Campaign():
|
||||||
self.jwt = jwt
|
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):
|
def get(self, campaign_key):
|
||||||
"""
|
"""
|
||||||
get Get the campaign
|
get Get the campaign
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue