summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/include/GlobalAPI.inc
blob: 88136450580af143f8141a2e01ffebf2089034a3 (plain)
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
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
// ================== DOUBLE INCLUDE ========================= //

#if defined _GlobalAPI_included_
#endinput
#endif
#define _GlobalAPI_included_

// ======================= DEFINITIONS ======================= //

#define DEFAULT_DATA 0
#define DEFAULT_INT -1
#define DEFAULT_STRING ""
#define DEFAULT_FLOAT -1.0
#define DEFAULT_BOOL view_as<bool>(-1)

#define GlobalAPI_Plugin_Version "2.0.0"
#define GlobalAPI_Plugin_Desc "Plugin helper for GlobalAPI Production & Staging"
#define GlobalAPI_Plugin_Url "https://bitbucket.org/kztimerglobalteam/GlobalAPI-SMPlugin"
#define GlobalAPI_Plugin_NameVersion "GlobalAPI Plugin " ... GlobalAPI_Plugin_Version

#define GlobalAPI_Backend_Version "v2.0"
#define GlobalAPI_Backend_Staging_Version "v2.0"
#define GlobalAPI_BaseUrl "https://kztimerglobal.com/api/" ... GlobalAPI_Backend_Version
#define GlobalAPI_Staging_BaseUrl "https://globalapi.ruto.sh/api/" ... GlobalAPI_Backend_Staging_Version

#define GlobalAPI_Max_BaseUrl_Length 128
#define GlobalAPI_Max_QueryParam_Num 20
#define GlobalAPI_Max_QueryParam_Length 64
#define GlobalAPI_Max_QueryParams_Length (GlobalAPI_Max_QueryParam_Num * GlobalAPI_Max_QueryParam_Length)
#define GlobalAPI_Max_QueryUrl_Length (GlobalAPI_Max_QueryParams_Length + GlobalAPI_Max_BaseUrl_Length)
#define GlobalAPI_Max_QueryParam_Array_Length 64

#define GlobalAPI_Max_APIKey_Length 128
#define GlobalAPI_Max_PluginName_Length 64
#define GlobalAPI_Max_PluginVersion_Length 32
#define GlobalAPI_Data_File_Extension "GAPI"

// ======================= INCLUDES ========================== //

#include <GlobalAPI/requestdata>
#include <GlobalAPI/responses>
#include <GlobalAPI/stocks>

// ======================= ENUMS ============================= //

/**
 * Defines what request method is used on requests
 */
enum
{
	GlobalAPIRequestType_GET = 0,	/**< Request uses GET HTTP method */
	GlobalAPIRequestType_POST		/**< Request uses POST HTTP method */
};

/**
 * Defines what accept type is used on requests
 */
enum
{
	GlobalAPIRequestAcceptType_JSON = 0,	/**< Request uses application/json HTTP accept type */
	GlobalAPIRequestAcceptType_OctetStream	/**< Request uses application/octet-stream HTTP accept type */
};

/**
 * Defines what content type is used on requests
 */
enum
{
	GlobalAPIRequestContentType_JSON = 0,	/**< Request uses application/json HTTP content type */
	GlobalAPIRequestContentType_OctetStream	/**< Request uses application/octet-stream HTTP content type */
};

// ======================= TYPEDEFS ========================== //

/*
	Function types when API call finishes
*/
typeset OnAPICallFinished
{
   /**
 	* Called when an API call has finished
 	*
 	* @param hResponse			JSON_Object handle to the response
 	* @param hData				GlobalAPIRequestData handle for the request
 	* @noreturn
 	*/
	function void(JSON_Object hResponse, GlobalAPIRequestData hData);

   /**
 	* Called when an API call has finished
 	*
 	* @param hResponse			JSON_Object handle to the response
 	* @param hData				GlobalAPIRequestData handle for the request
 	* @param data				Optional data that was passed
 	* @noreturn
 	*/
	function void(JSON_Object hResponse, GlobalAPIRequestData hData, any data);
};

// ======================= FORWARDS ========================== //

/**
 * Called when GlobalAPI plugin is initialized,
 * this means API Key is loaded and all the cvars are loaded
 *
 * @noreturn
 */
forward void GlobalAPI_OnInitialized();

/**
 * Called when GlobalAPI plugin has failed a request
 *
 * @param request				Handle to the request failed
 * @param hData					Handle to request's GlobalAPIRequestData
 * @noreturn
 */
