Skip to content

Commit

Permalink
Merge pull request #19 from elliot-100/get_more_events2
Browse files Browse the repository at this point in the history
Optional `max_events` parameter for `getEventsBetween`
  • Loading branch information
Olen authored Aug 15, 2022
2 parents 4a9da05 + 3124975 commit aa7f8fd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions spond/spond.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ async def getEvents(self, from_date = None):
self.events = await r.json()
return self.events

async def getEventsBetween(self, from_date, to_date):
async def getEventsBetween(self, from_date, to_date, max_events=100):
"""
Get up to 100 events between two datetimes.
Get events between two datetimes.
Subject to authenticated user's access.
Excludes cancelled events.
Expand All @@ -160,6 +160,8 @@ async def getEventsBetween(self, from_date, to_date):
Only return events which finish after this value.
to_date : datetime
Only return events which finish before this value.
max_events : int, optional
Set a limit on the number of events returned
Returns
-------
Expand All @@ -168,7 +170,13 @@ async def getEventsBetween(self, from_date, to_date):
"""
if not self.cookie:
await self.login()
url = self.apiurl + "sponds/?max=100&minEndTimestamp={}&maxEndTimestamp={}&order=asc&scheduled=true".format(from_date.strftime("%Y-%m-%dT00:00:00.000Z"), to_date.strftime("%Y-%m-%dT00:00:00.000Z"))
url = (
f"{self.apiurl}sponds/?"
f"max={max_events}&"
f"minEndTimestamp={from_date.strftime('%Y-%m-%dT00:00:00.000Z')}&"
f"maxEndTimestamp={to_date.strftime('%Y-%m-%dT00:00:00.000Z')}&"
f"order=asc&scheduled=true"
)
async with self.clientsession.get(url) as r:
self.events = await r.json()
return self.events
Expand Down

0 comments on commit aa7f8fd

Please sign in to comment.