77using LootLockerAdmin ;
88using Unity . EditorCoroutines . Editor ;
99
10- /// <summary>
11- /// made for admin, relay on editing coroutines
12- /// </summary>
13- public class AdminServerAPI : BaseServerAPI
10+ namespace LootLockerAdmin
1411{
15- public new static AdminServerAPI I ;
16-
17- public static void Init ( )
12+ /// <summary>
13+ /// made for admin, relay on editing coroutines
14+ /// </summary>
15+ public class AdminServerAPI : BaseServerAPI
1816 {
19- I = new AdminServerAPI ( ) ;
17+ public new static AdminServerAPI I ;
2018
21- BaseServerAPI . Init ( I ) ;
19+ public static void Init ( )
20+ {
21+ I = new AdminServerAPI ( ) ;
2222
23- I . StartCoroutine = EditorCoroutineUtility . StartCoroutineOwnerless ;
24- }
23+ BaseServerAPI . Init ( I ) ;
2524
26- protected override void RefreshTokenAndCompleteCall ( ServerRequest cacheServerRequest , Action < LootLockerResponse > OnServerResponse )
27- {
28- var authRequest = new InitialAuthRequest ( ) ;
29- authRequest . email = activeConfig . email ;
30- authRequest . password = activeConfig . password ;
25+ I . StartCoroutine = EditorCoroutineUtility . StartCoroutineOwnerless ;
26+ }
3127
32- LootLockerAPIManagerAdmin . InitialAuthenticationRequest ( authRequest , ( response ) =>
28+ protected override void RefreshTokenAndCompleteCall ( ServerRequest cacheServerRequest , Action < LootLockerResponse > OnServerResponse )
3329 {
34- if ( response . success )
30+ var authRequest = new InitialAuthRequest ( ) ;
31+ authRequest . email = activeConfig . email ;
32+ authRequest . password = activeConfig . password ;
33+
34+ LootLockerAPIManagerAdmin . InitialAuthenticationRequest ( authRequest , ( response ) =>
3535 {
36- Dictionary < string , string > headers = new Dictionary < string , string > ( ) ;
37- headers . Add ( "x-auth-token" , activeConfig . token ) ;
38- cacheServerRequest . extraHeaders = headers ;
39- if ( cacheServerRequest . retryCount < 4 )
36+ if ( response . success )
4037 {
41- SendRequest ( cacheServerRequest , OnServerResponse ) ;
42- cacheServerRequest . retryCount ++ ;
38+ Dictionary < string , string > headers = new Dictionary < string , string > ( ) ;
39+ headers . Add ( "x-auth-token" , activeConfig . token ) ;
40+ cacheServerRequest . extraHeaders = headers ;
41+ if ( cacheServerRequest . retryCount < 4 )
42+ {
43+ SendRequest ( cacheServerRequest , OnServerResponse ) ;
44+ cacheServerRequest . retryCount ++ ;
45+ }
46+ else
47+ {
48+ LootLockerSDKAdminManager . DebugMessage ( "Admin token refresh failed" ) ;
49+ LootLockerResponse res = new LootLockerResponse ( ) ;
50+ res . statusCode = 401 ;
51+ res . Error = "Admin token Expired" ;
52+ res . hasError = true ;
53+ OnServerResponse ? . Invoke ( res ) ;
54+ }
4355 }
4456 else
4557 {
46- LootLockerSDKAdminManager . DebugMessage ( "Admin token refresh failed" ) ;
58+ LootLockerSDKAdminManager . DebugMessage ( "Admin token refresh failed" , true ) ;
4759 LootLockerResponse res = new LootLockerResponse ( ) ;
4860 res . statusCode = 401 ;
4961 res . Error = "Admin token Expired" ;
5062 res . hasError = true ;
5163 OnServerResponse ? . Invoke ( res ) ;
5264 }
53- }
54- else
55- {
56- LootLockerSDKAdminManager . DebugMessage ( "Admin token refresh failed" , true ) ;
57- LootLockerResponse res = new LootLockerResponse ( ) ;
58- res . statusCode = 401 ;
59- res . Error = "Admin token Expired" ;
60- res . hasError = true ;
61- OnServerResponse ? . Invoke ( res ) ;
62- }
63- } ) ;
65+ } ) ;
66+ }
6467 }
65- }
68+ }
0 commit comments