Skip to content

Commit 827924f

Browse files
committed
new endpoints
1 parent a04d51a commit 827924f

File tree

8 files changed

+137
-19
lines changed

8 files changed

+137
-19
lines changed

Assets/LootLocker/Common/LootLockerEndPoints.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ public class LootLockerEndPoints : ScriptableObject
5858
public EndPointClass getSingleKeyFromPersitenctStorage;
5959
public EndPointClass updateOrCreateKeyValue;
6060
public EndPointClass deleteKeyValue;
61+
public EndPointClass getOtherPlayersPublicKeyValuePairs;
6162

6263
//Asset storage
6364
[Header("Assets")]
6465
public EndPointClass gettingContexts;
6566
public EndPointClass gettingAssetListWithCount;
6667
public EndPointClass gettingAssetListWithAfterAndCount;
68+
public EndPointClass getAssetsById;
6769
public EndPointClass gettingAllAssets;
6870
public EndPointClass gettingAssetInformationForOneorMoreAssets;
6971
public EndPointClass gettingAssetBoneInformation;

Assets/LootLocker/Game/LootLockerSDKManager.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,15 @@ public static void DeleteKeyValue(string keyToDelete, Action<GetPersistentStorag
332332
data.getRequests.Add(keyToDelete);
333333
LootLockerAPIManager.DeleteKeyValue(data, onComplete);
334334
}
335+
336+
public static void GetOtherPlayersPublicKeyValuePairs(string otherPlayerId, Action<GetPersistentStoragResponse> onComplete)
337+
{
338+
339+
if (!CheckInitialized()) return;
340+
LootLockerGetRequest data = new LootLockerGetRequest();
341+
data.getRequests.Add(otherPlayerId);
342+
LootLockerAPIManager.GetOtherPlayersPublicKeyValuePairs(data, onComplete);
343+
}
335344
#endregion
336345

337346
#region Assets
@@ -400,6 +409,16 @@ public static void RemoveFavouriteAsset(string assetId, Action<AssetResponse> on
400409
LootLockerAPIManager.RemoveFavouriteAsset(data, onComplete);
401410
}
402411

412+
public static void GetAssetsById(string[] assetIdsToRetrieve, Action<AssetResponse> onComplete)
413+
{
414+
if (!CheckInitialized()) return;
415+
LootLockerGetRequest data = new LootLockerGetRequest();
416+
417+
for (int i = 0; i < assetIdsToRetrieve.Length; i++)
418+
data.getRequests.Add(assetIdsToRetrieve[i]);
419+
420+
LootLockerAPIManager.RemoveFavouriteAsset(data, onComplete);
421+
}
403422

404423
#endregion
405424

Assets/LootLocker/Game/Requests/AssetRequest.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,38 @@ public static void GetAssetListWithAfterCount(AssetRequest data, Action<AssetRes
157157
}, true);
158158
}
159159

160+
public static void GetAssetsById(LootLockerGetRequest data, Action<AssetResponse> onComplete)
161+
{
162+
EndPointClass endPoint = LootLockerEndPoints.current.getAssetsById;
163+
164+
string builtAssets = data.getRequests.First();
165+
166+
if (data.getRequests.Count > 0)
167+
for (int i = 1; i < data.getRequests.Count; i++)
168+
builtAssets += "," + data.getRequests[i];
169+
170+
171+
string getVariable = string.Format(endPoint.endPoint, builtAssets);
172+
173+
ServerRequest.CallAPI(getVariable, endPoint.httpMethod, null, onComplete: (serverResponse) =>
174+
{
175+
AssetResponse response = new AssetResponse();
176+
if (string.IsNullOrEmpty(serverResponse.Error))
177+
{
178+
LootLockerSDKManager.DebugMessage(serverResponse.text);
179+
response = JsonConvert.DeserializeObject<AssetResponse>(serverResponse.text);
180+
response.text = serverResponse.text;
181+
onComplete?.Invoke(response);
182+
}
183+
else
184+
{
185+
response.message = serverResponse.message;
186+
response.Error = serverResponse.Error;
187+
onComplete?.Invoke(response);
188+
}
189+
}, true);
190+
}
191+
160192
public void ResetAssetCalls()
161193
{
162194
AssetRequest.lastId = 0;

Assets/LootLocker/Game/Requests/PersitentPlayerStorageRequest.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,5 +143,30 @@ public static void DeleteKeyValue(LootLockerGetRequest data, Action<GetPersisten
143143
}, true);
144144
}
145145

146+
public static void GetOtherPlayersPublicKeyValuePairs(LootLockerGetRequest data, Action<GetPersistentStoragResponse> onComplete)
147+
{
148+
EndPointClass endPoint = LootLockerEndPoints.current.getOtherPlayersPublicKeyValuePairs;
149+
150+
string getVariable = string.Format(endPoint.endPoint, data.getRequests[0]);
151+
152+
ServerRequest.CallAPI(getVariable, endPoint.httpMethod, null, onComplete: (serverResponse) =>
153+
{
154+
GetPersistentStoragResponse response = new GetPersistentStoragResponse();
155+
if (string.IsNullOrEmpty(serverResponse.Error))
156+
{
157+
response = JsonConvert.DeserializeObject<GetPersistentStoragResponse>(serverResponse.text);
158+
response.text = serverResponse.text;
159+
onComplete?.Invoke(response);
160+
}
161+
else
162+
{
163+
response.text = serverResponse.text;
164+
response.message = serverResponse.message;
165+
response.Error = serverResponse.Error;
166+
onComplete?.Invoke(response);
167+
}
168+
}, true);
169+
}
170+
146171
}
147172
}

