GameApi
is the Web Portal service that talks to the game.
Table of Contents
The Game API service supports two primary methods:
requestOne
- Requests a single object or a complex composite object.requestMany
- Requests a simple list of objects.For example:
gameApi: service(),
model: function() {
let aj = this.get('gameApi');
return aj.requestOne('events');
},
requestOne
because they get back a composite object. The events request, for example, returns a model that contains events and the calendar URL.
Both of the request methods take the request name (similar to a command name in the game code). Some requests take additional parameters. For example, the following request takes the event ID from the route parameters /event/<event id>
and passes it on to the game:
return aj.requestOne('event', {event_id: params['event_id']});
A few routes perform multiple game requests and bundle them together into a single model object. Their model looks like this:
return RSVP.hash({
types: aj.request('censusTypes'),
census: aj.requestOne('censusFull'),
})
.then((model) => Ember.Object.create(model));
Here the code would wait until both requests completed, then make a single model with model.types
and model.census
.
See Web Request Handling for more information about how this request is handled in the game engine.