This repository was archived by the owner on Oct 31, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change 1- using System . Reflection ;
1+ using System ;
2+ using System . Reflection ;
23
34using Fortnite_API . Endpoints ;
45
@@ -13,20 +14,29 @@ public class FortniteApi
1314 public ShopEndpoints Shop { get ; }
1415 public NewsEndpoints News { get ; }
1516
16- public FortniteApi ( string apiKey = null )
17+ public FortniteApi ( string apiKey )
1718 {
19+ if ( apiKey == null )
20+ {
21+ throw new ArgumentNullException ( nameof ( apiKey ) ) ;
22+ }
23+
24+ if ( apiKey . Length == 0 )
25+ {
26+ throw new ArgumentOutOfRangeException ( nameof ( apiKey ) ) ;
27+ }
28+
1829 var currentVersion = Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version ;
1930 var _client = new RestClient ( "https://fortnite-api.com/" )
2031 {
2132 UserAgent = $ "Fortnite-API.NET/{ currentVersion . ToString ( 3 ) } ",
22- Timeout = 10 * 1000
33+ Timeout = 10 * 1000 ,
34+ DefaultParameters =
35+ {
36+ new Parameter ( "x-api-key" , apiKey , ParameterType . HttpHeader )
37+ }
2338 } . UseSerializer < JsonNetSerializer > ( ) ;
2439
25- if ( ! string . IsNullOrWhiteSpace ( apiKey ) )
26- {
27- _client . DefaultParameters . Add ( new Parameter ( "x-api-key" , apiKey , ParameterType . HttpHeader ) ) ;
28- }
29-
3040 Cosmetics = new CosmeticsEndpoints ( _client ) ;
3141 Shop = new ShopEndpoints ( _client ) ;
3242 News = new NewsEndpoints ( _client ) ;
You can’t perform that action at this time.
0 commit comments