Skip to content

Commit

Permalink
API adapter docs
Browse files Browse the repository at this point in the history
  • Loading branch information
DanNixon committed Mar 31, 2024
1 parent 80918a8 commit 40c23c5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
25 changes: 25 additions & 0 deletions adapter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# API adapter

The adapter is a small shim that sits between applications and the [official schedule API](https://developer.emfcamp.org/schedule).

It adds a few nice features on top of the official API:

- RFC 3339 timestamps (not some RFC 3339-like but actually not nonsense)
- Filtering by multiple venues
- Filtering by timestamps
- A now and next API that is not dependant on being part way through the event to develop for
- Listing venues

## Examples

It is likely useful to stuff the output of these into your JSON visualiser of choice (e.g. pipe to `| jq | less`).

- List the entire schedule: `curl "localhost:8000/schedule"`
- List events for a specific venue: `curl "localhost:8000/schedule?venue=Stage+A"`
- List events for a set of venues: `curl "localhost:8000/schedule?venue=Stage+A&venue=Stage+B"`
- List events starting after a certain time (i.e. events that are in progress and in the future as of the given time): `curl "localhost:8000/schedule?starting_after=2022-06-05T12:00:00%2b01:00"`
- List events ending after a certain time (i.e. events that are in the future/yet to start as of the given time): `curl "localhost:8000/schedule?ending_after=2022-06-05T12:00:00%2b01:00"`
- List the entire schedule, using a fake start time for the first event and offsetting the rest of the schedule accordingly (useful for development): `curl "localhost:8000/schedule?fake_epoch=2024-04-01T17:00:00%2b01:00"`
- Now and next, for all venues, at the time of the request: `curl "localhost:8000/now-and-next"`
- Now and next, for "Stage A" and "Blacksmiths" venues, for a specific point in time, with a fake epoch: `curl "localrost:8000/now-and-next?fake_epoch=2024-04-01T17:00:00%2b01:00&now=2024-04-02T17:15:00%2b01:00&venue=Stage+A&venue=Blacksmiths"`
- List all venues: `curl "localhost:8000/venues"`
6 changes: 2 additions & 4 deletions adapter/src/queries/now_and_next.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(crate) struct NowAndNextQueryParams {

/// Use this time instead of the actual currrent time when evaluating events against time based filters.
/// For development use.
fake_current_time: Option<DateTime<FixedOffset>>,
now: Option<DateTime<FixedOffset>>,

/// Include only events that take place at these venues.
#[serde(rename = "venue")]
Expand Down Expand Up @@ -46,9 +46,7 @@ pub(crate) async fn now_and_next(
) -> Response {
let mut schedule = state.client.get_schedule().await;

let now = query
.fake_current_time
.unwrap_or_else(|| Local::now().into());
let now = query.now.unwrap_or_else(|| Local::now().into());

let mutators = query.into();
schedule.mutate(&mutators);
Expand Down

0 comments on commit 40c23c5

Please sign in to comment.