1use std::fmt;
2
3use http::Method;
4
5use crate::types::id::{CommentId, FileId, GameId, ModId, UserId};
6
7#[derive(Clone, Copy, Debug)]
8#[non_exhaustive]
9pub enum Route {
10 AddFile {
11 game_id: GameId,
12 mod_id: ModId,
13 },
14 AddGameMedia {
15 game_id: GameId,
16 },
17 AddGameTags {
18 game_id: GameId,
19 },
20 AddMod {
21 game_id: GameId,
22 },
23 AddModComment {
24 game_id: GameId,
25 mod_id: ModId,
26 },
27 AddModCommentKarma {
28 game_id: GameId,
29 mod_id: ModId,
30 comment_id: CommentId,
31 },
32 AddModDependencies {
33 game_id: GameId,
34 mod_id: ModId,
35 },
36 AddModMedia {
37 game_id: GameId,
38 mod_id: ModId,
39 },
40 AddModMetadata {
41 game_id: GameId,
42 mod_id: ModId,
43 },
44 AddModTags {
45 game_id: GameId,
46 mod_id: ModId,
47 },
48 DeleteFile {
49 game_id: GameId,
50 mod_id: ModId,
51 file_id: FileId,
52 },
53 DeleteGameTags {
54 game_id: GameId,
55 },
56 DeleteMod {
57 game_id: GameId,
58 mod_id: ModId,
59 },
60 DeleteModComment {
61 game_id: GameId,
62 mod_id: ModId,
63 comment_id: CommentId,
64 },
65 DeleteModDependencies {
66 game_id: GameId,
67 mod_id: ModId,
68 },
69 DeleteModMedia {
70 game_id: GameId,
71 mod_id: ModId,
72 },
73 DeleteModMetadata {
74 game_id: GameId,
75 mod_id: ModId,
76 },
77 DeleteModTags {
78 game_id: GameId,
79 mod_id: ModId,
80 },
81 EditFile {
82 game_id: GameId,
83 mod_id: ModId,
84 file_id: FileId,
85 },
86 EditMod {
87 game_id: GameId,
88 mod_id: ModId,
89 },
90 EditModComment {
91 game_id: GameId,
92 mod_id: ModId,
93 comment_id: CommentId,
94 },
95 ExternalAuthDiscord,
96 #[allow(dead_code)]
97 ExternalAuthEpic,
98 ExternalAuthGoogle,
99 ExternalAuthMeta,
100 #[allow(dead_code)]
101 ExternalAuthOpenID,
102 #[allow(dead_code)]
103 ExternalAuthPSN,
104 ExternalAuthSteam,
105 ExternalAuthSwitch,
106 ExternalAuthXbox,
107 GetFile {
108 game_id: GameId,
109 mod_id: ModId,
110 file_id: FileId,
111 },
112 GetFiles {
113 game_id: GameId,
114 mod_id: ModId,
115 },
116 GetGame {
117 id: GameId,
118 show_hidden_tags: Option<bool>,
119 },
120 GetGames {
121 show_hidden_tags: Option<bool>,
122 },
123 GetGameStats {
124 game_id: GameId,
125 },
126 GetGameTags {
127 game_id: GameId,
128 },
129 GetMod {
130 game_id: GameId,
131 mod_id: ModId,
132 },
133 GetModComment {
134 game_id: GameId,
135 mod_id: ModId,
136 comment_id: CommentId,
137 },
138 GetModComments {
139 game_id: GameId,
140 mod_id: ModId,
141 },
142 GetModDependencies {
143 game_id: GameId,
144 mod_id: ModId,
145 },
146 GetModEvents {
147 game_id: GameId,
148 mod_id: ModId,
149 },
150 GetModMetadata {
151 game_id: GameId,
152 mod_id: ModId,
153 },
154 GetModStats {
155 game_id: GameId,
156 mod_id: ModId,
157 },
158 GetModTags {
159 game_id: GameId,
160 mod_id: ModId,
161 },
162 GetModTeamMembers {
163 game_id: GameId,
164 mod_id: ModId,
165 },
166 GetMods {
167 game_id: GameId,
168 },
169 GetModsEvents {
170 game_id: GameId,
171 },
172 GetModsStats {
173 game_id: GameId,
174 },
175 ManagePlatformStatus {
176 game_id: GameId,
177 mod_id: ModId,
178 file_id: FileId,
179 },
180 MuteUser {
181 user_id: UserId,
182 },
183 OAuthEmailRequest,
184 OAuthEmailExchange,
185 OAuthLogout,
186 RateMod {
187 game_id: GameId,
188 mod_id: ModId,
189 },
190 RenameGameTags {
191 game_id: GameId,
192 },
193 #[allow(dead_code)]
194 ReorderModMedia {
195 game_id: GameId,
196 mod_id: ModId,
197 },
198 SubmitReport,
199 SubscribeToMod {
200 game_id: GameId,
201 mod_id: ModId,
202 },
203 Terms,
204 UnmuteUser {
205 user_id: UserId,
206 },
207 UnsubscribeFromMod {
208 game_id: GameId,
209 mod_id: ModId,
210 },
211 UserAuthenticated,
212 UserEvents,
213 UserFiles,
214 UserGames,
215 UserMods,
216 UserMuted,
217 UserRatings,
218 UserSubscriptions,
219}
220
221pub struct Parts {
222 pub method: Method,
223 pub path: String,
224 pub token_required: bool,
225}
226
227impl Route {
228 pub const fn method(&self) -> Method {
229 match self {
230 Self::GetFile { .. }
231 | Self::GetFiles { .. }
232 | Self::GetGame { .. }
233 | Self::GetGames { .. }
234 | Self::GetGameStats { .. }
235 | Self::GetGameTags { .. }
236 | Self::GetMod { .. }
237 | Self::GetModComment { .. }
238 | Self::GetModComments { .. }
239 | Self::GetModDependencies { .. }
240 | Self::GetModEvents { .. }
241 | Self::GetModMetadata { .. }
242 | Self::GetMods { .. }
243 | Self::GetModsEvents { .. }
244 | Self::GetModsStats { .. }
245 | Self::GetModStats { .. }
246 | Self::GetModTags { .. }
247 | Self::GetModTeamMembers { .. }
248 | Self::Terms
249 | Self::UserAuthenticated
250 | Self::UserEvents
251 | Self::UserFiles
252 | Self::UserGames
253 | Self::UserMods
254 | Self::UserRatings
255 | Self::UserSubscriptions => Method::GET,
256 Self::AddFile { .. }
257 | Self::AddGameMedia { .. }
258 | Self::AddGameTags { .. }
259 | Self::AddMod { .. }
260 | Self::AddModComment { .. }
261 | Self::AddModCommentKarma { .. }
262 | Self::AddModDependencies { .. }
263 | Self::AddModMedia { .. }
264 | Self::AddModMetadata { .. }
265 | Self::AddModTags { .. }
266 | Self::ExternalAuthDiscord
267 | Self::ExternalAuthEpic
268 | Self::ExternalAuthGoogle
269 | Self::ExternalAuthMeta
270 | Self::ExternalAuthOpenID
271 | Self::ExternalAuthPSN
272 | Self::ExternalAuthSteam
273 | Self::ExternalAuthSwitch
274 | Self::ExternalAuthXbox
275 | Self::ManagePlatformStatus { .. }
276 | Self::MuteUser { .. }
277 | Self::OAuthEmailRequest
278 | Self::OAuthEmailExchange
279 | Self::OAuthLogout
280 | Self::RateMod { .. }
281 | Self::SubmitReport { .. }
282 | Self::SubscribeToMod { .. }
283 | Self::UserMuted => Method::POST,
284 Self::EditMod { .. }
285 | Self::EditModComment { .. }
286 | Self::EditFile { .. }
287 | Self::RenameGameTags { .. }
288 | Self::ReorderModMedia { .. } => Method::PUT,
289 Self::DeleteFile { .. }
290 | Self::DeleteGameTags { .. }
291 | Self::DeleteMod { .. }
292 | Self::DeleteModComment { .. }
293 | Self::DeleteModDependencies { .. }
294 | Self::DeleteModMedia { .. }
295 | Self::DeleteModMetadata { .. }
296 | Self::DeleteModTags { .. }
297 | Self::UnmuteUser { .. }
298 | Self::UnsubscribeFromMod { .. } => Method::DELETE,
299 }
300 }
301
302 pub const fn token_required(&self) -> bool {
303 match self {
304 Self::ExternalAuthDiscord
305 | Self::ExternalAuthEpic
306 | Self::ExternalAuthGoogle
307 | Self::ExternalAuthMeta
308 | Self::ExternalAuthOpenID
309 | Self::ExternalAuthPSN
310 | Self::ExternalAuthSteam
311 | Self::ExternalAuthSwitch
312 | Self::ExternalAuthXbox
313 | Self::GetFile { .. }
314 | Self::GetFiles { .. }
315 | Self::GetGame { .. }
316 | Self::GetGames { .. }
317 | Self::GetGameStats { .. }
318 | Self::GetGameTags { .. }
319 | Self::GetMod { .. }
320 | Self::GetModComment { .. }
321 | Self::GetModComments { .. }
322 | Self::GetModDependencies { .. }
323 | Self::GetModEvents { .. }
324 | Self::GetModMetadata { .. }
325 | Self::GetMods { .. }
326 | Self::GetModsEvents { .. }
327 | Self::GetModsStats { .. }
328 | Self::GetModStats { .. }
329 | Self::GetModTags { .. }
330 | Self::GetModTeamMembers { .. }
331 | Self::OAuthEmailRequest
332 | Self::OAuthEmailExchange
333 | Self::Terms => false,
334 Self::AddFile { .. }
335 | Self::AddGameMedia { .. }
336 | Self::AddGameTags { .. }
337 | Self::AddMod { .. }
338 | Self::AddModComment { .. }
339 | Self::AddModCommentKarma { .. }
340 | Self::AddModDependencies { .. }
341 | Self::AddModMedia { .. }
342 | Self::AddModMetadata { .. }
343 | Self::AddModTags { .. }
344 | Self::DeleteFile { .. }
345 | Self::DeleteGameTags { .. }
346 | Self::DeleteMod { .. }
347 | Self::DeleteModComment { .. }
348 | Self::DeleteModDependencies { .. }
349 | Self::DeleteModMedia { .. }
350 | Self::DeleteModMetadata { .. }
351 | Self::DeleteModTags { .. }
352 | Self::EditFile { .. }
353 | Self::EditMod { .. }
354 | Self::EditModComment { .. }
355 | Self::ManagePlatformStatus { .. }
356 | Self::MuteUser { .. }
357 | Self::OAuthLogout
358 | Self::RateMod { .. }
359 | Self::RenameGameTags { .. }
360 | Self::ReorderModMedia { .. }
361 | Self::SubmitReport { .. }
362 | Self::SubscribeToMod { .. }
363 | Self::UnmuteUser { .. }
364 | Self::UnsubscribeFromMod { .. }
365 | Self::UserAuthenticated
366 | Self::UserEvents
367 | Self::UserFiles
368 | Self::UserGames
369 | Self::UserMods
370 | Self::UserMuted
371 | Self::UserRatings
372 | Self::UserSubscriptions => true,
373 }
374 }
375
376 pub fn into_parts(self) -> Parts {
377 Parts {
378 method: self.method(),
379 path: self.to_string(),
380 token_required: self.token_required(),
381 }
382 }
383}
384
385macro_rules! path {
386 ($($pieces:tt)*) => { internal_path!(@start $($pieces)*)};
387}
388
389macro_rules! internal_path {
390 (@start $f:ident; $first:tt $(, $tail:tt)*) => ({
391 internal_path!(@munch $f; [$first] [$(, $tail)*])
392 });
393 (@munch $f:ident; [$curr:tt] [, $next:tt $(, $tail:tt)*]) => ({
394 internal_path!(@segment $f; $curr);
395 internal_path!(@munch $f; [$next] [$(, $tail)*])
396 });
397 (@munch $f:ident; [$curr:tt] []) => ({
398 internal_path!(@segment $f; $curr);
399 Ok(())
400 });
401 (@segment $f:ident; $s:literal) => ({
402 $f.write_str($s)?;
403 });
404 (@segment $f:ident; $v:ident) => ({
405 fmt::Display::fmt($v, $f)?;
406 });
407}
408
409impl fmt::Display for Route {
410 #[allow(clippy::too_many_lines)]
411 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
412 match self {
413 Self::AddFile { game_id, mod_id } | Self::GetFiles { game_id, mod_id } => {
414 path!(f; "/games/", game_id, "/mods/", mod_id, "/files")
415 }
416 Self::AddGameMedia { game_id } => {
417 path!(f; "/games/", game_id, "/media")
418 }
419 Self::AddGameTags { game_id }
420 | Self::DeleteGameTags { game_id }
421 | Self::GetGameTags { game_id } => {
422 path!(f; "/games/", game_id, "/tags")
423 }
424 Self::AddMod { game_id } | Self::GetMods { game_id } => {
425 path!(f; "/games/", game_id, "/mods")
426 }
427 Self::AddModComment { game_id, mod_id } | Self::GetModComments { game_id, mod_id } => {
428 path!(f; "/games/", game_id, "/mods/", mod_id, "/comments")
429 }
430 Self::AddModCommentKarma {
431 game_id,
432 mod_id,
433 comment_id,
434 } => {
435 path!(f; "/games/", game_id, "/mods/", mod_id, "/comments/", comment_id, "/karma")
436 }
437 Self::AddModDependencies { game_id, mod_id }
438 | Self::DeleteModDependencies { game_id, mod_id }
439 | Self::GetModDependencies { game_id, mod_id } => {
440 path!(f; "/games/", game_id, "/mods/", mod_id, "/dependencies")
441 }
442 Self::AddModMedia { game_id, mod_id } | Self::DeleteModMedia { game_id, mod_id } => {
443 path!(f; "/games/", game_id, "/mods/", mod_id, "/media")
444 }
445 Self::AddModMetadata { game_id, mod_id }
446 | Self::DeleteModMetadata { game_id, mod_id }
447 | Self::GetModMetadata { game_id, mod_id } => {
448 path!(f; "/games/", game_id, "/mods/", mod_id, "/metadatakvp")
449 }
450 Self::AddModTags { game_id, mod_id }
451 | Self::DeleteModTags { game_id, mod_id }
452 | Self::GetModTags { game_id, mod_id } => {
453 path!(f; "/games/", game_id, "/mods/", mod_id, "/tags")
454 }
455 Self::DeleteFile {
456 game_id,
457 mod_id,
458 file_id,
459 }
460 | Self::EditFile {
461 game_id,
462 mod_id,
463 file_id,
464 }
465 | Self::GetFile {
466 game_id,
467 mod_id,
468 file_id,
469 } => {
470 path!(f; "/games/", game_id, "/mods/", mod_id, "/files/", file_id)
471 }
472 Self::DeleteMod { game_id, mod_id }
473 | Self::EditMod { game_id, mod_id }
474 | Self::GetMod { game_id, mod_id } => {
475 path!(f; "/games/", game_id, "/mods/", mod_id)
476 }
477 Self::DeleteModComment {
478 game_id,
479 mod_id,
480 comment_id,
481 }
482 | Self::EditModComment {
483 game_id,
484 mod_id,
485 comment_id,
486 }
487 | Self::GetModComment {
488 game_id,
489 mod_id,
490 comment_id,
491 } => {
492 path!(f; "/games/", game_id, "/mods/", mod_id, "/comments/", comment_id)
493 }
494 Self::ExternalAuthDiscord => f.write_str("/external/discordauth"),
495 Self::ExternalAuthEpic => f.write_str("/external/epicgamesauth"),
496 Self::ExternalAuthGoogle => f.write_str("/external/googleauth"),
497 Self::ExternalAuthMeta => f.write_str("/external/oculusauth"),
498 Self::ExternalAuthOpenID => f.write_str("/external/openidauth"),
499 Self::ExternalAuthPSN => f.write_str("/external/psnauth"),
500 Self::ExternalAuthSteam => f.write_str("/external/steamauth"),
501 Self::ExternalAuthSwitch => f.write_str("/external/switchauth"),
502 Self::ExternalAuthXbox => f.write_str("/external/xboxauth"),
503 Self::GetGame {
504 id,
505 show_hidden_tags,
506 } => {
507 f.write_str("/games/")?;
508 fmt::Display::fmt(id, f)?;
509 if let Some(show_hidden_tags) = show_hidden_tags {
510 f.write_str("?show_hidden_tags=")?;
511 fmt::Display::fmt(show_hidden_tags, f)?;
512 }
513 Ok(())
514 }
515 Self::GetGames { show_hidden_tags } => {
516 f.write_str("/games")?;
517 if let Some(show_hidden_tags) = show_hidden_tags {
518 f.write_str("?show_hidden_tags=")?;
519 fmt::Display::fmt(show_hidden_tags, f)?;
520 }
521 Ok(())
522 }
523 Self::GetGameStats { game_id } => {
524 path!(f; "/games/", game_id, "/stats")
525 }
526 Self::GetModEvents { game_id, mod_id } => {
527 path!(f; "/games/", game_id, "/mods/", mod_id, "/events")
528 }
529 Self::GetModTeamMembers { game_id, mod_id } => {
530 path!(f; "/games/", game_id, "/mods/", mod_id, "/team")
531 }
532 Self::GetModsEvents { game_id } => {
533 path!(f; "/games/", game_id, "/mods/events")
534 }
535 Self::GetModsStats { game_id } => {
536 path!(f; "/games/", game_id, "/mods/stats")
537 }
538 Self::GetModStats { game_id, mod_id } => {
539 path!(f; "/games/", game_id, "/mods/", mod_id, "/stats")
540 }
541 Self::ManagePlatformStatus {
542 game_id,
543 mod_id,
544 file_id,
545 } => {
546 path!(f; "/games/", game_id, "/mods/", mod_id, "/files/", file_id, "/platforms")
547 }
548 Self::MuteUser { user_id } | Self::UnmuteUser { user_id } => {
549 path!(f; "/users/", user_id, "/mute")
550 }
551 Self::OAuthEmailRequest => f.write_str("/oauth/emailrequest"),
552 Self::OAuthEmailExchange => f.write_str("/oauth/emailexchange"),
553 Self::OAuthLogout => f.write_str("/oauth/logout"),
554 Self::RateMod { game_id, mod_id } => {
555 path!(f; "/games/", game_id, "/mods/", mod_id, "/ratings")
556 }
557 Self::RenameGameTags { game_id } => {
558 path!(f; "/games/", game_id, "/tags/rename")
559 }
560 Self::ReorderModMedia { game_id, mod_id } => {
561 path!(f; "/games/", game_id, "/mods/", mod_id, "/media/reorder")
562 }
563 Self::SubscribeToMod { game_id, mod_id }
564 | Self::UnsubscribeFromMod { game_id, mod_id } => {
565 path!(f; "/games/", game_id, "/mods/", mod_id, "/subscribe")
566 }
567 Self::SubmitReport => f.write_str("/report"),
568 Self::Terms => f.write_str("/authenticate/terms"),
569 Self::UserAuthenticated => f.write_str("/me"),
570 Self::UserEvents => f.write_str("/me/events"),
571 Self::UserFiles => f.write_str("/me/files"),
572 Self::UserGames => f.write_str("/me/games"),
573 Self::UserMods => f.write_str("/me/mods"),
574 Self::UserMuted => f.write_str("/me/users/muted"),
575 Self::UserRatings => f.write_str("/me/ratings"),
576 Self::UserSubscriptions => f.write_str("/me/subscribed"),
577 }
578 }
579}
580
581#[cfg(test)]
582mod tests {
583 use super::*;
584
585 const GAME_ID: GameId = GameId::new(1);
586 const MOD_ID: ModId = ModId::new(2);
587 const FILE_ID: FileId = FileId::new(3);
588 const COMMENT_ID: CommentId = CommentId::new(4);
589 const USER_ID: UserId = UserId::new(5);
590
591 #[test]
592 fn add_file() {
593 let route = Route::AddFile {
594 game_id: GAME_ID,
595 mod_id: MOD_ID,
596 };
597
598 assert_eq!(route.to_string(), "/games/1/mods/2/files");
599 }
600
601 #[test]
602 fn add_game_media() {
603 let route = Route::AddGameMedia { game_id: GAME_ID };
604
605 assert_eq!(route.to_string(), "/games/1/media");
606 }
607
608 #[test]
609 fn add_game_tags() {
610 let route = Route::AddGameTags { game_id: GAME_ID };
611
612 assert_eq!(route.to_string(), "/games/1/tags");
613 }
614
615 #[test]
616 fn add_mod() {
617 let route = Route::AddMod { game_id: GAME_ID };
618
619 assert_eq!(route.to_string(), "/games/1/mods");
620 }
621
622 #[test]
623 fn add_mod_comment() {
624 let route = Route::AddModComment {
625 game_id: GAME_ID,
626 mod_id: MOD_ID,
627 };
628
629 assert_eq!(route.to_string(), "/games/1/mods/2/comments");
630 }
631
632 #[test]
633 fn add_mod_comment_karma() {
634 let route = Route::AddModCommentKarma {
635 game_id: GAME_ID,
636 mod_id: MOD_ID,
637 comment_id: COMMENT_ID,
638 };
639
640 assert_eq!(route.to_string(), "/games/1/mods/2/comments/4/karma");
641 }
642
643 #[test]
644 fn add_mod_dependencies() {
645 let route = Route::AddModDependencies {
646 game_id: GAME_ID,
647 mod_id: MOD_ID,
648 };
649
650 assert_eq!(route.to_string(), "/games/1/mods/2/dependencies");
651 }
652
653 #[test]
654 fn add_mod_media() {
655 let route = Route::AddModMedia {
656 game_id: GAME_ID,
657 mod_id: MOD_ID,
658 };
659
660 assert_eq!(route.to_string(), "/games/1/mods/2/media");
661 }
662
663 #[test]
664 fn add_mod_metadata() {
665 let route = Route::AddModMetadata {
666 game_id: GAME_ID,
667 mod_id: MOD_ID,
668 };
669
670 assert_eq!(route.to_string(), "/games/1/mods/2/metadatakvp");
671 }
672
673 #[test]
674 fn add_mod_tags() {
675 let route = Route::AddModTags {
676 game_id: GAME_ID,
677 mod_id: MOD_ID,
678 };
679
680 assert_eq!(route.to_string(), "/games/1/mods/2/tags");
681 }
682
683 #[test]
684 fn delete_file() {
685 let route = Route::DeleteFile {
686 game_id: GAME_ID,
687 mod_id: MOD_ID,
688 file_id: FILE_ID,
689 };
690
691 assert_eq!(route.to_string(), "/games/1/mods/2/files/3");
692 }
693
694 #[test]
695 fn delete_game_tags() {
696 let route = Route::DeleteGameTags { game_id: GAME_ID };
697
698 assert_eq!(route.to_string(), "/games/1/tags");
699 }
700
701 #[test]
702 fn delete_mod() {
703 let route = Route::DeleteMod {
704 game_id: GAME_ID,
705 mod_id: MOD_ID,
706 };
707
708 assert_eq!(route.to_string(), "/games/1/mods/2");
709 }
710
711 #[test]
712 fn delete_mod_comment() {
713 let route = Route::DeleteModComment {
714 game_id: GAME_ID,
715 mod_id: MOD_ID,
716 comment_id: COMMENT_ID,
717 };
718
719 assert_eq!(route.to_string(), "/games/1/mods/2/comments/4");
720 }
721
722 #[test]
723 fn delete_mod_dependencies() {
724 let route = Route::DeleteModDependencies {
725 game_id: GAME_ID,
726 mod_id: MOD_ID,
727 };
728
729 assert_eq!(route.to_string(), "/games/1/mods/2/dependencies");
730 }
731
732 #[test]
733 fn delete_mod_media() {
734 let route = Route::DeleteModMedia {
735 game_id: GAME_ID,
736 mod_id: MOD_ID,
737 };
738
739 assert_eq!(route.to_string(), "/games/1/mods/2/media");
740 }
741
742 #[test]
743 fn delete_mod_metadata() {
744 let route = Route::DeleteModMetadata {
745 game_id: GAME_ID,
746 mod_id: MOD_ID,
747 };
748
749 assert_eq!(route.to_string(), "/games/1/mods/2/metadatakvp");
750 }
751
752 #[test]
753 fn delete_mod_tags() {
754 let route = Route::DeleteModTags {
755 game_id: GAME_ID,
756 mod_id: MOD_ID,
757 };
758
759 assert_eq!(route.to_string(), "/games/1/mods/2/tags");
760 }
761
762 #[test]
763 fn edit_file() {
764 let route = Route::EditFile {
765 game_id: GAME_ID,
766 mod_id: MOD_ID,
767 file_id: FILE_ID,
768 };
769
770 assert_eq!(route.to_string(), "/games/1/mods/2/files/3");
771 }
772
773 #[test]
774 fn edit_mod() {
775 let route = Route::EditMod {
776 game_id: GAME_ID,
777 mod_id: MOD_ID,
778 };
779
780 assert_eq!(route.to_string(), "/games/1/mods/2");
781 }
782
783 #[test]
784 fn edit_mod_comment() {
785 let route = Route::EditModComment {
786 game_id: GAME_ID,
787 mod_id: MOD_ID,
788 comment_id: COMMENT_ID,
789 };
790
791 assert_eq!(route.to_string(), "/games/1/mods/2/comments/4");
792 }
793
794 #[test]
795 fn external_auth_discord() {
796 let route = Route::ExternalAuthDiscord;
797
798 assert_eq!(route.to_string(), "/external/discordauth");
799 }
800
801 #[test]
802 fn external_auth_epic() {
803 let route = Route::ExternalAuthEpic;
804
805 assert_eq!(route.to_string(), "/external/epicgamesauth");
806 }
807
808 #[test]
809 fn external_auth_google() {
810 let route = Route::ExternalAuthGoogle;
811
812 assert_eq!(route.to_string(), "/external/googleauth");
813 }
814
815 #[test]
816 fn external_auth_meta() {
817 let route = Route::ExternalAuthMeta;
818
819 assert_eq!(route.to_string(), "/external/oculusauth");
820 }
821
822 #[test]
823 fn external_auth_openid() {
824 let route = Route::ExternalAuthOpenID;
825
826 assert_eq!(route.to_string(), "/external/openidauth");
827 }
828
829 #[test]
830 fn external_auth_psn() {
831 let route = Route::ExternalAuthPSN;
832
833 assert_eq!(route.to_string(), "/external/psnauth");
834 }
835
836 #[test]
837 fn external_auth_steam() {
838 let route = Route::ExternalAuthSteam;
839
840 assert_eq!(route.to_string(), "/external/steamauth");
841 }
842
843 #[test]
844 fn external_auth_switch() {
845 let route = Route::ExternalAuthSwitch;
846
847 assert_eq!(route.to_string(), "/external/switchauth");
848 }
849
850 #[test]
851 fn external_auth_xbox() {
852 let route = Route::ExternalAuthXbox;
853
854 assert_eq!(route.to_string(), "/external/xboxauth");
855 }
856
857 #[test]
858 fn get_file() {
859 let route = Route::GetFile {
860 game_id: GAME_ID,
861 mod_id: MOD_ID,
862 file_id: FILE_ID,
863 };
864
865 assert_eq!(route.to_string(), "/games/1/mods/2/files/3");
866 }
867
868 #[test]
869 fn get_files() {
870 let route = Route::GetFiles {
871 game_id: GAME_ID,
872 mod_id: MOD_ID,
873 };
874
875 assert_eq!(route.to_string(), "/games/1/mods/2/files");
876 }
877
878 #[test]
879 fn get_game() {
880 let route = Route::GetGame {
881 id: GAME_ID,
882 show_hidden_tags: None,
883 };
884
885 assert_eq!(route.to_string(), "/games/1");
886
887 let route = Route::GetGame {
888 id: GAME_ID,
889 show_hidden_tags: Some(true),
890 };
891
892 assert_eq!(route.to_string(), "/games/1?show_hidden_tags=true");
893 }
894
895 #[test]
896 fn get_games() {
897 let route = Route::GetGames {
898 show_hidden_tags: None,
899 };
900
901 assert_eq!(route.to_string(), "/games");
902
903 let route = Route::GetGames {
904 show_hidden_tags: Some(true),
905 };
906
907 assert_eq!(route.to_string(), "/games?show_hidden_tags=true");
908 }
909
910 #[test]
911 fn get_game_stats() {
912 let route = Route::GetGameStats { game_id: GAME_ID };
913
914 assert_eq!(route.to_string(), "/games/1/stats");
915 }
916
917 #[test]
918 fn get_game_tags() {
919 let route = Route::GetGameTags { game_id: GAME_ID };
920
921 assert_eq!(route.to_string(), "/games/1/tags");
922 }
923
924 #[test]
925 fn get_mod() {
926 let route = Route::GetMod {
927 game_id: GAME_ID,
928 mod_id: MOD_ID,
929 };
930
931 assert_eq!(route.to_string(), "/games/1/mods/2");
932 }
933
934 #[test]
935 fn get_mod_comment() {
936 let route = Route::GetModComment {
937 game_id: GAME_ID,
938 mod_id: MOD_ID,
939 comment_id: COMMENT_ID,
940 };
941
942 assert_eq!(route.to_string(), "/games/1/mods/2/comments/4");
943 }
944
945 #[test]
946 fn get_mod_comments() {
947 let route = Route::GetModComments {
948 game_id: GAME_ID,
949 mod_id: MOD_ID,
950 };
951
952 assert_eq!(route.to_string(), "/games/1/mods/2/comments");
953 }
954
955 #[test]
956 fn get_mod_dependencies() {
957 let route = Route::GetModDependencies {
958 game_id: GAME_ID,
959 mod_id: MOD_ID,
960 };
961
962 assert_eq!(route.to_string(), "/games/1/mods/2/dependencies");
963 }
964
965 #[test]
966 fn get_mod_events() {
967 let route = Route::GetModEvents {
968 game_id: GAME_ID,
969 mod_id: MOD_ID,
970 };
971
972 assert_eq!(route.to_string(), "/games/1/mods/2/events");
973 }
974
975 #[test]
976 fn get_mod_metadata() {
977 let route = Route::GetModMetadata {
978 game_id: GAME_ID,
979 mod_id: MOD_ID,
980 };
981
982 assert_eq!(route.to_string(), "/games/1/mods/2/metadatakvp");
983 }
984
985 #[test]
986 fn get_mod_stats() {
987 let route = Route::GetModStats {
988 game_id: GAME_ID,
989 mod_id: MOD_ID,
990 };
991
992 assert_eq!(route.to_string(), "/games/1/mods/2/stats");
993 }
994
995 #[test]
996 fn get_mod_tags() {
997 let route = Route::GetModTags {
998 game_id: GAME_ID,
999 mod_id: MOD_ID,
1000 };
1001
1002 assert_eq!(route.to_string(), "/games/1/mods/2/tags");
1003 }
1004
1005 #[test]
1006 fn get_mod_team_members() {
1007 let route = Route::GetModTeamMembers {
1008 game_id: GAME_ID,
1009 mod_id: MOD_ID,
1010 };
1011
1012 assert_eq!(route.to_string(), "/games/1/mods/2/team");
1013 }
1014
1015 #[test]
1016 fn get_mods() {
1017 let route = Route::GetMods { game_id: GAME_ID };
1018
1019 assert_eq!(route.to_string(), "/games/1/mods");
1020 }
1021
1022 #[test]
1023 fn get_mods_events() {
1024 let route = Route::GetModsEvents { game_id: GAME_ID };
1025
1026 assert_eq!(route.to_string(), "/games/1/mods/events");
1027 }
1028
1029 #[test]
1030 fn get_mods_stats() {
1031 let route = Route::GetModsStats { game_id: GAME_ID };
1032
1033 assert_eq!(route.to_string(), "/games/1/mods/stats");
1034 }
1035
1036 #[test]
1037 fn manage_platform_status() {
1038 let route = Route::ManagePlatformStatus {
1039 game_id: GAME_ID,
1040 mod_id: MOD_ID,
1041 file_id: FILE_ID,
1042 };
1043
1044 assert_eq!(route.to_string(), "/games/1/mods/2/files/3/platforms");
1045 }
1046
1047 #[test]
1048 fn mute_user() {
1049 let route = Route::MuteUser { user_id: USER_ID };
1050
1051 assert_eq!(route.to_string(), "/users/5/mute");
1052 }
1053
1054 #[test]
1055 fn oauth_email_request() {
1056 let route = Route::OAuthEmailRequest;
1057
1058 assert_eq!(route.to_string(), "/oauth/emailrequest");
1059 }
1060
1061 #[test]
1062 fn oauth_email_exchange() {
1063 let route = Route::OAuthEmailExchange;
1064
1065 assert_eq!(route.to_string(), "/oauth/emailexchange");
1066 }
1067
1068 #[test]
1069 fn oauth_logout() {
1070 let route = Route::OAuthLogout;
1071
1072 assert_eq!(route.to_string(), "/oauth/logout");
1073 }
1074
1075 #[test]
1076 fn rate_mod() {
1077 let route = Route::RateMod {
1078 game_id: GAME_ID,
1079 mod_id: MOD_ID,
1080 };
1081
1082 assert_eq!(route.to_string(), "/games/1/mods/2/ratings");
1083 }
1084
1085 #[test]
1086 fn rename_game_tags() {
1087 let route = Route::RenameGameTags { game_id: GAME_ID };
1088
1089 assert_eq!(route.to_string(), "/games/1/tags/rename");
1090 }
1091
1092 #[test]
1093 fn reorder_mod_media() {
1094 let route = Route::ReorderModMedia {
1095 game_id: GAME_ID,
1096 mod_id: MOD_ID,
1097 };
1098
1099 assert_eq!(route.to_string(), "/games/1/mods/2/media/reorder");
1100 }
1101
1102 #[test]
1103 fn submit_report() {
1104 let route = Route::SubmitReport;
1105
1106 assert_eq!(route.to_string(), "/report");
1107 }
1108
1109 #[test]
1110 fn subscribe_to_mod() {
1111 let route = Route::SubscribeToMod {
1112 game_id: GAME_ID,
1113 mod_id: MOD_ID,
1114 };
1115
1116 assert_eq!(route.to_string(), "/games/1/mods/2/subscribe");
1117 }
1118
1119 #[test]
1120 fn terms() {
1121 let route = Route::Terms;
1122
1123 assert_eq!(route.to_string(), "/authenticate/terms");
1124 }
1125
1126 #[test]
1127 fn unmute_user() {
1128 let route = Route::UnmuteUser { user_id: USER_ID };
1129
1130 assert_eq!(route.to_string(), "/users/5/mute");
1131 }
1132
1133 #[test]
1134 fn unsubscribe_from_mod() {
1135 let route = Route::UnsubscribeFromMod {
1136 game_id: GAME_ID,
1137 mod_id: MOD_ID,
1138 };
1139
1140 assert_eq!(route.to_string(), "/games/1/mods/2/subscribe");
1141 }
1142
1143 #[test]
1144 fn user_authenticated() {
1145 let route = Route::UserAuthenticated;
1146
1147 assert_eq!(route.to_string(), "/me");
1148 }
1149
1150 #[test]
1151 fn user_events() {
1152 let route = Route::UserEvents;
1153
1154 assert_eq!(route.to_string(), "/me/events");
1155 }
1156
1157 #[test]
1158 fn user_files() {
1159 let route = Route::UserFiles;
1160
1161 assert_eq!(route.to_string(), "/me/files");
1162 }
1163
1164 #[test]
1165 fn user_games() {
1166 let route = Route::UserGames;
1167
1168 assert_eq!(route.to_string(), "/me/games");
1169 }
1170
1171 #[test]
1172 fn user_mods() {
1173 let route = Route::UserMods;
1174
1175 assert_eq!(route.to_string(), "/me/mods");
1176 }
1177
1178 #[test]
1179 fn user_muted() {
1180 let route = Route::UserMuted;
1181
1182 assert_eq!(route.to_string(), "/me/users/muted");
1183 }
1184
1185 #[test]
1186 fn user_ratings() {
1187 let route = Route::UserRatings;
1188
1189 assert_eq!(route.to_string(), "/me/ratings");
1190 }
1191
1192 #[test]
1193 fn user_subscriptions() {
1194 let route = Route::UserSubscriptions;
1195
1196 assert_eq!(route.to_string(), "/me/subscribed");
1197 }
1198}