Assets/LootLocker/Game/Resources/Config/LootLockerEndPoints.asset

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ MonoBehaviour:
126126
deleteKeyValue:
127127
endPoint: v1/player/storage?key={0}
128128
httpMethod: 2
129+
getOtherPlayersPublicKeyValuePairs:
130+
endPoint: v1/player/{0}/storage
131+
httpMethod: 0
129132
gettingContexts:
130133
endPoint: v1/contexts
131134
httpMethod: 0
@@ -135,6 +138,9 @@ MonoBehaviour:
135138
gettingAssetListWithAfterAndCount:
136139
endPoint: v1/assets/list?after={0}&count={1}
137140
httpMethod: 0
141+
getAssetsById:
142+
endPoint:
143+
httpMethod: 0
138144
gettingAllAssets:
139145
endPoint: v1/assets
140146
httpMethod: 0

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class AssetTest : MonoBehaviour
1212
public string assetId;
1313
public string labelText;
1414
Vector2 scrollPosition;
15+
public string[] assetsToRequest = new string[] { "23", "2342", "32152" };
1516

1617
private void OnGUI()
1718
{
@@ -215,4 +216,20 @@ public void RemoveFavouriteAsset()
215216
});
216217
}
217218

219+
[ContextMenu("RemoveFavouriteAsset")]
220+
public void GetAssetsByIds()
221+
{
222+
LootLockerSDKManager.GetAssetsById(assetsToRequest, (response) =>
223+
{
224+
if (response.success)
225+
{
226+
labelText = "Success\n" + response.text;
227+
}
228+
else
229+
{
230+
labelText = "Failed\n" + response.text;
231+
}
232+
});
233+
}
234+
218235
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class PersistentPlayerStorageTest : MonoBehaviour
2828
public string keyToDelete;
2929
public string labelText;
3030
Vector2 scrollPosition, scrollPosition2;
31+
public string otherPlayerId;
3132

3233
private void OnGUI()
3334
{
@@ -233,4 +234,20 @@ public void DeleteKeyValue()
233234

234235
});
235236
}
237+
238+
[ContextMenu("DeleteKeyValue")]
239+
public void GetOtherPlayersPublicKeyValuePairs()
240+
{
241+
LootLockerSDKManager.GetOtherPlayersPublicKeyValuePairs(otherPlayerId, (getPersistentStoragResponse) =>
242+
{
243+
if (getPersistentStoragResponse.success)
244+
{
245+
labelText = "Success\n" + getPersistentStoragResponse.text;
246+
}
247+
else
248+
{
249+
labelText = "Failed\n" + getPersistentStoragResponse.text;
250+
}
251+
});
252+
}
236253
}