forward void GlobalAPI_OnRequestFailed(Handle request, GlobalAPIRequestData hData);

/**
 * Called when GlobalAPI plugin has started a request
 *
 * @param request				Handle to the request started
 * @param hData					Handle to request's GlobalAPIRequestData
 * @noreturn
 */
forward void GlobalAPI_OnRequestStarted(Handle request, GlobalAPIRequestData hData);

/**
 * Called when GlobalAPI plugin has finished a request
 *
 * @param request				Handle to the request finished
 * @param hData					Handle to request's GlobalAPIRequestData
 * @noreturn
 */
forward void GlobalAPI_OnRequestFinished(Handle request, GlobalAPIRequestData hData);

// ======================= NATIVES =========================== //

/**
 * Gets a boolean of whether GlobalAPI plugin is initialized.
 *
 * @note						See GlobalAPI_OnInitialized for the event version.
 * @return						Whether GlobalAPI plugin is initialized.
 */
native bool GlobalAPI_IsInit();

/**
 * Gets the API Key used by GlobalAPI plugin
 *
 * @param buffer				Buffer to store result in
 * @param maxlength				Max length of the buffer
 * @noreturn		
 */
native void GlobalAPI_GetAPIKey(char[] buffer, int maxlength);

/**
 * Gets whether GlobalAPI is using an API Key
 *
 * @note						This does not mean the API Key is valid!
 * @return						Whether API Key is used by GlobalAPI plugin
 */
native bool GlobalAPI_HasAPIKey();

/**
 * Gets whether GlobalAPI is using the staging endpoint
 *
 * @note						It is not safe to call this before GlobalAPI_OnInitialized!
 * @return						Whether staging endpoint is used by GlobalAPI plugin
 */
native bool GlobalAPI_IsStaging();

/**
 * Gets whether GlobalAPI is in debug mode
 *
 * @note						It is not safe to call this before GlobalAPI_OnInitialized!
 * @return						Whether GlobalAPI plugin is in debug mode
 */
native bool GlobalAPI_IsDebugging();

/**
 * Sends a request in GlobalAPI plugin format
 *
 * @param hData					Handle to GlobalAPIRequestData
 * @return						Whether the request was sent successfully
 */
native bool GlobalAPI_SendRequest(GlobalAPIRequestData hData);

/**
 * Sends a debug message to GlobalAPI plugin logs if debugging is enabled
 *
 * @param message				Formatting rules
 * @param ...					Variable number of format parameters
 * @note						This is not safe to use before convars have loaded
 * @return						Whether the message was logged
 */
native bool GlobalAPI_DebugMessage(const char[] message, any ...);

