@@ -16,6 +16,7 @@ defmodule CadetWeb.UserController do
1616 story = user_current_story ( user )
1717 xp = user_total_xp ( user )
1818 game_states = user_game_states ( user )
19+
1920 render (
2021 conn ,
2122 "index.json" ,
@@ -39,6 +40,7 @@ defmodule CadetWeb.UserController do
3940
4041 def update_game_states ( conn , % { "gameStates" => new_game_states } ) do
4142 user = conn . assigns [ :current_user ]
43+
4244 case Cadet.GameStates . update ( user , new_game_states ) do
4345 { :ok , nil } ->
4446 text ( conn , "OK" )
@@ -56,9 +58,11 @@ defmodule CadetWeb.UserController do
5658 security ( [ % { JWT: [ ] } ] )
5759 consumes ( "application/json" )
5860 produces ( "application/json" )
61+
5962 parameters do
6063 new_game_states ( :path , :map , "new game states" , required: true )
6164 end
65+
6266 response ( 200 , "OK" , Schema . ref ( :UserInfo ) )
6367 response ( 201 , "Created" )
6468 response ( 204 , "No Content" )
@@ -68,9 +72,11 @@ defmodule CadetWeb.UserController do
6872
6973 def clear_up_game_states ( conn , _ ) do
7074 user = conn . assigns [ :current_user ]
75+
7176 case Cadet.GameStates . clear ( user ) do
7277 { :ok , nil } ->
7378 text ( conn , "OK" )
79+
7480 { :error , { status , message } } ->
7581 conn
7682 |> put_status ( status )
@@ -90,7 +96,6 @@ defmodule CadetWeb.UserController do
9096 response ( 401 , "Unauthorised" )
9197 end
9298
93-
9499 def swagger_definitions do
95100 % {
96101 UserInfo:
@@ -128,10 +133,9 @@ defmodule CadetWeb.UserController do
128133
129134 game_states (
130135 :map ,
131- "States for user's game, including users' collectibles and completed quests.\n "
132- <> "Collectibles is a map.\n "
133- <> "Completed quests is an array of strings"
134-
136+ "States for user's game, including users' collectibles and completed quests.\n " <>
137+ "Collectibles is a map.\n " <>
138+ "Completed quests is an array of strings"
135139 )
136140 end
137141 end ,
0 commit comments