Skip to content

Commit

Permalink
Rename start_time and end_time to from_date and to_date
Browse files Browse the repository at this point in the history
  • Loading branch information
Olen committed May 22, 2022
1 parent 70be08a commit eeec72f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,27 @@ loop.run_until_complete(main())
### getGroups()
Gets all your group memberships and all members of those groups

### getEvents([end_time])
### getEvents([from_date])
Gets up to 100 events.

Optional `end_time` parameter determines the earliest date from which events are returned.
Optional `from_date` parameter determines the earliest date from which events are returned.
Pass a `datetime` to get earlier events, e.g.:
```
events = await spond_session.getEvents(datetime.now() - timedelta(days=365))
```
If omitted, returns events from today - 14 days.


### getEventsBetween(start_time, end_time)
### getEventsBetween(from_date, to_date)
Gets up to 100 events.

Required `start_time` and `end_time` parameters determines the earliest and latest date from which events are returned.
Required `from_date` and `to_date` parameters determines the earliest and latest date from which events are returned.
Both expect a `datetime` object, e.g.:
```
start_time = datetime.now() - timedelta(days=30)
end_time = datetime.now() + timedelta(days=30)
from_date = datetime.now() - timedelta(days=30)
to_date = datetime.now() + timedelta(days=30)
events = await spond_session.getEventsBetween(start_time, end_time)
events = await spond_session.getEventsBetween(from_date, to_date)
```
Will return _up to_ 100 events starting from 30 days in the past until 30 days in the future.

Expand Down
12 changes: 6 additions & 6 deletions spond/spond.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,20 @@ async def sendMessage(self, recipient, text):
print(r)
return await r.json()

async def getEvents(self, end_time = None):
async def getEvents(self, from_date = None):
if not self.cookie:
await self.login()
if not end_time:
end_time = datetime.now() - timedelta(days=14)
url = self.apiurl + "sponds/?max=100&minEndTimestamp={}&order=asc&scheduled=true".format(end_time.strftime("%Y-%m-%dT00:00:00.000Z"))
if not from_date:
from_date = datetime.now() - timedelta(days=14)
url = self.apiurl + "sponds/?max=100&minEndTimestamp={}&order=asc&scheduled=true".format(from_date.strftime("%Y-%m-%dT00:00:00.000Z"))
async with self.clientsession.get(url) as r:
self.events = await r.json()
return self.events

async def getEventsBetween(self, start_time, end_time):
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(start_time.strftime("%Y-%m-%dT00:00:00.000Z"), end_time.strftime("%Y-%m-%dT00:00:00.000Z"))
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"))
async with self.clientsession.get(url) as r:
self.events = await r.json()
return self.events
Expand Down

0 comments on commit eeec72f

Please sign in to comment.