/**
 * Starts a GET HTTP Request to /api/{version}/auth/status
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetAuthStatus(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA);

/**
 * Starts a GET HTTP Request to /api/{version}/bans
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param banTypes				Ban types to query
 * @param banTypesList			-Unsupported at the moment-
 * @param isExpired				Whether to query for isExpired or not
 * @param ipAddress				IP address to query
 * @param steamId64				SteamID64 to query
 * @param steamId				SteamID2 to query
 * @param notesContain			Notes to query
 * @param statsContain			Stats to query
 * @param serverId				Server ID to query
 * @param createdSince			Created since date to query
 * @param updatedSince			Updated since date to query
 * @param offset				Offset of the dataset to query
 * @param limit					Amount of items returned for the query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetBans(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, const char[] banTypes = DEFAULT_STRING,
								const char[] banTypesList = DEFAULT_STRING, bool isExpired = DEFAULT_BOOL, const char[] ipAddress = DEFAULT_STRING,
								const char[] steamId64 = DEFAULT_STRING, const char[] steamId = DEFAULT_STRING, const char[] notesContain = DEFAULT_STRING,
								const char[] statsContain = DEFAULT_STRING, int serverId = DEFAULT_INT, const char[] createdSince = DEFAULT_STRING,
								const char[] updatedSince = DEFAULT_STRING, int offset = DEFAULT_INT, int limit = DEFAULT_INT);

/**
 * Starts a POST HTTP Request to /api/{version}/bans
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param steamId				SteamID2 of the user
 * @param banType				Type of the ban
 * @param stats					Stats of the ban
 * @param notes					Notes of the ban
 * @param ipAddress				IP address of the user
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_CreateBan(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA,
									const char[] steamId, const char[] banType, const char[] stats,
									const char[] notes, const char[] ipAddress);

/**
 * Starts a GET HTTP Request to /api/{version}/jumpstats
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param id					Id to query
 * @param serverId				Server id to query
 * @param steamId64				SteamID64 to query
 * @param steamId				SteamID2 to query
 * @param jumpType				Jump type to query
 * @param steamId64List			-Unsupported at the moment-
 * @param jumpTypeList			-Unsupported at the moment-
 * @param greaterThanDistance	Greater than distance to query
 * @param lessThanDistance		Less than distance to query
 * @param isMsl					Whether to query for isMsl or not
 * @param isCrouchBind			Whether to query for isCrouchBind or not
 * @param isForwardBind			Whether to query for isForwardBind or not
 * @param isCrouchBoost			Whether to query for isCrouchBoost or not
 * @param updatedById			Updated by id to query
 * @param createdSince			Created since date to query
 * @param updatedSince			Updated since date to query
 * @param offset				Offset of the dataset to query
 * @param limit					Amount of items returned for the query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetJumpstats(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, int id = DEFAULT_INT,
									int serverId = DEFAULT_INT, const char[] steamId64 = DEFAULT_STRING, const char[] steamId = DEFAULT_STRING,
									const char[] jumpType = DEFAULT_STRING, const char[] steamId64List = DEFAULT_STRING,
									const char[] jumpTypeList = DEFAULT_STRING, float greaterThanDistance = DEFAULT_FLOAT,
									float lessThanDistance = DEFAULT_FLOAT, bool isMsl = DEFAULT_BOOL, bool isCrouchBind = DEFAULT_BOOL,
									bool isForwardBind = DEFAULT_BOOL, bool isCrouchBoost = DEFAULT_BOOL, int updatedById = DEFAULT_INT,
									const char[] createdSince = DEFAULT_STRING, const char[] updatedSince = DEFAULT_STRING,
									int offset = DEFAULT_INT, int limit = DEFAULT_INT);

/**
 * Starts a POST HTTP Request to /api/{version}/jumpstats
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param steamId				SteamID2 of the user
 * @param jumpType				Type of the jump
 * @param distance				Distance of the jump
 * @param jumpJsonInfo			Data of the jump
 * @param tickRate				Tickrate of the server
 * @param mslCount				Msl count of the jump
 * @param isCrouchBind			Whether crouch bind was used
 * @param isForwardBind			Whether forward bind was used
 * @param isCrouchBoost			Whether crouch boost was used
 * @param strafeCount			Strafe count of the jump
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_CreateJumpstat(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, const char[] steamId,
										int jumpType, float distance, const char[] jumpJsonInfo, int tickRate, int mslCount,
										bool isCrouchBind, bool isForwardBind, bool isCrouchBoost, int strafeCount);

/**
 * Starts a GET HTTP Request to /api/{version}/jumpstats/{jump_type}/top
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param jumpType				Jump type to query
 * @param id					Id to query
 * @param serverId				Server Id to query
 * @param steamId64				SteamID64 to query
 * @param steamId				SteamID2 to query
 * @param steamId64List			-Unsupported at the moment-
 * @param jumpTypeList			-Unsupported at the moment-
 * @param greaterThanDistance	Greater than distance to query
 * @param lessThanDistance		Less than distance to query
 * @param isMsl					Whether to query for isMsl or not
 * @param isCrouchBind			Whether to query for isCrouchBind or not
 * @param isForwardBind			Whether to query for isForwardBind or not
 * @param isCrouchBoost			Whether to query for isCrouchBoost or not
 * @param updatedById			Updated by id to query
 * @param createdSince			Created since date to query
 * @param updatedSince			Updated since date to query
 * @param offset				Offset of the dataset to query
 * @param limit					Amount of items returned for the query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetJumpstatTop(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, const char[] jumpType,
										int id = DEFAULT_INT, int serverId = DEFAULT_INT, const char[] steamId64 = DEFAULT_STRING,
										const char[] steamId = DEFAULT_STRING, const char[] steamId64List = DEFAULT_STRING,
										const char[] jumpTypeList = DEFAULT_STRING, float greaterThanDistance = DEFAULT_FLOAT,
										float lessThanDistance = DEFAULT_FLOAT, bool isMsl = DEFAULT_BOOL, bool isCrouchBind = DEFAULT_BOOL,
										bool isForwardBind = DEFAULT_BOOL, bool isCrouchBoost = DEFAULT_BOOL, int updatedById = DEFAULT_INT,
										const char[] createdSince = DEFAULT_STRING, const char[] updatedSince = DEFAULT_STRING,
										int offset = DEFAULT_INT, int limit = DEFAULT_INT);

/**
 * Starts a GET HTTP Request to /api/{version}/jumpstats/{jump_type}/top30
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param jumpType				Jump type to query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetJumpstatTop30(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, const char[] jumpType);

/**
 * Starts a GET HTTP Request to /api/{version}/maps
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param name					Map name to query
 * @param largerThanFilesize	Larger than filesize to query
 * @param smallerThanFilesize	Smaller than filesize to query
 * @param isValidated			Whether to query for isValidated or not
 * @param difficulty			Map difficulty to query
 * @param createdSince			Created since date to query
 * @param updatedSince 			Updated since date to query 
 * @param offset				Offset of the dataset to query
 * @param limit					Amount of items returned for the query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetMaps(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, const char[] name = DEFAULT_STRING,
								int largerThanFilesize = DEFAULT_INT, int smallerThanFilesize = DEFAULT_INT, bool isValidated = DEFAULT_BOOL,
								int difficulty = DEFAULT_INT, const char[] createdSince = DEFAULT_STRING, const char[] updatedSince = DEFAULT_STRING,
								int offset = DEFAULT_INT, int limit = DEFAULT_INT);

/**
 * Starts a GET HTTP Request to /api/{version}/maps/{id}
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param id					Map id to query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetMapById(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, int id);

/**
 * Starts a GET HTTP Request to /api/{version}/maps/name/{map_name}
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param name					Map name to query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetMapByName(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, const char[] name);

/**
 * Starts a GET HTTP Request to /api/{version}/modes
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetModes(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA);

/**
 * Starts a GET HTTP Request to /api/{version}/modes/id/{id}
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param id					Mode id to query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetModeById(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, int id);

/**
 * Starts a GET HTTP Request to /api/{version}/modes/name/{mode_name}
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param name					Mode name to query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetModeByName(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, const char[] name);

/**
 * Starts a GET HTTP Request to /api/{version}/players
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param steamId				SteamID2 to query
 * @param isBanned				Whether to query for isBanned or not
 * @param totalRecords			Total records to query
 * @param ipAddress				IP address to query
 * @param steamId64List			-Unsupported at the moment-
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetPlayers(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, const char[] steamId = DEFAULT_STRING,
									bool isBanned = DEFAULT_BOOL, int totalRecords = DEFAULT_INT, const char[] ipAddress = DEFAULT_STRING,
									const char[] steamId64List = DEFAULT_STRING);

/**
 * Starts a GET HTTP Request to /api/{version}/players/steamid/{steamid}
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param steamId				SteamID2 to query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetPlayerBySteamId(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, const char[] steamId);

/**
 * Starts a GET HTTP Request to /api/{version}/players/steamid/{steamid}/ip/{ip}
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param steamId				SteamID2 to query
 * @param ipAddress				IP address to query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetPlayerBySteamIdAndIp(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA,
												const char[] steamId, const char[] ipAddress);

/**
 * Starts a POST HTTP Request to /api/{version}/records
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param steamId				SteamID2 of the user
 * @param mapId					Map id of the record
 * @param mode					Mode of the record
 * @param stage					Stage of the record
 * @param tickRate				Tickrate of the server
 * @param teleports				Teleport count of the record
 * @param time					Elapsed time of the record
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_CreateRecord(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, const char[] steamId,
									int mapId, const char[] mode, int stage, int tickRate, int teleports, float time);

/**
 * Starts a GET HTTP Request to /api/{version}/records/place/{id}
 *
 * @note						This is deprecated!
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param id					Id to query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetRecordPlaceById(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, int id);

/**
 * Starts a GET HTTP Request to /api/{version}/records/top
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param steamId				SteamID2 to query
 * @param steamId64				SteamID64 to query
 * @param mapId					Map id to query
 * @param mapName				Map name to query
 * @param tickRate				Tickrate to query
 * @param stage					Stage to query
 * @param modes					Mode(s) to query
 * @param hasTeleports			Whether to query for hasTeleports or not
 * @param playerName			Player name to query
 * @param offset				Offset of the dataset to query
 * @param limit					Amount of items returned for the query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetRecordsTop(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA,
										const char[] steamId = DEFAULT_STRING, const char[] steamId64 = DEFAULT_STRING, int mapId = DEFAULT_INT,
										const char[] mapName = DEFAULT_STRING, int tickRate = DEFAULT_INT, int stage = DEFAULT_INT,
										const char[] modes = DEFAULT_STRING, bool hasTeleports = DEFAULT_BOOL,
										const char[] playerName = DEFAULT_STRING, int offset = DEFAULT_INT, int limit = DEFAULT_INT);

/**
 * Starts a GET HTTP Request to /api/{version}/records/top/recent
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param steamId				SteamID2 to query
 * @param steamId64				SteamID64 to query
 * @param mapId					Map id to query
 * @param mapName				Map name to query
 * @param tickRate				Tickrate to query
 * @param stage					Stage to query
 * @param modes					Mode(s) to query
 * @param topAtLeast			Place top at least to query
 * @param topOverallAtLeast		Place top overall at least to query
 * @param hasTeleports			Whether to query for hasTeleports or not
 * @param createdSince			Created since date to query
 * @param playerName			Player name to query
 * @param offset				Offset of the dataset to query
 * @param limit					Amount of items returned for the query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetRecordsTopRecent(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA,
											const char[] steamId = DEFAULT_STRING, const char[] steamId64 = DEFAULT_STRING,
											int mapId = DEFAULT_INT, const char[] mapName = DEFAULT_STRING,
											int tickRate = DEFAULT_INT, int stage = DEFAULT_INT,
											const char[] modes = DEFAULT_STRING, int topAtLeast = DEFAULT_INT,
											int topOverallAtLeast = DEFAULT_INT, bool hasTeleports = DEFAULT_BOOL,
											const char[] createdSince = DEFAULT_STRING, const char[] playerName = DEFAULT_STRING,
											int offset = DEFAULT_INT, int limit = DEFAULT_INT);

/**
 * Starts a GET HTTP Request to /api/{version}/records/top/world_records
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param ids					Array of ids to query
 * @param idsLength 			Length of the ids array
 * @param mapIds				Array of map ids to query
 * @param mapIdsLength			Length of the map ids array
 * @param stages				Array of stages to query
 * @param stagesLength			Length of the stages array
 * @param modeIds				Array of mode ids to query
 * @param modeIdsLength			Length of the mode ids array
 * @param tickRates				Array of tickrates to query
 * @param tickRatesLength		Length of the tickrates array
 * @param hasTeleports			Whether to query for hasTeleports or not
 * @param mapTag				Map tags to query
 * @param offset				Offset of the dataset to query
 * @param limit					Amount of items returned for the query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetRecordsTopWorldRecords(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA,
												int[] ids = {}, int idsLength = DEFAULT_INT,
												int[] mapIds = {}, int mapIdsLength = DEFAULT_INT,
												int[] stages = {}, int stagesLength = DEFAULT_INT,
												int[] modeIds = {}, int modeIdsLength = DEFAULT_INT,
												int[] tickRates = {}, int tickRatesLength = DEFAULT_INT,
												bool hasTeleports = DEFAULT_BOOL, char[] mapTag = DEFAULT_STRING,
												int offset = DEFAULT_INT, int limit = DEFAULT_INT);

/**
 * Starts a GET HTTP Request to /api/{version}/servers
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param id					Id to query
 * @param port					Port to query
 * @param ip					IP address to query
 * @param name					Server name to query
 * @param ownerSteamId64		Owner's steamid64 to query
 * @param approvalStatus		Approval status to query
 * @param offset				Offset of the dataset to query
 * @param limit					Amount of items returned for the query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetServers(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA,
									int id = DEFAULT_INT, int port = DEFAULT_INT, const char[] ip = DEFAULT_STRING,
									const char[] name = DEFAULT_STRING, const char[] ownerSteamId64 = DEFAULT_STRING,
									int approvalStatus = DEFAULT_INT, int offset = DEFAULT_INT, int limit = DEFAULT_INT);

/**
 * Starts a GET HTTP Request to /api/{version}/servers/{id}
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param id					Id to query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetServerById(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, int id);

/**
 * Starts a GET HTTP Request to /api/{version}/servers/name/{server_name}
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param serverName			Server name to query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetServersByName(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, const char[] serverName);

/**
 * Starts a GET HTTP Request to /api/{version}/player_ranks
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param pointsGreaterThan		Points greater than to query
 * @param averageGreaterThan	Average greater than to query
 * @param ratingGreaterThan		Rating greater than to query
 * @param finishesGreaterThan	Finishes greater than to query
 * @param steamId64List			Comma-separated stirng of steamid64s to query
 * @param recordFilterIds		Array of record filter ids to query
 * @param recordFilterIdsLength	Length of the record filter ids array
 * @param mapIds				Array of map ids to query
 * @param mapIdsLength			Length of the map ids array
 * @param stages				Array of stages to query
 * @param stagesLength			Length of the stages array
 * @param modeIds				Array of mode ids to query
 * @param modeIdsLength			Length of the mode ids array
 * @param tickRates				Array of tickrates to query
 * @param tickRatesLength		Length of the tickrates array
 * @param hasTeleports			Whether to query for hasTeleports or not
 * @param offset				Offset of the dataset to query
 * @param limit					Amount of items returned for the query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetPlayerRanks(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA,
										int pointsGreaterThan = DEFAULT_INT, float averageGreaterThan = DEFAULT_FLOAT,
										float ratingGreaterThan = DEFAULT_FLOAT, int finishesGreaterThan = DEFAULT_INT,
										const char[] steamId64List = DEFAULT_STRING,
										int[] recordFilterIds = {}, int recordFilterIdsLength = DEFAULT_INT,
										int[] mapIds = {}, int mapIdsLength = DEFAULT_INT,
										int[] stages = {}, int stagesLength = DEFAULT_INT,
										int[] modeIds = {}, int modeIdsLength = DEFAULT_INT,
										int[] tickRates = {}, int tickRatesLength = DEFAULT_INT,
										bool hasTeleports = DEFAULT_BOOL, int offset = DEFAULT_INT, int limit = DEFAULT_INT);

/**
 * Starts a GET HTTP Request to /api/{version}/record_filters
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param ids					Array of ids to query
 * @param idsLength 			Length of the ids array
 * @param mapIds				Array of map ids to query
 * @param mapIdsLength			Length of the map ids array
 * @param stages				Array of stages to query
 * @param stagesLength			Length of the stages array
 * @param modeIds				Array of mode ids to query
 * @param modeIdsLength			Length of the mode ids array
 * @param tickRates				Array of tickrates to query
 * @param tickRatesLength		Length of the tickrates array
 * @param hasTeleports			Whether to query for hasTeleports or not
 * @param offset				Offset of the dataset to query
 * @param limit					Amount of items returned for the query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetRecordFilters(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA,
										int[] ids = {}, int idsLength = DEFAULT_INT,
										int[] mapIds = {}, int mapIdsLength = DEFAULT_INT,
										int[] stages = {}, int stagesLength = DEFAULT_INT,
										int[] modeIds = {}, int modeIdsLength = DEFAULT_INT,
										int[] tickRates = {}, int tickRatesLength = DEFAULT_INT,
										bool hasTeleports = DEFAULT_BOOL, bool isOverall = DEFAULT_BOOL,
										int offset = DEFAULT_INT, int limit = DEFAULT_INT);

/**
 * Starts a GET HTTP Request to /api/{version}/record_filters/distributions
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param ids					Array of ids to query
 * @param idsLength 			Length of the ids array
 * @param mapIds				Array of map ids to query
 * @param mapIdsLength			Length of the map ids array
 * @param stages				Array of stages to query
 * @param stagesLength			Length of the stages array
 * @param modeIds				Array of mode ids to query
 * @param modeIdsLength			Length of the mode ids array
 * @param tickRates				Array of tickrates to query
 * @param tickRatesLength		Length of the tickrates array
 * @param hasTeleports			Whether to query for hasTeleports or not
 * @param offset				Offset of the dataset to query
 * @param limit					Amount of items returned for the query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetRecordFilterDistributions(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA,
													int[] ids = {}, int idsLength = DEFAULT_INT,
													int[] mapIds = {}, int mapIdsLength = DEFAULT_INT,
													int[] stages = {}, int stagesLength = DEFAULT_INT,
													int[] modeIds = {}, int modeIdsLength = DEFAULT_INT,
													int[] tickRates = {}, int tickRatesLength = DEFAULT_INT,
													bool hasTeleports = DEFAULT_BOOL, bool isOverall = DEFAULT_BOOL,
													int offset = DEFAULT_INT, int limit = DEFAULT_INT);

/**
 * Starts a GET HTTP Request to /api/{version}/records/replay/list
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param offset				Offset of the dataset to query
 * @param limit					Amount of items returned for the query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetReplayList(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA,
									int offset = DEFAULT_INT, int limit = DEFAULT_INT);

/**
 * Starts a GET HTTP Request to /api/{version}/records/{recordId}/replay
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param recordId				Record id to query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetReplayByRecordId(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, int recordId);
/**
 * Starts a GET HTTP Request to /api/{version}/records/replay/{replayId}
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param replayId				Replay id to query
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_GetReplayByReplayId(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA, int replayId);

/**
 * Starts a POST HTTP Request to /api/{version}/records/{recordId}/replay
 *
 * @param callback				Callback when request has finished
 * @param data					Optional data to pass
 * @param recordId				Id of the record
 * @param replayFile			Path to the replay file
 * @return						Whether request was successfully sent
 */