Assets/LootLocker/SampleApp/Scenes/AppScene.unity

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4214,7 +4214,7 @@ MonoBehaviour:
42144214
m_TargetGraphic: {fileID: 341682279}
42154215
m_HandleRect: {fileID: 341682278}
42164216
m_Direction: 2
4217-
m_Value: 0
4217+
m_Value: 1
42184218
m_Size: 1
42194219
m_NumberOfSteps: 0
42204220
m_OnValueChanged:
@@ -5473,7 +5473,7 @@ PrefabInstance:
54735473
objectReference: {fileID: 0}
54745474
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
54755475
propertyPath: m_AnchoredPosition.y
5476-
value: 0
5476+
value: -55
54775477
objectReference: {fileID: 0}
54785478
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
54795479
propertyPath: m_SizeDelta.x
@@ -5489,15 +5489,15 @@ PrefabInstance:
54895489
objectReference: {fileID: 0}
54905490
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
54915491
propertyPath: m_AnchorMin.y
5492-
value: 0
5492+
value: 1
54935493
objectReference: {fileID: 0}
54945494
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
54955495
propertyPath: m_AnchorMax.x
54965496
value: 0
54975497
objectReference: {fileID: 0}
54985498
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
54995499
propertyPath: m_AnchorMax.y
5500-
value: 0
5500+
value: 1
55015501
objectReference: {fileID: 0}
55025502
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
55035503
propertyPath: m_Pivot.x
@@ -12894,8 +12894,8 @@ MonoBehaviour:
1289412894
m_TargetGraphic: {fileID: 1530191017}
1289512895
m_HandleRect: {fileID: 1530191016}
1289612896
m_Direction: 2
12897-
m_Value: 0
12898-
m_Size: 0.9888031
12897+
m_Value: 0.99991614
12898+
m_Size: 0.9331356
1289912899
m_NumberOfSteps: 0
1290012900
m_OnValueChanged:
1290112901
m_PersistentCalls:
@@ -15301,7 +15301,7 @@ MonoBehaviour:
1530115301
m_TargetGraphic: {fileID: 1376298557}
1530215302
m_HandleRect: {fileID: 1376298556}
1530315303
m_Direction: 2
15304-
m_Value: 0
15304+
m_Value: 1
1530515305
m_Size: 1
1530615306
m_NumberOfSteps: 0
1530715307
m_OnValueChanged:
@@ -15936,7 +15936,7 @@ RectTransform:
1593615936
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
1593715937
m_AnchorMin: {x: 0, y: 1}
1593815938
m_AnchorMax: {x: 1, y: 1}
15939-
m_AnchoredPosition: {x: 0, y: 0.0000103249}
15939+
m_AnchoredPosition: {x: 0, y: 0.0001363584}
1594015940
m_SizeDelta: {x: 0, y: 0}
1594115941
m_Pivot: {x: 0, y: 1}
1594215942
--- !u!114 &1221765395
@@ -17480,7 +17480,7 @@ RectTransform:
1748017480
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
1748117481
m_AnchorMin: {x: 0, y: 0}
1748217482
m_AnchorMax: {x: 0, y: 0}
17483-
m_AnchoredPosition: {x: 522.5, y: 0}
17483+
m_AnchoredPosition: {x: 1966.6528, y: 0}
1748417484
m_SizeDelta: {x: 900, y: 0}
1748517485
m_Pivot: {x: 0.5, y: 1}
1748617486
--- !u!114 &1304146772
@@ -18184,7 +18184,7 @@ MonoBehaviour:
1818418184
m_TargetGraphic: {fileID: 1119646460}
1818518185
m_HandleRect: {fileID: 1119646459}
1818618186
m_Direction: 2
18187-
m_Value: 0
18187+
m_Value: 1
1818818188
m_Size: 1
1818918189
m_NumberOfSteps: 0
1819018190
m_OnValueChanged:
@@ -18468,8 +18468,8 @@ MonoBehaviour:
1846818468
m_TargetGraphic: {fileID: 1546478131}
1846918469
m_HandleRect: {fileID: 1546478130}
1847018470
m_Direction: 2
18471-
m_Value: 0
18472-
m_Size: 0.9134688
18471+
m_Value: 1.0000019
18472+
m_Size: 0.90620214
1847318473
m_NumberOfSteps: 0
1847418474
m_OnValueChanged:
1847518475
m_PersistentCalls:
@@ -21192,7 +21192,7 @@ MonoBehaviour:
2119221192
m_TargetGraphic: {fileID: 1892422722}
2119321193
m_HandleRect: {fileID: 1892422721}
2119421194
m_Direction: 2
21195-
m_Value: 0
21195+
m_Value: 1
2119621196
m_Size: 1
2119721197
m_NumberOfSteps: 0
2119821198
m_OnValueChanged:
@@ -21449,7 +21449,7 @@ PrefabInstance:
2144921449
objectReference: {fileID: 0}
2145021450
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
2145121451
propertyPath: m_AnchoredPosition.y
21452-
value: 0
21452+
value: -100
2145321453
objectReference: {fileID: 0}
2145421454
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
2145521455
propertyPath: m_SizeDelta.x
@@ -21465,15 +21465,15 @@ PrefabInstance:
2146521465
objectReference: {fileID: 0}
2146621466
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
2146721467
propertyPath: m_AnchorMin.y
21468-
value: 0
21468+
value: 1
2146921469
objectReference: {fileID: 0}
2147021470
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
2147121471
propertyPath: m_AnchorMax.x
2147221472
value: 0
2147321473
objectReference: {fileID: 0}
2147421474
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
2147521475
propertyPath: m_AnchorMax.y
21476-
value: 0
21476+
value: 1
2147721477
objectReference: {fileID: 0}
2147821478
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
2147921479
propertyPath: m_Pivot.x
@@ -27997,7 +27997,7 @@ PrefabInstance:
2799727997
objectReference: {fileID: 0}
2799827998
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
2799927999
propertyPath: m_AnchoredPosition.y
28000-
value: 0
28000+
value: -55
2800128001
objectReference: {fileID: 0}
2800228002
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
2800328003
propertyPath: m_SizeDelta.x
@@ -28013,15 +28013,15 @@ PrefabInstance:
2801328013
objectReference: {fileID: 0}
2801428014
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
2801528015
propertyPath: m_AnchorMin.y
28016-
value: 0
28016+
value: 1
2801728017
objectReference: {fileID: 0}
2801828018
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
2801928019
propertyPath: m_AnchorMax.x
2802028020
value: 0
2802128021
objectReference: {fileID: 0}
2802228022
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
2802328023
propertyPath: m_AnchorMax.y
28024-
value: 0
28024+
value: 1
2802528025
objectReference: {fileID: 0}
2802628026
- target: {fileID: 5768038229556804, guid: c35b49eb46baaa54baa23b4902c17559, type: 3}
2802728027
propertyPath: m_Pivot.x

0 commit comments

Comments
 (0)