File tree 1 file changed +16
-0
lines changed 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ type Event
9
9
| EQuizWasCreated QuizWasCreated
10
10
| EQuizWasPublished QuizWasPublished
11
11
| EQuestionAddedToQuiz QuestionAddedToQuiz
12
+ | EGameWasFinished GameWasFinished
12
13
13
14
14
15
type alias PlayerHasRegistered =
@@ -44,6 +45,12 @@ type alias QuestionAddedToQuiz =
44
45
, answer : String
45
46
}
46
47
48
+ type alias GameWasFinished =
49
+ { game_id : String
50
+ , id : String
51
+ , timestamp : String
52
+ }
53
+
47
54
48
55
decodeEvents : Json .Decode .Decoder (List Event )
49
56
decodeEvents =
@@ -70,6 +77,9 @@ eventInfo eventName =
70
77
" QuestionAddedToQuiz" ->
71
78
Json . Decode . map ( \ e -> EQuestionAddedToQuiz e) decodeQuestionAddedToQuiz
72
79
80
+ " GameWasFinished" ->
81
+ Json . Decode . map ( \ e -> EGameWasFinished e) decodeGameWasFinished
82
+
73
83
_ ->
74
84
Json . Decode . fail ( eventName ++ " is not a recognized event" )
75
85
@@ -110,4 +120,10 @@ decodeQuestionAddedToQuiz =
110
120
|: ( at [ " timestamp" ] Json . Decode . string)
111
121
|: ( at [ " payload" , " answer" ] Json . Decode . string)
112
122
123
+ decodeGameWasFinished : Json .Decode .Decoder GameWasFinished
124
+ decodeGameWasFinished =
125
+ Json . Decode . succeed GameWasFinished
126
+ |: ( at [ " payload" , " game_id" ] Json . Decode . string)
127
+ |: ( at [ " id" ] Json . Decode . string)
128
+ |: ( at [ " timestamp" ] Json . Decode . string)
113
129
You can’t perform that action at this time.
0 commit comments