membershipworks: Add methods to get event listing and events by eid/url

This commit is contained in:
Adam Goldsmith 2022-10-28 15:27:03 -04:00
parent cf55c2aed5
commit 68c9b3f82d

View File

@ -2,6 +2,7 @@ import csv
from io import StringIO from io import StringIO
import requests import requests
import datetime
BASE_URL = "https://api.membershipworks.com" BASE_URL = "https://api.membershipworks.com"
@ -236,3 +237,29 @@ class MembershipWorks:
fields = self._all_fields() fields = self._all_fields()
members = self.get_members(folders, ",".join(fields.keys())) members = self.get_members(folders, ",".join(fields.keys()))
return members 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"),
},
)
return r.json()
def get_event_by_eid(self, eid: str):
"""Retrieve a specific event by its event id (eid)"""
r = self.sess.get(
BASE_URL + "/v2/event",
params={"eid": eid},
)
return r.json()
def get_event_by_url(self, url: str):
"""Retrieve a specific event by its url"""
r = self.sess.get(
BASE_URL + "/v2/event",
params={"url": url},
)
return r.json()