Skip to content

Commit 14bddd1

Browse files
committed
Fixed file naming issue and getsingleplayer storage, added a config value to let sdk refresh token or not
1 parent 3791b72 commit 14bddd1

File tree

7 files changed

+24
-17
lines changed

7 files changed

+24
-17
lines changed

Assets/LootLocker/Common/BaseServerAPI.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ IEnumerator coroutine()
154154
#if UNITY_EDITOR
155155
LootLockerSDKManager.DebugMessage("Response code: " + webRequest.responseCode);
156156
#endif
157-
if (webRequest.responseCode != 401)
157+
if (webRequest.responseCode != 401 || !activeConfig.allowTokenRefresh)
158158
{
159159
response.Error += " " + webRequest.downloadHandler.text;
160160
response.text = webRequest.downloadHandler.text;

Assets/LootLocker/Common/LootLockerGenericConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public enum DebugLevel { All, ErrorOnly, NormalOnly, Off}
4040

4141
public DebugLevel currentDebugLevel;
4242

43+
public bool allowTokenRefresh = true;
4344

4445
public void UpdateToken(string token, string deviceid)
4546
{

Assets/LootLocker/Common/ServerRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public ServerRequest(string endpoint, HTTPMethod httpMethod = HTTPMethod.GET, by
176176
this.form.AddField(kvp.Key, kvp.Value);
177177
}
178178

179-
this.form.AddBinaryData("file", upload, "file");
179+
this.form.AddBinaryData("file", upload, uploadName);
180180

181181
bool isNonPayloadMethod = (this.httpMethod == HTTPMethod.GET || this.httpMethod == HTTPMethod.HEAD || this.httpMethod == HTTPMethod.OPTIONS);
182182

Assets/LootLocker/Game/LootLockerSDKManager.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,12 @@ public static void GetEntirePersistentStorage(Action<GetPersistentStoragResponse
319319
LootLockerAPIManager.GetEntirePersistentStorage(onComplete);
320320
}
321321

322-
public static void GetSingleKeyPersistentStorage(Action<GetPersistentSingle> onComplete)
322+
public static void GetSingleKeyPersistentStorage(string key, Action<GetPersistentSingle> onComplete)
323323
{
324324
if (!CheckInitialized()) return;
325-
LootLockerAPIManager.GetSingleKeyPersistentStorage(onComplete);
325+
LootLockerGetRequest data = new LootLockerGetRequest();
326+
data.getRequests.Add(key);
327+
LootLockerAPIManager.GetSingleKeyPersistentStorage(data,onComplete);
326328
}
327329

328330
public static void UpdateOrCreateKeyValue(string key, string value, Action<GetPersistentStoragResponse> onComplete)

Assets/LootLocker/Game/Requests/PersitentPlayerStorageRequest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ public static void GetEntirePersistentStorage(Action<GetPersistentStoragResponse
6868
}, true);
6969
}
7070

71-
public static void GetSingleKeyPersistentStorage(Action<GetPersistentSingle> onComplete)
71+
public static void GetSingleKeyPersistentStorage(LootLockerGetRequest data, Action<GetPersistentSingle> onComplete)
7272
{
7373
EndPointClass endPoint = LootLockerEndPoints.current.getSingleKeyFromPersitenctStorage;
7474

75+
string getVariable = string.Format(endPoint.endPoint, data.getRequests[0]);
76+
7577
ServerRequest.CallAPI(endPoint.endPoint, endPoint.httpMethod, null, onComplete: (serverResponse) =>
7678
{
7779
GetPersistentSingle response = new GetPersistentSingle();

Assets/LootLocker/Game/Requests/PlayerRequest.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ namespace LootLockerRequests
1212
public class GetPlayerInfoResponse : LootLockerResponse
1313
{
1414
public bool success { get; set; }
15-
public int account_balance { get; set; }
16-
public int xp { get; set; }
17-
public int level { get; set; }
15+
public int? account_balance { get; set; }
16+
public int? xp { get; set; }
17+
public int? level { get; set; }
1818
public Level_Thresholds level_thresholds { get; set; }
1919
}
2020

@@ -50,7 +50,7 @@ public class DeactivatedObjects
5050
public class BalanceResponse : LootLockerResponse
5151
{
5252
public bool success { get; set; }
53-
public int balance { get; set; }
53+
public int? balance { get; set; }
5454
}
5555

5656
[System.Serializable]
@@ -66,20 +66,20 @@ public class XpSubmitResponse : LootLockerResponse
6666
public class XpResponse : LootLockerResponse
6767
{
6868
public bool success { get; set; }
69-
public int xp { get; set; }
70-
public int level { get; set; }
69+
public int? xp { get; set; }
70+
public int? level { get; set; }
7171
}
7272
[System.Serializable]
7373
public class Xp
7474
{
75-
public int previous { get; set; }
76-
public int current { get; set; }
75+
public int? previous { get; set; }
76+
public int? current { get; set; }
7777
}
7878
[System.Serializable]
7979
public class Level
8080
{
81-
public int level { get; set; }
82-
public int xp_threshold { get; set; }
81+
public int? level { get; set; }
82+
public int? xp_threshold { get; set; }
8383
}
8484

8585
[System.Serializable]
@@ -120,7 +120,7 @@ public class Rental
120120
[System.Serializable]
121121
public class XpSubmitRequest
122122
{
123-
public int points;
123+
public int? points;
124124

125125
public XpSubmitRequest(int points)
126126
{

Assets/LootLocker/Game/Samples/Scripts/PersistentPlayerStorageTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public class PersistentPlayerStorageTest : MonoBehaviour
1212
public List<Payload> dataToSave;
1313
[Header("Delete Data")]
1414
public string keyToDelete;
15+
[Header("single key Data")]
16+
public string keyToGet;
1517
public string labelText;
1618
Vector2 scrollPosition, scrollPosition2;
1719
public string otherPlayerId;
@@ -188,7 +190,7 @@ public void GetEntirePersistentStorage()
188190
[ContextMenu("GetSingleKeyPersistentStorage")]
189191
public void GetSingleKeyPersistentStorage()
190192
{
191-
LootLockerSDKManager.GetSingleKeyPersistentStorage((getPersistentStoragResponse) =>
193+
LootLockerSDKManager.GetSingleKeyPersistentStorage(keyToGet,(getPersistentStoragResponse) =>
192194
{
193195
if (getPersistentStoragResponse.success)
194196
{

0 commit comments

Comments
 (0)