@@ -7,6 +7,7 @@ defmodule CadetWeb.UserController do
7
7
use PhoenixSwagger
8
8
9
9
import Cadet.Assessments
10
+ import Cadet.Collectibles
10
11
11
12
def index ( conn , _ ) do
12
13
user = conn . assigns . current_user
@@ -15,14 +16,37 @@ defmodule CadetWeb.UserController do
15
16
story = user_current_story ( user )
16
17
xp = user_total_xp ( user )
17
18
19
+ collectibles = user_collectibles ( user )
20
+
18
21
render (
19
22
conn ,
20
23
"index.json" ,
21
24
user: user ,
22
25
grade: grade ,
23
26
max_grade: max_grade ,
24
27
story: story ,
25
- xp: xp
28
+ xp: xp ,
29
+ collectibles: collectibles ,
30
+ )
31
+ end
32
+
33
+ def addCollectibles ( conn , pic_nickname , pic_name ) do
34
+ user = conn . assigns . current_user
35
+ grade = user_total_grade ( user )
36
+ max_grade = user_max_grade ( user )
37
+ story = user_current_story ( user )
38
+ xp = user_total_xp ( user )
39
+ collectibles = add_user_collectibles ( user , pic_nickname , pic_name )
40
+
41
+ render (
42
+ conn ,
43
+ "index.json" ,
44
+ user: user ,
45
+ grade: grade ,
46
+ max_grade: max_grade ,
47
+ story: story ,
48
+ xp: xp ,
49
+ collectibles: collectibles ,
26
50
)
27
51
end
28
52
@@ -39,6 +63,15 @@ defmodule CadetWeb.UserController do
39
63
response ( 401 , "Unauthorised" )
40
64
end
41
65
66
+ swagger_path :addCollectibles do
67
+ post ( "/user" )
68
+ summary ( "add one collectible to the user" )
69
+ security ( [ % { JWT: [ ] } ] )
70
+ response ( 200 , "OK" )
71
+ response ( 400 , "Invalid parameters" )
72
+ response ( 401 , "Unauthorised" )
73
+ end
74
+
42
75
def swagger_definitions do
43
76
% {
44
77
UserInfo:
@@ -73,6 +106,11 @@ defmodule CadetWeb.UserController do
73
106
:integer ,
74
107
"Amount of xp. Only provided for 'Student'." <> "Value will be 0 for non-students."
75
108
)
109
+
110
+ collectibles (
111
+ :map ,
112
+ "Collectibles users obtained in story." <> " Value will be empty map for non-students."
113
+ )
76
114
end
77
115
end ,
78
116
UserStory:
0 commit comments