membershipworks: Allow get_events_list to use end date, retrieve categories

This commit is contained in:
Adam Goldsmith 2023-12-30 13:27:19 -05:00
parent 08dde9a4f4
commit 546b13428e

View File

@ -238,14 +238,25 @@ class MembershipWorks:
members = self.get_members(folders, ",".join(fields.keys()))
return members
def get_events_list(self, start_date: datetime.datetime):
"""Retrive a list of events since start_date"""
r = self.sess.get(
BASE_URL + "/v2/events",
params={
"sdp": start_date.strftime("%s"),
},
)
def get_events_list(
self,
start_date: datetime.datetime = None,
end_date: datetime.datetime = None,
categories=False,
):
"""Retrive a list of events between `start_date` and `end_date`, optionally including category information"""
if start_date is None and end_date is None:
raise ValueError("Must specify one of start_date or end_date")
params = {}
if start_date is not None:
params["sdp"] = start_date.strftime("%s")
if end_date is not None:
params["edp"] = end_date.strftime("%s")
if categories is not None:
params["_st"] = ""
r = self.sess.get(BASE_URL + "/v2/events", params=params)
return r.json()
def get_event_by_eid(self, eid: str):