This repository has been archived by the owner on Apr 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatchmakingAPI.Script.txt
804 lines (715 loc) · 30.3 KB
/
MatchmakingAPI.Script.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
/**
* API for Matchmaking
*/
#Const Version "2021-08-06"
#Const ScriptName "Libs/Nadeo/TMNext/TrackMania/API/MatchmakingAPI.Script.txt"
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Libraries
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
#Include "TextLib" as TL
#Include "Libs/Nadeo/MenuLibs/Common/Manialink/ManiaView2.Script.txt" as MV
#Include "Libs/Nadeo/TMNext/TrackMania/Config.Script.txt" as Config
#Include "Libs/Nadeo/TMNext/TrackMania/Structures/HttpStruct.Script.txt" as HttpStruct
#Include "Libs/Nadeo/CommonLibs/Common/Http.Script.txt" as Http
#Include "Libs/Nadeo/TMNext/TrackMania/Structures/MatchmakingStruct.Script.txt" as MatchmakingStruct
#Include "Libs/Nadeo/CommonLibs/Common/HttpClubAuthorizationHeader.Script.txt" as HttpClubAuthorizationHeader
#Include "Libs/Nadeo/CommonLibs/Common/HttpServerAuthorizationHeader.Script.txt" as HttpServerAuthorizationHeader
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Constants
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
#Const C_Name "component-matchmaking-api" //< Component name
#Const P "ComponentMatchmakingAPI_" //< Prefix use to differentiate functions/variables in the script
#Const C_Headers [
"Accept" => "application/json",
"Content-Type" => "application/json"
]
/* Matchmaking API */
#Const C_API_Matchmaking "/api/matchmaking"
#Const C_API_Official "/api/official"
#Const C_API_Match "/api/match"
#Const C_API_Code "/api/code"
#Const C_Route_PostMatchmakingHeartbeat "/:MatchmakingId/heartbeat"
#Const C_Route_GetMatchmakingPlayerStatus "/:MatchmakingId/player-status"
#Const C_Route_PostMatchmakingAccept "/:MatchmakingId/accept"
#Const C_Route_PostMatchmakingCancel "/:MatchmakingId/cancel"
#Const C_Route_GetLeaderboard "/:MatchmakingId/leaderboard"
#Const C_Route_Me "/me"
#Const C_Route_GetParticipantsScores "/:MatchId/participants"
#Const C_Route_GetMatchmakingDivisionRules "/:MatchmakingId/division/display-rules"
#Const C_Route_GetPlayersProgression "/:MatchmakingId/progression/players"
#Const C_Route_GetCode "/:Code"
#Const C_Route_GetSummary "/summary"
#Const C_Route_GetMyStats "/:MatchmakingId/stats/me"
#Const C_RouteParameter_MatchmakingId "MatchmakingId"
#Const C_RouteParameter_MatchId "MatchId"
#Const C_RouteParameter_QueueName "QueueName"
#Const C_RouteParameter_Code "Code"
#Const C_QueryParameter_Players "players"
/* Club API */
#Const C_API_Matches "/api/matches"
#Const C_Route_GetMatchByLid "/:Match"
#Const C_RouteParameter_MatchLid "Match"
/* Competition API */
#Const C_API_SuperRoyal "/api/me/super-royal"
#Const C_Route_Current "/current"
#Const C_Route_Stats "/stats"
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Structures
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/* Matchmaking API */
#Struct ComponentMatchmakingAPI_K_HttpHeartbeatBody {
Text[] play_with;
Text code;
}
#Struct ComponentMatchmakingAPI_K_HttpHeartbeat {
Text status;
Integer creation_date;
Integer matchmaking_waiting_time;
Text match_live_id;
Integer ban_end_date;
}
#Struct ComponentMatchmakingAPI_K_HttpPenalty {
Integer creation_date;
Integer points;
}
#Struct ComponentMatchmakingAPI_K_HttpPlayerStatus {
ComponentMatchmakingAPI_K_HttpHeartbeat current_heartbeat;
ComponentMatchmakingAPI_K_HttpPenalty penalty;
Text current_division;
Integer current_progression;
Text matchmaking_status;
}
#Struct ComponentMatchmakingAPI_K_HttpMatch {
Text join_link;
}
#Struct ComponentMatchmakingAPI_K_HttpPlayerRanking {
Integer matchmaking_id;
Text player;
Integer score;
}
#Struct ComponentMatchmakingAPI_K_HttpParticipant {
Text player;
Text current_division;
Integer current_progression;
}
#Struct ComponentMatchmakingAPI_K_HttpMatchParticipants {
Boolean is_completed;
ComponentMatchmakingAPI_K_HttpParticipant[] participants;
}
#Struct ComponentMatchmakingAPI_K_HttpOfficialQueueSummary {
Integer ranked_3v3_id;
Integer royal_id;
Integer super_royal_id;
}
#Struct ComponentMatchmakingAPI_K_HttpDivisionRules {
Text id;
Integer position;
Text display_rule_type;
Integer display_rule_minimum_points;
Integer display_rule_maximum_points;
Integer display_rule_minimum_rank;
}
#Struct ComponentMatchmakingAPI_K_HttpDisplayDivisionRules {
ComponentMatchmakingAPI_K_HttpDivisionRules[] divisions;
}
#Struct ComponentMatchmakingAPI_K_HttpPlayerProgression {
Text player;
Text division;
Integer progression;
}
#Struct ComponentMatchmakingAPI_K_HttpProgressions {
ComponentMatchmakingAPI_K_HttpPlayerProgression[] progressions;
}
#Struct ComponentMatchmakingAPI_K_HttpCode {
Text code;
}
#Struct ComponentMatchmakingAPI_K_HttpSuperRoyal {
Integer starts_in;
Text status;
Text match_live_id;
}
#Struct ComponentMatchmakingAPI_K_HttpSuperRoyalStatistics {
Integer master_won;
Integer gold_won;
Integer silver_won;
Integer bronze_won;
}
#Struct ComponentMatchmakingAPI_K_HttpPlayerStatistics {
Integer matchmaking_id;
Text player;
Text current_division;
Integer current_progression;
Text best_division;
Integer best_progression;
Integer best_progression_date;
Text previous_division;
Integer previous_progression;
Integer previous_progression_date;
Integer mvp_count;
Integer victories;
Integer played_matches;
}
#Struct ComponentMatchmakingAPI_K_HttpPlayerLeaderboard {
Text player;
Integer rank;
Integer score;
}
#Struct ComponentMatchmakingAPI_K_HttpLeaderboard {
Text matchmaking_id;
Integer cardinal;
ComponentMatchmakingAPI_K_HttpPlayerLeaderboard[] results;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Functions
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
Text[Text] GetHeadersWithClubAuth() {
declare Text[Text] Headers = C_Headers;
declare Text AuthorizationHeaders = HttpClubAuthorizationHeader::Get();
declare Text KeyAutho = TL::SubString(AuthorizationHeaders, 0, TL::Length("Authorization"));
declare Text ValueAutho = TL::SubString(AuthorizationHeaders, TL::Length("Authorization: "), TL::Length(AuthorizationHeaders));
Headers[KeyAutho] = ValueAutho;
return Headers;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Get the players scores (skill level and score delta) for a given match
Http::LibCommonHttp_K_Request Server_GetMatchParticipants(Text _MatchId) {
declare Text Route = Http::InjectRouteParameters(C_Route_GetParticipantsScores, [C_RouteParameter_MatchId => _MatchId]);
return Http::CreateGet(Config::Get().APIMatchmakingUrl^C_API_Match^Route, HttpServerAuthorizationHeader::GetHeadersWithClubAuthorization(C_Headers));
}
MatchmakingStruct::LibStructuresMatchmaking_K_MatchParticipants GetResponseFromGetMatchParticipants(Http::LibCommonHttp_K_Request _Request) {
declare ComponentMatchmakingAPI_K_HttpMatchParticipants MatchParticipantsResponse;
MatchParticipantsResponse.fromjson(Http::GetResult(_Request));
declare MatchmakingStruct::LibStructuresMatchmaking_K_PlayerProgression[Text] Participants;
foreach (Participant in MatchParticipantsResponse.participants) {
Participants[Participant.player] = MatchmakingStruct::LibStructuresMatchmaking_K_PlayerProgression {
AccountId = Participant.player,
CurrentDivision = Participant.current_division,
CurrentProgression = Participant.current_progression
};
}
declare MatchParticipants = MatchmakingStruct::LibStructuresMatchmaking_K_MatchParticipants {
IsCompleted = MatchParticipantsResponse.is_completed,
Participants = Participants
};
return MatchParticipants;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the matchmaking division rules
*
* @param _MatchmakingId The id of matchmaking queue
*
* @return The request
*/
Http::LibCommonHttp_K_Request Server_GetMatchmakingDivisionRules(Text _MatchmakingId) {
declare Text Route = Http::InjectRouteParameters(
C_Route_GetMatchmakingDivisionRules,
[C_RouteParameter_MatchmakingId => _MatchmakingId]
);
return Http::CreateGet(Config::Get().APIMatchmakingUrl^C_API_Matchmaking^Route, HttpServerAuthorizationHeader::GetHeadersWithClubAuthorization(C_Headers));
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the matchmaking division rules
*
* @param _MatchmakingId The id of matchmaking queue
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetMatchmakingDivisionRules(Integer _MatchmakingId) {
declare Text Route = Http::InjectRouteParameters(
C_Route_GetMatchmakingDivisionRules,
[C_RouteParameter_MatchmakingId => ""^_MatchmakingId]
);
return Http::CreateGet(Config::Get().APIMatchmakingUrl^C_API_Matchmaking^Route, GetHeadersWithClubAuth());
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Parse the response of Server_GetMatchmakingDivisionRules and GetMatchmakingDivisionRules requests
MatchmakingStruct::LibStructuresMatchmaking_K_Division[Text] GetResponseFromGetMatchmakingDivisionRules(Http::LibCommonHttp_K_Request _Request) {
declare ComponentMatchmakingAPI_K_HttpDisplayDivisionRules DisplayDivisionRulesResponse;
DisplayDivisionRulesResponse.fromjson(Http::GetResult(_Request));
declare MatchmakingStruct::LibStructuresMatchmaking_K_Division[Text] Divisions;
foreach (division in DisplayDivisionRulesResponse.divisions) {
Divisions[division.id] = MatchmakingStruct::LibStructuresMatchmaking_K_Division {
Id = division.id,
Position = division.position,
RuleType = division.display_rule_type,
MinimumPoints = division.display_rule_minimum_points,
MaximumPoints = division.display_rule_maximum_points,
MinimumRank = division.display_rule_minimum_rank
};
}
return Divisions;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the official queue ids summary
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetOfficialQueueSummary() {
declare Http::LibCommonHttp_K_Request Request = Http::CreateGet(Config::Get().APIMatchmakingUrl^C_API_Official^C_Route_GetSummary, GetHeadersWithClubAuth());
return Request;
}
MatchmakingStruct::LibStructuresMatchmaking_K_QueueSummary GetResponseFromGetOfficialQueueSummary(Http::LibCommonHttp_K_Request _Request) {
declare ComponentMatchmakingAPI_K_HttpOfficialQueueSummary OfficialQueueSummaryResponse;
OfficialQueueSummaryResponse.fromjson(Http::GetResult(_Request));
declare MatchmakingStruct::LibStructuresMatchmaking_K_QueueSummary QueueSummary = MatchmakingStruct::LibStructuresMatchmaking_K_QueueSummary {
Ranked_3v3_Id = OfficialQueueSummaryResponse.ranked_3v3_id,
Royal_Id = OfficialQueueSummaryResponse.royal_id,
Super_Royal_Id = OfficialQueueSummaryResponse.super_royal_id
};
return QueueSummary;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the players progressions
*
* @param _MatchmakingId The id of matchmaking queue
* @param _AccountIds The array of the players accountIds
*
* @return The request
*/
Http::LibCommonHttp_K_Request GetMatchmakingPlayersProgressions(Integer _MatchmakingId, Text[] _AccountIds) {
declare Text Route = Http::InjectRouteParameters(
C_Route_GetPlayersProgression,
[C_RouteParameter_MatchmakingId => ""^_MatchmakingId]
);
declare QueryString = Http::CreateQueryString([
C_QueryParameter_Players => _AccountIds
]);
return Http::CreateGet(Config::Get().APIMatchmakingUrl^C_API_Matchmaking^Route^QueryString, GetHeadersWithClubAuth());
}
MatchmakingStruct::LibStructuresMatchmaking_K_PlayerProgression[Text] GetResponseFromGetMatchmakingPlayersProgressions(Http::LibCommonHttp_K_Request _Request) {
declare ComponentMatchmakingAPI_K_HttpProgressions ProgressionsResponse;
ProgressionsResponse.fromjson(Http::GetResult(_Request));
declare MatchmakingStruct::LibStructuresMatchmaking_K_PlayerProgression[Text] Progressions;
foreach (Progression in ProgressionsResponse.progressions) {
Progressions[Progression.player] = MatchmakingStruct::LibStructuresMatchmaking_K_PlayerProgression {
AccountId = Progression.player,
CurrentDivision = Progression.division,
CurrentProgression = Progression.progression
};
}
return Progressions;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the local player leaderboard
*
* @param _MatchmakingId The id of matchmaking queue
*
* @return The request
*/
Http::LibCommonHttp_K_Request Server_GetMatchmakingLeaderboard(Text _MatchmakingId) {
declare Text Route = Http::InjectRouteParameters(
C_Route_GetLeaderboard,
[C_RouteParameter_MatchmakingId => _MatchmakingId]
);
return Http::CreateGet(Config::Get().APIMatchmakingUrl^C_API_Matchmaking^Route, HttpServerAuthorizationHeader::GetHeadersWithClubAuthorization(C_Headers));
}
MatchmakingStruct::LibStructuresMatchmaking_K_PlayerLeaderboard[] GetResponseFromGetMatchmakingLeaderboard(Http::LibCommonHttp_K_Request _Request) {
declare ComponentMatchmakingAPI_K_HttpLeaderboard LeaderboardResponse;
LeaderboardResponse.fromjson(Http::GetResult(_Request));
declare MatchmakingStruct::LibStructuresMatchmaking_K_PlayerLeaderboard[] Leaderboard = [];
foreach (Result in LeaderboardResponse.results) {
Leaderboard.add(MatchmakingStruct::LibStructuresMatchmaking_K_PlayerLeaderboard {
AccountId = Result.player,
Rank = Result.rank,
Score = Result.score
});
}
return Leaderboard;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Get the component
*
* @return The component id
*/
Text Component() {
return MV::Component(
C_Name,
"""
""",
"""
#Include "TextLib" as {{{P}}}TL
/* Matchmaking API */
#Const {{{P}}}C_Headers {{{dump(C_Headers)}}}
#Const {{{P}}}C_API_Matchmaking {{{dump(C_API_Matchmaking)}}}
#Const {{{P}}}C_API_Official {{{dump(C_API_Official)}}}
#Const {{{P}}}C_API_Code {{{dump(C_API_Code)}}}
#Const {{{P}}}C_API_SuperRoyal {{{dump(C_API_SuperRoyal)}}}
#Const {{{P}}}C_Route_PostMatchmakingHeartbeat {{{dump(C_Route_PostMatchmakingHeartbeat)}}}
#Const {{{P}}}C_Route_GetMatchmakingPlayerStatus {{{dump(C_Route_GetMatchmakingPlayerStatus)}}}
#Const {{{P}}}C_Route_PostMatchmakingAccept {{{dump(C_Route_PostMatchmakingAccept)}}}
#Const {{{P}}}C_Route_PostMatchmakingCancel {{{dump(C_Route_PostMatchmakingCancel)}}}
#Const {{{P}}}C_Route_GetLeaderboard {{{dump(C_Route_GetLeaderboard)}}}
#Const {{{P}}}C_Route_Me {{{dump(C_Route_Me)}}}
#Const {{{P}}}C_Route_GetCode {{{dump(C_Route_GetCode)}}}
#Const {{{P}}}C_RouteParameter_MatchmakingId {{{dump(C_RouteParameter_MatchmakingId)}}}
#Const {{{P}}}C_Route_GetMatchmakingDivisionRules {{{dump(C_Route_GetMatchmakingDivisionRules)}}}
#Const {{{P}}}C_RouteParameter_QueueName {{{dump(C_RouteParameter_QueueName)}}}
#Const {{{P}}}C_Route_GetPlayersProgression {{{dump(C_Route_GetPlayersProgression)}}}
#Const {{{P}}}C_RouteParameter_Code {{{dump(C_RouteParameter_Code)}}}
#Const {{{P}}}C_Route_GetMyStats {{{dump(C_Route_GetMyStats)}}}
#Const {{{P}}}C_Route_Current {{{dump(C_Route_Current)}}}
#Const {{{P}}}C_Route_Stats {{{dump(C_Route_Stats)}}}
#Const {{{P}}}C_QueryParameter_Players {{{dump(C_QueryParameter_Players)}}}
/* Club API */
#Const {{{P}}}C_API_Matches {{{dump(C_API_Matches)}}}
#Const {{{P}}}C_Route_GetMatchByLid {{{dump(C_Route_GetMatchByLid)}}}
#Const {{{P}}}C_RouteParameter_MatchLid {{{dump(C_RouteParameter_MatchLid)}}}
{{{dumptype(ComponentMatchmakingAPI_K_HttpHeartbeatBody)}}}
{{{dumptype(ComponentMatchmakingAPI_K_HttpHeartbeat)}}}
{{{dumptype(ComponentMatchmakingAPI_K_HttpPenalty)}}}
{{{dumptype(ComponentMatchmakingAPI_K_HttpPlayerStatus)}}}
{{{dumptype(ComponentMatchmakingAPI_K_HttpMatch)}}}
{{{dumptype(ComponentMatchmakingAPI_K_HttpPlayerRanking)}}}
{{{dumptype(ComponentMatchmakingAPI_K_HttpDivisionRules)}}}
{{{dumptype(ComponentMatchmakingAPI_K_HttpDisplayDivisionRules)}}}
{{{dumptype(ComponentMatchmakingAPI_K_HttpPlayerProgression)}}}
{{{dumptype(ComponentMatchmakingAPI_K_HttpProgressions)}}}
{{{dumptype(ComponentMatchmakingAPI_K_HttpCode)}}}
{{{dumptype(ComponentMatchmakingAPI_K_HttpSuperRoyal)}}}
{{{dumptype(ComponentMatchmakingAPI_K_HttpSuperRoyalStatistics)}}}
{{{dumptype(ComponentMatchmakingAPI_K_HttpPlayerStatistics)}}}
{{{dumptype(ComponentMatchmakingAPI_K_HttpPlayerLeaderboard)}}}
{{{dumptype(ComponentMatchmakingAPI_K_HttpLeaderboard)}}}
""",
"""
Text[Text] {{{P}}}GetHeadersWithClubAuth() {
declare Text[Text] Headers = {{{P}}}C_Headers;
declare Text AuthorizationHeaders = {{{HttpClubAuthorizationHeader::P}}}Get();
declare Text KeyAutho = {{{P}}}TL::SubString(AuthorizationHeaders, 0, 13);
declare Text ValueAutho = {{{P}}}TL::SubString(AuthorizationHeaders, 15, {{{P}}}TL::Length(AuthorizationHeaders));
Headers[KeyAutho] = ValueAutho;
return Headers;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to post a Matchmaking Heartbeat
*
* @param _MatchmakingId The id of matchmaking queue
*
* @return The request
*/
{{{Http::P}}}K_Request {{{P}}}PostMatchmakingHeartbeat(Integer _MatchmakingId, Text[] _SquadMembersIds, Text _Code) {
declare Text Route = {{{Http::P}}}InjectRouteParameters(
{{{P}}}C_Route_PostMatchmakingHeartbeat,
[{{{P}}}C_RouteParameter_MatchmakingId => ""^_MatchmakingId]
);
declare {{{P}}}K_HttpHeartbeatBody HeartBeatBody = {{{P}}}K_HttpHeartbeatBody {
play_with = _SquadMembersIds,
code = _Code
};
return {{{Http::P}}}CreatePost({{{Config::P}}}Get().APIMatchmakingUrl^{{{P}}}C_API_Matchmaking^Route, HeartBeatBody.tojson(), {{{P}}}GetHeadersWithClubAuth());
}
{{{MatchmakingStruct::P}}}K_Heartbeat HeartbeatApiToScript(ComponentMatchmakingAPI_K_HttpHeartbeat _HeartbeatResponse) {
return {{{MatchmakingStruct::P}}}K_Heartbeat {
Status = _HeartbeatResponse.status,
CreationDate = _HeartbeatResponse.creation_date,
MatchmakingWaitingTime = _HeartbeatResponse.matchmaking_waiting_time,
MatchLiveId = _HeartbeatResponse.match_live_id,
BanEndDate = _HeartbeatResponse.ban_end_date
};
}
{{{MatchmakingStruct::P}}}K_Heartbeat {{{P}}}GetResponseFromPostMatchmakingHeartbeat({{{Http::P}}}K_Request _Request) {
declare ComponentMatchmakingAPI_K_HttpHeartbeat HeartbeatResponse;
HeartbeatResponse.fromjson({{{Http::P}}}GetResult(_Request));
return HeartbeatApiToScript(HeartbeatResponse);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the player status
*
* @param _MatchmakingId The id of matchmaking queue
*
* @return The request
*/
{{{Http::P}}}K_Request {{{P}}}GetMatchmakingPlayerStatus(Integer _MatchmakingId) {
declare Text Route = {{{Http::P}}}InjectRouteParameters(
{{{P}}}C_Route_GetMatchmakingPlayerStatus,
[{{{P}}}C_RouteParameter_MatchmakingId => ""^_MatchmakingId]
);
return {{{Http::P}}}CreateGet({{{Config::P}}}Get().APIMatchmakingUrl^{{{P}}}C_API_Matchmaking^Route, {{{P}}}GetHeadersWithClubAuth());
}
{{{MatchmakingStruct::P}}}K_PlayerStatus {{{P}}}GetResponseFromGetMatchmakingPlayerStatus({{{Http::P}}}K_Request _Request) {
declare ComponentMatchmakingAPI_K_HttpPlayerStatus PlayerStatusResponse;
PlayerStatusResponse.fromjson({{{Http::P}}}GetResult(_Request));
return {{{MatchmakingStruct::P}}}K_PlayerStatus {
CurrentHeartbeat = HeartbeatApiToScript(PlayerStatusResponse.current_heartbeat),
Penalty = {{{MatchmakingStruct::P}}}K_Penalty {
CreationDate = PlayerStatusResponse.penalty.creation_date,
Points = PlayerStatusResponse.penalty.points
},
CurrentDivision = PlayerStatusResponse.current_division,
CurrentProgression = PlayerStatusResponse.current_progression,
MatchmakingStatus = PlayerStatusResponse.matchmaking_status
};
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the matchmaking division rules
*
* @param _MatchmakingId The id of matchmaking queue
*
* @return The request
*/
{{{Http::P}}}K_Request {{{P}}}GetMatchmakingDivisionRules(Integer _MatchmakingId) {
declare Text Route = {{{Http::P}}}InjectRouteParameters(
{{{P}}}C_Route_GetMatchmakingDivisionRules,
[{{{P}}}C_RouteParameter_MatchmakingId => ""^_MatchmakingId]
);
return {{{Http::P}}}CreateGet({{{Config::P}}}Get().APIMatchmakingUrl^{{{P}}}C_API_Matchmaking^Route, {{{P}}}GetHeadersWithClubAuth());
}
{{{MatchmakingStruct::P}}}K_Division[Text] {{{P}}}GetResponseFromGetMatchmakingDivisionRules({{{Http::P}}}K_Request _Request) {
declare ComponentMatchmakingAPI_K_HttpDisplayDivisionRules DisplayDivisionRulesResponse;
DisplayDivisionRulesResponse.fromjson({{{Http::P}}}GetResult(_Request));
declare {{{MatchmakingStruct::P}}}K_Division[Text] Divisions;
foreach (division in DisplayDivisionRulesResponse.divisions) {
Divisions[division.id] = {{{MatchmakingStruct::P}}}K_Division {
Id = division.id,
Position = division.position,
RuleType = division.display_rule_type,
MinimumPoints = division.display_rule_minimum_points,
MaximumPoints = division.display_rule_maximum_points,
MinimumRank = division.display_rule_minimum_rank
};
}
return Divisions;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the local player leaderboard
*
* @param _MatchmakingId The id of matchmaking queue
*
* @return The request
*/
{{{Http::P}}}K_Request {{{P}}}GetMyMatchmakingLeaderboard(Integer _MatchmakingId) {
declare Text Route = {{{Http::P}}}InjectRouteParameters(
{{{P}}}C_Route_GetLeaderboard,
[{{{P}}}C_RouteParameter_MatchmakingId => ""^_MatchmakingId]
);
return {{{Http::P}}}CreateGet({{{Config::P}}}Get().APIMatchmakingUrl^{{{P}}}C_API_Matchmaking^Route^{{{P}}}C_Route_Me, {{{P}}}GetHeadersWithClubAuth());
}
{{{MatchmakingStruct::P}}}K_PlayerRank {{{P}}}GetResponseFromGetMyMatchmakingLeaderboard({{{Http::P}}}K_Request _Request) {
declare ComponentMatchmakingAPI_K_HttpPlayerRanking LeaderboardResponse;
LeaderboardResponse.fromjson({{{Http::P}}}GetResult(_Request));
declare Leaderboard = {{{MatchmakingStruct::P}}}K_PlayerRank {
MatchmakingId = LeaderboardResponse.matchmaking_id,
AccountId = LeaderboardResponse.player,
Score = LeaderboardResponse.score
};
return Leaderboard;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the local player leaderboard
*
* @param _MatchmakingId The id of matchmaking queue
*
* @return The request
*/
{{{Http::P}}}K_Request {{{P}}}GetMatchmakingLeaderboard(Integer _MatchmakingId) {
declare Text Route = {{{Http::P}}}InjectRouteParameters(
{{{P}}}C_Route_GetLeaderboard,
[{{{P}}}C_RouteParameter_MatchmakingId => ""^_MatchmakingId]
);
return {{{Http::P}}}CreateGet({{{Config::P}}}Get().APIMatchmakingUrl^{{{P}}}C_API_Matchmaking^Route, {{{P}}}GetHeadersWithClubAuth());
}
{{{MatchmakingStruct::P}}}K_PlayerLeaderboard[] {{{P}}}GetResponseFromGetMatchmakingLeaderboard({{{Http::P}}}K_Request _Request) {
declare ComponentMatchmakingAPI_K_HttpLeaderboard LeaderboardResponse;
LeaderboardResponse.fromjson({{{Http::P}}}GetResult(_Request));
declare {{{MatchmakingStruct::P}}}K_PlayerLeaderboard[] Leaderboard = [];
foreach (Result in LeaderboardResponse.results) {
Leaderboard.add({{{MatchmakingStruct::P}}}K_PlayerLeaderboard {
AccountId = Result.player,
Rank = Result.rank,
Score = Result.score
});
}
return Leaderboard;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to post "accept match". NB no response body.
*
* @param _MatchmakingId The id of matchmaking queue
*
* @return The request
*/
{{{Http::P}}}K_Request {{{P}}}PostMatchmakingAccept(Integer _MatchmakingId) {
declare Text Route = {{{Http::P}}}InjectRouteParameters(
{{{P}}}C_Route_PostMatchmakingAccept,
[{{{P}}}C_RouteParameter_MatchmakingId => ""^_MatchmakingId]
);
return {{{Http::P}}}CreatePost({{{Config::P}}}Get().APIMatchmakingUrl^{{{P}}}C_API_Matchmaking^Route, "", {{{P}}}GetHeadersWithClubAuth());
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to post "cancel match". NB no response body.
*
* @param _MatchmakingId The id of matchmaking queue
*
* @return The request
*/
{{{Http::P}}}K_Request {{{P}}}PostMatchmakingCancel(Integer _MatchmakingId) {
declare Text Route = {{{Http::P}}}InjectRouteParameters(
{{{P}}}C_Route_PostMatchmakingCancel,
[{{{P}}}C_RouteParameter_MatchmakingId => ""^_MatchmakingId]
);
return {{{Http::P}}}CreatePost({{{Config::P}}}Get().APIMatchmakingUrl^{{{P}}}C_API_Matchmaking^Route, "", {{{P}}}GetHeadersWithClubAuth());
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get a match by match Lid
*
* @param _MatchId The Lid of match
*
* @return The request
*/
{{{Http::P}}}K_Request {{{P}}}GetMatchByLid(Text _MatchLid) {
declare Text Route = {{{Http::P}}}InjectRouteParameters(
{{{P}}}C_Route_GetMatchByLid,
[{{{P}}}C_RouteParameter_MatchLid => _MatchLid]
);
return {{{Http::P}}}CreateGet({{{Config::P}}}Get().APIBordeauxClubUrl^{{{P}}}C_API_Matches^Route, {{{P}}}GetHeadersWithClubAuth());
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Match by Lid response
*
* @param _Request The request
*
* @return The match join link
*/
Text {{{P}}}GetResponseFromGetMatchByLid({{{Http::P}}}K_Request _Request) {
declare ComponentMatchmakingAPI_K_HttpMatch MatchResponse;
MatchResponse.fromjson({{{Http::P}}}GetResult(_Request));
return MatchResponse.join_link;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the players progressions
*
* @param _MatchmakingId The id of matchmaking queue
* @param _AccountIds The array of the players accountIds
*
* @return The request
*/
{{{Http::P}}}K_Request {{{P}}}GetMatchmakingPlayersProgressions(Integer _MatchmakingId, Text[] _AccountIds) {
declare Text Route = {{{Http::P}}}InjectRouteParameters(
{{{P}}}C_Route_GetPlayersProgression,
[{{{P}}}C_RouteParameter_MatchmakingId => ""^_MatchmakingId]
);
declare QueryString ={{{Http::P}}}CreateQueryString([
{{{P}}}C_QueryParameter_Players => _AccountIds
]);
return {{{Http::P}}}CreateGet({{{Config::P}}}Get().APIMatchmakingUrl^{{{P}}}C_API_Matchmaking^Route^QueryString, {{{P}}}GetHeadersWithClubAuth());
}
{{{MatchmakingStruct::P}}}K_PlayerProgression[Text] {{{P}}}GetResponseFromGetMatchmakingPlayersProgressions({{{Http::P}}}K_Request _Request) {
declare ComponentMatchmakingAPI_K_HttpProgressions ProgressionsResponse;
ProgressionsResponse.fromjson({{{Http::P}}}GetResult(_Request));
declare {{{MatchmakingStruct::P}}}K_PlayerProgression[Text] Progressions;
foreach (Progression in ProgressionsResponse.progressions) {
Progressions[Progression.player] = {{{MatchmakingStruct::P}}}K_PlayerProgression {
AccountId = Progression.player,
CurrentDivision = Progression.division,
CurrentProgression = Progression.progression
};
}
return Progressions;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to generate a Party Code
*
* @return The request
*/
{{{Http::P}}}K_Request {{{P}}}GeneratePartyCode() {
return {{{Http::P}}}CreatePost({{{Config::P}}}Get().APIMatchmakingUrl^{{{P}}}C_API_Code, "", {{{P}}}GetHeadersWithClubAuth());
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to check if a party code is correct (meaning available in CLUB database)
*
* @param _Code The code to check
*
* @return The request
*/
{{{Http::P}}}K_Request {{{P}}}CheckPartyCode(Text _Code) {
declare Text Route = {{{Http::P}}}InjectRouteParameters(
{{{P}}}C_Route_GetCode,
[{{{P}}}C_RouteParameter_Code => _Code]
);
return {{{Http::P}}}CreateGet({{{Config::P}}}Get().APIMatchmakingUrl^{{{P}}}C_API_Code^Route, {{{P}}}GetHeadersWithClubAuth());
}
Text {{{P}}}GetResponseFromPartyCode({{{Http::P}}}K_Request _Request) {
declare ComponentMatchmakingAPI_K_HttpCode CodeResponse;
CodeResponse.fromjson({{{Http::P}}}GetResult(_Request));
declare Text Code = CodeResponse.code;
return Code;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to have the SuperRoyal infos
*
* @return The request
*/
{{{Http::P}}}K_Request {{{P}}}GetCurrentSuperRoyal() {
return {{{Http::P}}}CreateGet({{{Config::P}}}Get().APICompetitionUrl^{{{P}}}C_API_SuperRoyal^{{{P}}}C_Route_Current, {{{P}}}GetHeadersWithClubAuth());
}
{{{MatchmakingStruct::P}}}K_SuperRoyal {{{P}}}GetResponseFromCurrentSuperRoyal({{{Http::P}}}K_Request _Request) {
declare ComponentMatchmakingAPI_K_HttpSuperRoyal SuperRoyalResponse;
SuperRoyalResponse.fromjson({{{Http::P}}}GetResult(_Request));
return {{{MatchmakingStruct::P}}}K_SuperRoyal {
StartsIn = SuperRoyalResponse.starts_in,
Status = SuperRoyalResponse.status,
MatchLiveId = SuperRoyalResponse.match_live_id
};
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to have the SuperRoyal infos
*
* @return The request
*/
{{{Http::P}}}K_Request {{{P}}}GetSuperRoyalStats() {
return {{{Http::P}}}CreateGet({{{Config::P}}}Get().APICompetitionUrl^{{{P}}}C_API_SuperRoyal^{{{P}}}C_Route_Stats, {{{P}}}GetHeadersWithClubAuth());
}
{{{MatchmakingStruct::P}}}K_SuperRoyalStatistics {{{P}}}GetResponseFromSuperRoyalStats({{{Http::P}}}K_Request _Request) {
declare ComponentMatchmakingAPI_K_HttpSuperRoyalStatistics SuperRoyalStatsResponse;
SuperRoyalStatsResponse.fromjson({{{Http::P}}}GetResult(_Request));
return {{{MatchmakingStruct::P}}}K_SuperRoyalStatistics {
BronzeVictories = SuperRoyalStatsResponse.bronze_won,
SilverVictories = SuperRoyalStatsResponse.silver_won,
GoldVictories = SuperRoyalStatsResponse.gold_won,
MasterVictories = SuperRoyalStatsResponse.master_won
};
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Start a request to get the player statistics in a specific matchmaking
*
* @param _MatchmakingId The id of matchmaking queue
*
* @return The request
*/
{{{Http::P}}}K_Request {{{P}}}GetPlayerMatchmakingStatistics(Integer _MatchmakingId) {
declare Text Route = {{{Http::P}}}InjectRouteParameters(
{{{P}}}C_Route_GetMyStats,
[{{{P}}}C_RouteParameter_MatchmakingId => ""^_MatchmakingId]
);
return {{{Http::P}}}CreateGet({{{Config::P}}}Get().APIMatchmakingUrl^{{{P}}}C_API_Matchmaking^Route, {{{P}}}GetHeadersWithClubAuth());
}
{{{MatchmakingStruct::P}}}K_PlayerStatistics {{{P}}}GetResponseFromGetPlayerMatchmakingStatistics({{{Http::P}}}K_Request _Request) {
declare ComponentMatchmakingAPI_K_HttpPlayerStatistics PlayerStatisticsResponse;
PlayerStatisticsResponse.fromjson({{{Http::P}}}GetResult(_Request));
return {{{MatchmakingStruct::P}}}K_PlayerStatistics {
MatchmakingId = PlayerStatisticsResponse.matchmaking_id,
AccountId = PlayerStatisticsResponse.player,
CurrentDivision = PlayerStatisticsResponse.current_division,
CurrentProgression = PlayerStatisticsResponse.current_progression,
BestDivision = PlayerStatisticsResponse.best_division,
BestProgression = PlayerStatisticsResponse.best_progression,
BestProgressionDate = PlayerStatisticsResponse.best_progression_date,
PreviousDivision = PlayerStatisticsResponse.previous_division,
PreviousProgression = PlayerStatisticsResponse.previous_progression,
PreviousProgressionDate = PlayerStatisticsResponse.previous_progression_date,
MVPCount = PlayerStatisticsResponse.mvp_count,
Victories = PlayerStatisticsResponse.victories,
PlayedMatches = PlayerStatisticsResponse.played_matches
};
}
""",
[
Http::Component(),
MatchmakingStruct::Component(),
HttpStruct::Component(),
Config::Component(),
HttpClubAuthorizationHeader::Component()
],
[]
);
}