Line data Source code
1 4 : (ns schemas.api.classes
2 : (:require
3 : [schemas.domain.event-participants :as domain-event-participant-schemas]
4 : [schemas.types :as types-schemas]))
5 :
6 :
7 : ;; Request Schemas
8 4 : (def ClassParticipantIdsRequestSchema
9 28 : [:map {:swagger/title "ClassParticipantIdsRequestSchema"
10 : :swagger/description "List of participant UUIDs to transfer between classes"}
11 8 : [:participant-ids
12 20 : [:vector {:min 1}
13 4 : types-schemas/UuidString]]])
14 :
15 :
16 4 : (def ClassSwapRequestSchema
17 8 : [:map
18 20 : {:swagger/title "ClassSwapRequestSchema"
19 : :swagger/description
20 : "Participants to swap between two classes: class-a-participant-ids move to class B, class-b-participant-ids move to class A"}
21 8 : [:class-a-participant-ids
22 20 : [:vector {:min 0}
23 4 : types-schemas/UuidString]]
24 8 : [:class-b-participant-ids
25 20 : [:vector {:min 0}
26 4 : types-schemas/UuidString]]])
27 :
28 :
29 4 : (def ClassParticipantRequestSchema
30 28 : [:map {:swagger/title "ClassParticipantRequestSchema"
31 : :swagger/description "Request payload for adding an existing event participant to a class"}
32 20 : [:participant-id [:ref :types/UuidString]]])
33 :
34 :
35 4 : (def ClassRequestSchema
36 28 : [:map {:swagger/title "ClassRequestSchema"
37 : :swagger/description "Request payload for creating or updating a class"}
38 8 : [:name
39 44 : [:string {:min 1
40 : :max 255
41 : :description "Class name"
42 : :example "Beginner"}]]
43 20 : [:max-players {:optional true}
44 8 : [:maybe
45 36 : [:int {:min 1
46 : :description "Maximum number of players allowed"
47 : :example 16}]]]])
48 :
49 :
50 : ;; Path Params Schemas
51 4 : (def ClassAndEventPathParamsSchema
52 20 : [:map {:swagger/title "ClassAndEventPathParamsSchema"}
53 28 : [:class-uuid {:description "Class UUID in v7 format"
54 : :example "550e8400-e29b-41d4-a716-446655440000"}
55 12 : [:ref :types/UuidString]]
56 28 : [:event-uuid {:description "Event UUID in v7 format"
57 : :example "550e8400-e29b-41d4-a716-446655440000"}
58 12 : [:ref :types/UuidString]]])
59 :
60 :
61 4 : (def ClassTransferPathParamsSchema
62 20 : [:map {:swagger/title "ClassTransferPathParamsSchema"}
63 28 : [:event-uuid {:description "Event UUID in v7 format"
64 : :example "550e8400-e29b-41d4-a716-446655440000"}
65 12 : [:ref :types/UuidString]]
66 28 : [:class-uuid {:description "Target class UUID in v7 format"
67 : :example "550e8400-e29b-41d4-a716-446655440000"}
68 12 : [:ref :types/UuidString]]
69 28 : [:source-class-uuid {:description "Source class UUID in v7 format"
70 : :example "550e8400-e29b-41d4-a716-446655440000"}
71 12 : [:ref :types/UuidString]]])
72 :
73 :
74 4 : (def ClassSwapPathParamsSchema
75 20 : [:map {:swagger/title "ClassSwapPathParamsSchema"}
76 28 : [:event-uuid {:description "Event UUID in v7 format"
77 : :example "550e8400-e29b-41d4-a716-446655440000"}
78 12 : [:ref :types/UuidString]]
79 28 : [:class-uuid {:description "First class UUID in v7 format"
80 : :example "550e8400-e29b-41d4-a716-446655440000"}
81 12 : [:ref :types/UuidString]]
82 28 : [:other-class-uuid {:description "Second class UUID in v7 format"
83 : :example "550e8400-e29b-41d4-a716-446655440000"}
84 12 : [:ref :types/UuidString]]])
85 :
86 :
87 4 : (def ClassParticipantPathParamsSchema
88 20 : [:map {:swagger/title "ClassParticipantPathParamsSchema"}
89 28 : [:class-uuid {:description "Class UUID in v7 format"
90 : :example "550e8400-e29b-41d4-a716-446655440000"}
91 12 : [:ref :types/UuidString]]
92 28 : [:event-uuid {:description "Event UUID in v7 format"
93 : :example "550e8400-e29b-41d4-a716-446655440000"}
94 12 : [:ref :types/UuidString]]
95 28 : [:participant-id {:description "Participant UUID in v7 format"
96 : :example "550e8400-e29b-41d4-a716-446655440000"}
97 12 : [:ref :types/UuidString]]])
98 :
99 :
100 : ;; Event-class response body schemas
101 4 : (def EventClassResponseSuccess201Body
102 28 : [:map {:swagger/title "EventClassResponseSuccess201Body"
103 : :swagger/description "Successful event class creation response"}
104 28 : [:message [:string {:example "Class \"Beginner\" created successfully."}]]
105 20 : [:data [:ref :domain/EventClassRecord]]])
106 :
107 :
108 4 : (def EventClassResponseSuccess200Body
109 28 : [:map {:swagger/title "EventClassResponseSuccess200Body"
110 : :swagger/description "Successful event class retrieval/update response"}
111 28 : [:message [:string {:example "Class updated successfully."}]]
112 20 : [:data [:ref :domain/EventClassRecord]]])
113 :
114 :
115 4 : (def EventClassListResponseSuccess200Body
116 28 : [:map {:swagger/title "EventClassListResponseSuccess200Body"
117 : :swagger/description "Successful event classes list response"}
118 28 : [:message [:string {:example "Classes retrieved successfully."}]]
119 28 : [:data [:sequential [:ref :domain/EventClassRecord]]]])
120 :
121 :
122 4 : (def EventClassDeleteResponseSuccess200Body
123 28 : [:map {:swagger/title "EventClassDeleteResponseSuccess200Body"
124 : :swagger/description "Successful event class deletion response"}
125 28 : [:message [:string {:example "Class deleted successfully."}]]])
126 :
127 :
128 4 : (def EventClassParticipantResponseSuccess201Body
129 28 : [:map {:swagger/title "EventClassParticipantResponseSuccess201Body"
130 : :swagger/description "Successful event class participant creation response"}
131 28 : [:message [:string {:example "Participant added to class successfully."}]]
132 20 : [:data [:ref :domain/ClassParticipantRecord]]])
133 :
134 :
135 4 : (def EventClassResponseError400Body
136 28 : [:map {:swagger/title "EventClassResponseError400Body"
137 : :swagger/description "Event class operation error response"}
138 28 : [:message [:string {:example "Invalid class data."}]]
139 12 : [:error :map]])
140 :
141 :
142 4 : (def EventClassResponseError404Body
143 28 : [:map {:swagger/title "EventClassResponseError404Body"
144 : :swagger/description "Event class not found response"}
145 28 : [:message [:string {:example "Class not found."}]]
146 20 : [:data {:optional true}
147 4 : nil?]])
148 :
149 :
150 4 : (def EventClassResponseSchema
151 : "Union of possible event class create/update responses."
152 8 : [:or
153 40 : [:map [:status [:= 200]] [:body EventClassResponseSuccess200Body]]
154 40 : [:map [:status [:= 201]] [:body EventClassResponseSuccess201Body]]
155 40 : [:map [:status [:= 400]] [:body EventClassResponseError400Body]]
156 40 : [:map [:status [:= 404]] [:body EventClassResponseError404Body]]])
157 :
158 :
159 4 : (def EventClassListResponseSchema
160 : "Response for listing classes by event."
161 8 : [:or
162 40 : [:map [:status [:= 200]] [:body EventClassListResponseSuccess200Body]]
163 40 : [:map [:status [:= 400]] [:body EventClassResponseError400Body]]])
164 :
165 :
166 4 : (def EventClassDeleteResponseSchema
167 : "Response for deleting an event class."
168 8 : [:or
169 40 : [:map [:status [:= 200]] [:body EventClassDeleteResponseSuccess200Body]]
170 40 : [:map [:status [:= 400]] [:body EventClassResponseError400Body]]
171 40 : [:map [:status [:= 404]] [:body EventClassResponseError404Body]]])
172 :
173 :
174 4 : (def EventClassParticipantResponseSchema
175 : "Response for adding a participant to an event class."
176 8 : [:or
177 40 : [:map [:status [:= 201]] [:body EventClassParticipantResponseSuccess201Body]]
178 40 : [:map [:status [:= 400]] [:body EventClassResponseError400Body]]
179 40 : [:map [:status [:= 404]] [:body EventClassResponseError404Body]]])
180 :
181 :
182 4 : (def EventClassParticipantRegisterEventResponseSuccess201Body
183 8 : [:map
184 20 : {:swagger/title "EventClassParticipantRegisterEventResponseSuccess201Body"
185 : :swagger/description
186 : "Successful response for adding a participant to a class, registering it for the event first if needed"}
187 28 : [:message [:string {:example "Participant added to event and class successfully."}]]
188 8 : [:data
189 8 : [:map
190 20 : [:event-participant [:ref :domain/EventParticipantRecord]]
191 20 : [:class-participant [:ref :domain/ClassParticipantRecord]]]]])
192 :
193 :
194 4 : (def EventClassParticipantRegisterEventResponseSchema
195 : "Response for adding a participant to a class, registering it for the event first if needed."
196 8 : [:or
197 40 : [:map [:status [:= 201]] [:body EventClassParticipantRegisterEventResponseSuccess201Body]]
198 40 : [:map [:status [:= 400]] [:body EventClassResponseError400Body]]
199 40 : [:map [:status [:= 404]] [:body EventClassResponseError404Body]]])
200 :
201 :
202 4 : (def EventClassParticipantDeleteResponseSuccess200Body
203 28 : [:map {:swagger/title "EventClassParticipantDeleteResponseSuccess200Body"
204 : :swagger/description "Successful event class participant removal response"}
205 28 : [:message [:string {:example "Participant removed from class successfully."}]]])
206 :
207 :
208 4 : (def EventClassParticipantDeleteResponseSchema
209 : "Response for removing a participant from an event class."
210 8 : [:or
211 40 : [:map [:status [:= 200]] [:body EventClassParticipantDeleteResponseSuccess200Body]]
212 40 : [:map [:status [:= 400]] [:body EventClassResponseError400Body]]
213 40 : [:map [:status [:= 404]] [:body EventClassResponseError404Body]]])
214 :
215 :
216 4 : (def EventClassBulkAddFromEventResponseSuccess200Body
217 28 : [:map {:swagger/title "EventClassBulkAddFromEventResponseSuccess200Body"
218 : :swagger/description "Successful bulk-add participants from event response"}
219 28 : [:message [:string {:example "Participants added to class successfully."}]]
220 8 : [:data
221 8 : [:map
222 8 : [:added-count
223 36 : [:int {:min 0
224 : :description "Number of participants added"
225 : :example 5}]]
226 8 : [:skipped-count
227 36 : [:int {:min 0
228 : :description "Number of participants skipped"
229 : :example 2}]]]]])
230 :
231 :
232 4 : (def EventClassBulkAddFromEventResponseSchema
233 : "Response for bulk-adding event participants to a class."
234 8 : [:or
235 40 : [:map [:status [:= 200]] [:body EventClassBulkAddFromEventResponseSuccess200Body]]
236 40 : [:map [:status [:= 400]] [:body EventClassResponseError400Body]]
237 40 : [:map [:status [:= 404]] [:body EventClassResponseError404Body]]])
238 :
239 :
240 4 : (def ClassUpdateParticipantRequestSchema
241 20 : [:map {:swagger/title "ClassUpdateParticipantRequestSchema"}
242 12 : [:status domain-event-participant-schemas/ParticipantStatusSchema]])
243 :
244 :
245 4 : (def EventClassParticipantUpdateResponseSuccess200Body
246 20 : [:map {:swagger/title "EventClassParticipantUpdateResponseSuccess200Body"}
247 12 : [:message :string]
248 20 : [:data [:ref :domain/ClassParticipantRecord]]])
249 :
250 :
251 4 : (def EventClassParticipantUpdateResponseSchema
252 : "Response for updating a class participant."
253 8 : [:or
254 40 : [:map [:status [:= 200]] [:body EventClassParticipantUpdateResponseSuccess200Body]]
255 40 : [:map [:status [:= 400]] [:body EventClassResponseError400Body]]
256 40 : [:map [:status [:= 404]] [:body EventClassResponseError404Body]]])
257 :
258 :
259 4 : (def EventClassBulkCopyResponseSuccess200Body
260 28 : [:map {:swagger/title "EventClassBulkCopyResponseSuccess200Body"
261 : :swagger/description "Successful bulk-copy participants between classes response"}
262 28 : [:message [:string {:example "Participants copied to class successfully."}]]
263 8 : [:data
264 8 : [:map
265 8 : [:added-count
266 36 : [:int {:min 0
267 : :description "Number of participants added to the target class"
268 : :example 5}]]
269 8 : [:skipped-count
270 36 : [:int {:min 0
271 : :description "Number of participants skipped (already in target or capacity reached)"
272 : :example 2}]]]]])
273 :
274 :
275 4 : (def EventClassBulkCopyResponseSchema
276 : "Response for bulk-copying participants between classes."
277 8 : [:or
278 40 : [:map [:status [:= 200]] [:body EventClassBulkCopyResponseSuccess200Body]]
279 40 : [:map [:status [:= 400]] [:body EventClassResponseError400Body]]
280 40 : [:map [:status [:= 404]] [:body EventClassResponseError404Body]]])
281 :
282 :
283 4 : (def EventClassBulkMoveResponseSuccess200Body
284 28 : [:map {:swagger/title "EventClassBulkMoveResponseSuccess200Body"
285 : :swagger/description "Successful bulk-move participants between classes response"}
286 28 : [:message [:string {:example "Participants moved to class successfully."}]]
287 8 : [:data
288 8 : [:map
289 8 : [:moved-count
290 36 : [:int {:min 0
291 : :description "Number of participants moved to the target class"
292 : :example 5}]]
293 8 : [:skipped-count
294 36 : [:int {:min 0
295 : :description "Number of participants skipped (shared or capacity reached)"
296 : :example 2}]]]]])
297 :
298 :
299 4 : (def EventClassBulkMoveResponseSchema
300 : "Response for bulk-moving participants between classes."
301 8 : [:or
302 40 : [:map [:status [:= 200]] [:body EventClassBulkMoveResponseSuccess200Body]]
303 40 : [:map [:status [:= 400]] [:body EventClassResponseError400Body]]
304 40 : [:map [:status [:= 404]] [:body EventClassResponseError404Body]]])
305 :
306 :
307 4 : (def EventClassSwapResponseSuccess200Body
308 28 : [:map {:swagger/title "EventClassSwapResponseSuccess200Body"
309 : :swagger/description "Successful participant swap between classes response"}
310 28 : [:message [:string {:example "Participants swapped between classes successfully."}]]
311 8 : [:data
312 8 : [:map
313 8 : [:moved-to-a-count
314 36 : [:int {:min 0
315 : :description "Number of participants moved from B into A"
316 : :example 3}]]
317 8 : [:moved-to-b-count
318 36 : [:int {:min 0
319 : :description "Number of participants moved from A into B"
320 : :example 4}]]
321 8 : [:skipped-count
322 36 : [:int {:min 0
323 : :description "Number of shared participants left unchanged"
324 : :example 1}]]]]])
325 :
326 :
327 4 : (def EventClassSwapResponseSchema
328 : "Response for swapping participants between two classes."
329 8 : [:or
330 40 : [:map [:status [:= 200]] [:body EventClassSwapResponseSuccess200Body]]
331 40 : [:map [:status [:= 400]] [:body EventClassResponseError400Body]]
332 40 : [:map [:status [:= 404]] [:body EventClassResponseError404Body]]])
333 :
334 :
335 4 : (def ClassParticipantPaymentRequestSchema
336 8 : [:maybe
337 28 : [:map {:swagger/title "ClassParticipantPaymentRequestSchema"
338 : :swagger/description "Optional payload for marking a class participant as paid"}
339 20 : [:amount {:optional true}
340 56 : [:maybe [:or [:int {:min 0}] [:double {:min 0}]]]]
341 20 : [:currency {:optional true}
342 8 : [:maybe
343 28 : [:string {:min 1
344 : :max 10}]]]]])
345 :
346 :
347 4 : (def EventClassParticipantPaymentResponseSuccess200Body
348 28 : [:map {:swagger/title "EventClassParticipantPaymentResponseSuccess200Body"
349 : :swagger/description "Successful class participant payment operation response"}
350 16 : [:message [:string]]
351 20 : [:data [:ref :domain/ClassParticipantRecord]]])
352 :
353 :
354 4 : (def EventClassParticipantPaymentResponseSchema
355 : "Response for marking/reverting a class participant payment."
356 8 : [:or
357 40 : [:map [:status [:= 200]] [:body EventClassParticipantPaymentResponseSuccess200Body]]
358 40 : [:map [:status [:= 400]] [:body EventClassResponseError400Body]]
359 40 : [:map [:status [:= 404]] [:body EventClassResponseError404Body]]
360 40 : [:map [:status [:= 422]] [:body EventClassResponseError400Body]]])
|