APIService

AngularJS Service for managing generic API calls. Also stores default settings for API calls such as game_id.

Requires

Members

(private, inner, nullable) game_id :number

Stored game_id to use as default when API calls do not specify one.

Source:
Type:
  • number

Methods

(static) setGameId(idnullable)

Set stored default game ID module:APIService~game_id

Source:
Parameters:
Name Type Attributes Description
id number <nullable>

(static) getGameId() → (nullable) {number}

Get stored default game ID module:APIService~game_id

Source:
Returns:
Type:
number

The default game_id currently stored in the module instance.

(static) call(params) → {Promise}

Generic wrapper function for API calls using angular $http service. Used by most public methods in the module.

If debugService.get('noAPI') is true, this will not perform any API request, and will immediately resolve as if the request responded successfully with the data { noAPI: true }.

Source:
Parameters:
Name Type Description
params Object
Name Type Attributes Description
method string

HTTP method

url string

URL endpoint (added to the environment's serverAddress)

params Object <optional>

Query parameters.

data Object <optional>

Request message data.

config Object <optional>

Set $http config properties, can override call function args

onSuccess $httpDataCallback <optional>

Callback to run on success (receives response data only).

onError $httpCallback <optional>

Callback to run on error (receives full response object).

Returns:
Type:
Promise

Promise object, either:

  • Resolved with the result of the onSuccess callback or the HTTP response data.
  • Rejected with the result of the onError callback, the full HTTP response object, or an error.

(static) getGame(params, onSuccessopt) → {Promise}

Get game information.

Source:
See:
Parameters:
Name Type Attributes Description
params Object
Name Type Attributes Description
domain string
game_id number <optional>
slug string <optional>
token string <optional>
onSuccess $httpDataCallback <optional>
Returns:
Type:
Promise

Promise object, either:

  • Resolved with the result of the onSuccess callback or the HTTP response data.
  • Rejected with the full HTTP response object or an error.

(static) getGameFile(url, onSuccessopt) → {Promise}

Get Game Data from a file

Source:
Parameters:
Name Type Attributes Description
url string
onSuccess $httpDataCallback <optional>
Returns:
Type:
Promise

Promise object, either:

  • Resolved with the result of the onSuccess callback or the HTTP response data.
  • Rejected with the full HTTP response object or an error.

(static) getScore(params, onSuccessopt) → {Promise}

Get player's high score for a game.

Source:
See:
Parameters:
Name Type Attributes Description
params Object
Name Type Attributes Default Description
game_id number <optional>
module:APIService~game_id
best string <optional>
'highest'
onSuccess $httpDataCallback <optional>
Returns:
Type:
Promise

Promise object, either:

  • Resolved with the result of the onSuccess callback or the HTTP response data.
  • Rejected with the full HTTP response object or an error.

(static) reportScore(data, onSuccessopt, noSVopt) → {Promise}

Add player's score for a game. Only the player's high score for each game is reported in Score and Leaderboard calls.

Source:
See:
Parameters:
Name Type Attributes Default Description
data Object

Request message data (may include entries besides those listed below).

Name Type Attributes Default Description
game_id number <optional>
module:APIService~game_id
points number <optional>
0
time number <optional>
0
level_id number <optional>
onSuccess $httpDataCallback <optional>
noSV boolean <optional>
false
Returns:
Type:
Promise

Promise object, either:

  • Resolved with the result of the onSuccess callback or the HTTP response data.
  • Rejected with the full HTTP response object or an error.

(static) reportAnswer(data, onSuccessopt) → {Promise}

Add an answer attempt.

Source:
See:
Parameters:
Name Type Attributes Description
data Object

Request message data (may include entries besides those listed below).

Name Type Attributes Default Description
game_id number <optional>
module:APIService~game_id
level_id number <optional>
question_id number
correct Boolean
answer_id string <optional>
answer_text string <optional>
time number
onSuccess $httpDataCallback <optional>
  • @param {$httpDataCallback} [onError]
Returns:
Type:
Promise

Promise object, either:

  • Resolved with the result of the onSuccess callback or the HTTP response data.
  • Rejected with the full HTTP response object or an error.

(static) getQuestionLeaderboard(question_id, params, onSuccess) → {Promise}

Get leaderboard for a game for a specific question

Source:
See:
Parameters:
Name Type Description
question_id number
params Object

Query parameters (may include entries besides those listed below).

Name Type Attributes Default Description
game_id string <optional>
module:APIService~game_id
onSuccess $httpDataCallback
Returns:
Type:
Promise

Promise object, either:

  • Resolved with the result of the onSuccess callback or the HTTP response data.
  • Rejected with the full HTTP response object or an error.

(static) getLeaderboard(params, onSuccess) → {Promise}

Get leaderboard for a game

Source:
See:
Parameters:
Name Type Description
params Object

Query parameters (may include entries besides those listed below).

Name Type Attributes Default Description
game_id string <optional>
module:APIService~game_id
best string <optional>
'highest'
limit number <optional>
start_date string <optional>
end_date string <optional>
onSuccess $httpDataCallback
Returns:
Type:
Promise

Promise object, either:

  • Resolved with the result of the onSuccess callback or the HTTP response data.
  • Rejected with the full HTTP response object or an error.

(static) getInstructorLeaderboard(params, onSuccess) → {Promise}

Get instructor leaderboard

Source:
Parameters:
Name Type Description
params Object

Query parameters (may include entries besides those listed below).

Name Type Attributes Description
slug string <optional>
onSuccess $httpDataCallback
Returns:
Type:
Promise

Promise object, either:

  • Resolved with the HTTP response object
  • Rejected with the full HTTP response object or an error.

(static) getInstructorState(slug) → {Promise}

Get instructor state

Source:
See:
Parameters:
Name Type Description
slug string
Returns:
Type:
Promise

Promise object, either:

(static) getInstructorPlayers(data) → {Promise}

Get instructor players

Source:
Parameters:
Name Type Description
data object
Name Type Description
session_group_id number
Returns:
Type:
Promise

Promise object, either:

  • Resolved with the number of players.
  • Rejected with the full HTTP response object or an error.

(static) getQuestionResults(data) → {Promise}

Get results of question

Source:
Parameters:
Name Type Description
data object
Name Type Description
session_group_id number
question_id number
Returns:
Type:
Promise

Promise object, either:

  • Resolved with the HTTP response object.
  • Rejected with the full HTTP response object or an error.

(static) getQuestionAudio(question_id) → {Promise}

Get audio data for a question ID.

Source:
See:
Parameters:
Name Type Description
question_id number
Returns:
Type:
Promise

Promise object, either:

  • Resolved with the HTTP response data.
  • Rejected with the full HTTP response object or an error.