Browse Source

Bumping API version and adding the new endpoints

Kirk Trombley 5 years ago
parent
commit
eb2d59b145
2 changed files with 32 additions and 2 deletions
  1. 1 1
      server/app.py
  2. 31 1
      server/game_api.py

+ 1 - 1
server/app.py

@@ -32,7 +32,7 @@ def version():
     """
     Return the version of the API and a status message, "healthy"
     """
-    return jsonify({"version": "3", "status": "healthy"})
+    return jsonify({"version": "4", "status": "healthy"})
 
 
 if __name__ == "__main__":

+ 31 - 1
server/game_api.py

@@ -52,9 +52,39 @@ def game_settings(game_id):
     return jsonify(g.to_dict())
 
 
-@game.route("/<game_id>/linked", methods=["POST"])
+@game.route("/<game_id>/config")
+def game_config(game_id):
+    g = require_game(game_id)
+    return jsonify({
+        "timer": g.timer,
+        "rounds": g.rounds,
+        "onlyAmerica": False, # TODO lying for now until this is being stored in the db
+    })
+
+
+@game.route("/<game_id>/coords")
+def coords(game_id):
+    g = require_game(game_id)
+    return jsonify({
+        str(c.round_number): {
+            "lat": c.latitude,
+            "lng": c.longitude,
+        } for c in g.coordinates
+    })
+
+
+@game.route("/<game_id>/players")
+def players(game_id):
+    g = require_game(game_id)
+    return jsonify({"players": [p.to_dict() for p in g.players]})
+
+
+@game.route("/<game_id>/linked", methods=["GET", "POST"])
 def link_game(game_id):
     g = require_game(game_id)
+    if request.method == "GET":
+        return jsonify({"linkedGame": g.linked_game})
+
     link_id = request.json.get("linkedGame", None)
     if link_id is None or db.Game.query.get(link_id) is None:
         abort(401)