native bool GlobalAPI_CreateReplayForRecordId(OnAPICallFinished callback = INVALID_FUNCTION, any data = DEFAULT_DATA,
												int recordId, const char[] replayFile);

// ======================= PLUGIN INFO ======================= //

public SharedPlugin __pl_GlobalAPI =
{
	name = "GlobalAPI",
	file = "GlobalAPI.smx",
	#if defined REQUIRE_PLUGIN
	required = 1,
	#else
	required = 0,
	#endif
};

#if !defined REQUIRE_PLUGIN
public void __pl_GlobalAPI_SetNTVOptional()
{
	// Plugin
	MarkNativeAsOptional("GlobalAPI_IsInit");
	MarkNativeAsOptional("GlobalAPI_GetAPIKey");
	MarkNativeAsOptional("GlobalAPI_HasAPIKey");
	MarkNativeAsOptional("GlobalAPI_IsStaging");
	MarkNativeAsOptional("GlobalAPI_IsDebugging");
	MarkNativeAsOptional("GlobalAPI_SendRequest");
	MarkNativeAsOptional("GlobalAPI_DebugMessage");

	// Auth
	MarkNativeAsOptional("GlobalAPI_GetAuthStatus");
	
	// Bans
	MarkNativeAsOptional("GlobalAPI_GetBans");
	MarkNativeAsOptional("GlobalAPI_CreateBan");

	// Jumpstats
	MarkNativeAsOptional("GlobalAPI_GetJumpstats");
	MarkNativeAsOptional("GlobalAPI_GetJumpstatTop");
	MarkNativeAsOptional("GlobalAPI_GetJumpstatTop30");

	// Maps
	MarkNativeAsOptional("GlobalAPI_GetMaps");
	MarkNativeAsOptional("GlobalAPI_GetMapById");
	MarkNativeAsOptional("GlobalAPI_GetMapByName");

	// Modes
	MarkNativeAsOptional("GlobalAPI_GetModes");
	MarkNativeAsOptional("GlobalAPI_GetModeById");
	MarkNativeAsOptional("GlobalAPI_GetModeByName");

	// Players
	MarkNativeAsOptional("GlobalAPI_GetPlayers");
	MarkNativeAsOptional("GlobalAPI_GetPlayerBySteamId");
	MarkNativeAsOptional("GlobalAPI_GetPlayerBySteamIdAndIp");

	// Records
	MarkNativeAsOptional("GlobalAPI_CreateRecord");
	MarkNativeAsOptional("GlobalAPI_GetRecordPlaceById");
	MarkNativeAsOptional("GlobalAPI_GetRecordsTop");
	MarkNativeAsOptional("GlobalAPI_GetRecordsTopRecent");
	MarkNativeAsOptional("GlobalAPI_GetRecordsTopWorldRecords");

	// Servers
	MarkNativeAsOptional("GlobalAPI_GetServers");
	MarkNativeAsOptional("GlobalAPI_GetServerById");
	MarkNativeAsOptional("GlobalAPI_GetServersByName");
	
	// Ranks
	MarkNativeAsOptional("GlobalAPI_GetPlayerRanks");
	
	// Record Filters
	MarkNativeAsOptional("GlobalAPI_GetRecordFilters");
	MarkNativeAsOptional("GlobalAPI_GetRecordFilterDistributions");

	// Replays
	MarkNativeAsOptional("GlobalAPI_GetReplayList");
	MarkNativeAsOptional("GlobalAPI_GetReplayByRecordId");
	MarkNativeAsOptional("GlobalAPI_GetReplayByReplayId");
	MarkNativeAsOptional("GlobalAPI_CreateReplayForRecordId");
}
#endif