Skip to content

Commit e2668bf

Browse files
committed
Revert "Revert "Nintendo Switch support""
This reverts commit 4c94f86.
1 parent a8d8f09 commit e2668bf

File tree

4 files changed

+70
-12
lines changed

4 files changed

+70
-12
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
namespace LootLocker
66
{
7-
public class LootLockerEndPoints
7+
public class LootLockerEndPoints
88
{
99
// Authentication
1010
[Header("Authentication")]
1111
public static EndPointClass playerVerification = new EndPointClass("v1/player/verify", LootLockerHTTPMethod.POST);
1212
public static EndPointClass authenticationRequest = new EndPointClass("v2/session", LootLockerHTTPMethod.POST);
1313
public static EndPointClass guestSessionRequest = new EndPointClass("v2/session/guest", LootLockerHTTPMethod.POST);
14+
public static EndPointClass nintendoSwitchSessionRequest = new EndPointClass("session/nintendo-switch", LootLockerHTTPMethod.POST);
1415
public static EndPointClass whiteLabelLoginSessionRequest = new EndPointClass("v2/session/white-label", LootLockerHTTPMethod.POST);
1516
public static EndPointClass endingSession = new EndPointClass("v1/session", LootLockerHTTPMethod.DELETE);
1617
public static EndPointClass initialAuthenticationRequest = new EndPointClass("v1/session", LootLockerHTTPMethod.POST);
@@ -59,15 +60,15 @@ public class LootLockerEndPoints
5960
public static EndPointClass createCharacter = new EndPointClass("v1/player/character", LootLockerHTTPMethod.POST);
6061
public static EndPointClass listCharacterTypes = new EndPointClass("v1/player/character/types", LootLockerHTTPMethod.GET);
6162

62-
// Persistentplayer storage
63+
// Persistentplayer storage
6364
[Header("Persitent Player Storage")]
6465
public static EndPointClass getEntirePersistentStorage = new EndPointClass("v1/player/storage", LootLockerHTTPMethod.GET);
6566
public static EndPointClass getSingleKeyFromPersitenctStorage = new EndPointClass("v1/player/storage?key={0}", LootLockerHTTPMethod.GET);
6667
public static EndPointClass updateOrCreateKeyValue = new EndPointClass("v1/player/storage", LootLockerHTTPMethod.POST);
6768
public static EndPointClass deleteKeyValue = new EndPointClass("v1/player/storage?key={0}", LootLockerHTTPMethod.DELETE);
6869
public static EndPointClass getOtherPlayersPublicKeyValuePairs = new EndPointClass("v1/player/{0}/storage", LootLockerHTTPMethod.GET);
6970

70-
// Asset storage
71+
// Asset storage
7172
[Header("Assets")]
7273
public static EndPointClass gettingContexts = new EndPointClass("v1/contexts", LootLockerHTTPMethod.GET);
7374
public static EndPointClass gettingAssetListWithCount = new EndPointClass("v1/assets/list?count={0}", LootLockerHTTPMethod.GET);
@@ -79,7 +80,7 @@ public class LootLockerEndPoints
7980
public static EndPointClass addingFavouriteAssets = new EndPointClass("v1/asset/{0}/favourite", LootLockerHTTPMethod.POST);
8081
public static EndPointClass removingFavouriteAssets = new EndPointClass("v1/asset/{0}/favourite", LootLockerHTTPMethod.DELETE);
8182

82-
// Asset storage
83+
// Asset storage
8384
[Header("Asset Instances")]
8485
public static EndPointClass getAllKeyValuePairs = new EndPointClass("v1/asset/instance/storage", LootLockerHTTPMethod.GET);
8586
public static EndPointClass getAllKeyValuePairsToAnInstance = new EndPointClass("v1/asset/instance/{0}/storage", LootLockerHTTPMethod.GET);
@@ -90,7 +91,7 @@ public class LootLockerEndPoints
9091
public static EndPointClass deleteKeyValuePair = new EndPointClass("v1/asset/instance/{0}/storage/{1}", LootLockerHTTPMethod.DELETE);
9192
public static EndPointClass inspectALootBox = new EndPointClass("v1/asset/instance/{0}/inspect", LootLockerHTTPMethod.GET);
9293
public static EndPointClass openALootBox = new EndPointClass("v1/asset/instance/{0}/open", LootLockerHTTPMethod.PUT);
93-
94+
9495
// UGC
9596
[Header("UGC")]
9697
public static EndPointClass creatingAnAssetCandidate = new EndPointClass("v1/player/assets/candidates", LootLockerHTTPMethod.POST);

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public static void CheckWhiteLabelSession(string email, string token, Action<boo
280280

281281
/// <summary>
282282
/// Create new user using the white label login system.
283-
///
283+
///
284284
/// White label platform must be enabled in the web console for this to work.
285285
/// </summary>
286286
public static void StartWhiteLabelSession(string email, string password, Action<LootLockerSessionResponse> onComplete)
@@ -336,6 +336,22 @@ public static void StartWhiteLabelSession(Action<LootLockerSessionResponse> onCo
336336
LootLockerAPIManager.WhiteLabelSession(sessionRequest, onComplete);
337337
}
338338

339+
/// <summary>
340+
/// Create a new session for a Nintendo Switch user
341+
///
342+
/// The Nintendo Switch platform must be enabled in the web console for this to work.
343+
/// </summary>
344+
public static void StartNintendoSwitchSession(string nsa_id_token, Action<LootLockerSessionResponse> onComplete)
345+
{
346+
if (!CheckInitialized())
347+
{
348+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerSessionResponse>());
349+
return;
350+
}
351+
LootLockerNintendoSwitchSessionRequest sessionRequest = new LootLockerNintendoSwitchSessionRequest(nsa_id_token);
352+
LootLockerAPIManager.NintendoSwitchSession(sessionRequest, onComplete);
353+
}
354+
339355
public static void EndSession(string deviceId, Action<LootLockerSessionResponse> onComplete)
340356
{
341357
if (!CheckInitialized())
@@ -359,7 +375,7 @@ public static void EndSession(string deviceId, Action<LootLockerSessionResponse>
359375

360376
/// <summary>
361377
/// Create new user using the white label login system.
362-
///
378+
///
363379
/// White label platform must be enabled in the web console for this to work.
364380
/// </summary>
365381
public static void WhiteLabelLogin(string email, string password, Action<LootLockerWhiteLabelLoginResponse> onComplete)
@@ -427,7 +443,7 @@ public static void WhiteLabelSignUp(string email, string password, Action<LootLo
427443

428444
/// <summary>
429445
/// Request password reset email for the user.
430-
///
446+
///
431447
/// White label platform must be enabled in the web console for this to work.
432448
/// </summary>
433449
public static void WhiteLabelRequestPassword(string email, Action<LootLockerResponse> onComplete)
@@ -443,7 +459,7 @@ public static void WhiteLabelRequestPassword(string email, Action<LootLockerResp
443459

444460
/// <summary>
445461
/// Request verify account email for the user.
446-
///
462+
///
447463
/// White label platform must be enabled in the web console for this to work.
448464
/// Account verification must also be enabled.
449465
/// </summary>

Runtime/Game/Requests/LootLockerSessionRequest.cs

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ public LootLockerWhiteLabelSessionRequest(string email)
4848
}
4949
}
5050

51+
[System.Serializable]
52+
public class LootLockerNintendoSwitchSessionRequest : LootLockerGetRequest
53+
{
54+
public string game_key => LootLockerConfig.current.apiKey?.ToString();
55+
public string nsa_id_token { get; private set; }
56+
public string game_version => LootLockerConfig.current.game_version;
57+
public bool development_mode => LootLockerConfig.current.developmentMode;
58+
public LootLockerNintendoSwitchSessionRequest(string nsa_id_token)
59+
{
60+
this.nsa_id_token = nsa_id_token;
61+
}
62+
}
63+
5164
[System.Serializable]
5265
public class LootLockerSessionResponse : LootLockerResponse
5366
{
@@ -108,7 +121,7 @@ public static void Session(LootLockerGetRequest data, Action<LootLockerSessionRe
108121
}, false);
109122
}
110123

111-
public static void WhiteLabelSession(LootLockerGetRequest data, Action<LootLockerSessionResponse> onComplete)
124+
public static void WhiteLabelSession(LootLockerWhiteLabelSessionRequest data, Action<LootLockerSessionResponse> onComplete)
112125
{
113126
EndPointClass endPoint = LootLockerEndPoints.whiteLabelLoginSessionRequest;
114127

@@ -160,6 +173,34 @@ public static void GuestSession(LootLockerGetRequest data, Action<LootLockerGues
160173
}, false);
161174
}
162175

176+
public static void NintendoSwitchSession(LootLockerNintendoSwitchSessionRequest data, Action<LootLockerSessionResponse> onComplete)
177+
{
178+
EndPointClass endPoint = LootLockerEndPoints.nintendoSwitchSessionRequest;
179+
180+
string json = "";
181+
if (data == null)
182+
{
183+
return;
184+
}
185+
186+
json = JsonConvert.SerializeObject(data);
187+
LootLockerServerRequest.CallAPI(endPoint.endPoint, endPoint.httpMethod, json, (serverResponse) =>
188+
{
189+
LootLockerSessionResponse response = new LootLockerSessionResponse();
190+
if (string.IsNullOrEmpty(serverResponse.Error))
191+
{
192+
response = JsonConvert.DeserializeObject<LootLockerSessionResponse>(serverResponse.text);
193+
LootLockerConfig.current.UpdateToken(response.session_token, (data as LootLockerSessionRequest)?.player_identifier);
194+
}
195+
196+
response.text = serverResponse.text;
197+
response.success = serverResponse.success;
198+
response.Error = serverResponse.Error; response.statusCode = serverResponse.statusCode;
199+
onComplete?.Invoke(response);
200+
201+
}, false);
202+
}
203+
163204
public static void EndSession(LootLockerGetRequest data, Action<LootLockerSessionResponse> onComplete)
164205
{
165206
EndPointClass endPoint = LootLockerEndPoints.endingSession;
@@ -172,7 +213,7 @@ public static void EndSession(LootLockerGetRequest data, Action<LootLockerSessio
172213
LootLockerSessionResponse response = new LootLockerSessionResponse();
173214
if (string.IsNullOrEmpty(serverResponse.Error))
174215
response = JsonConvert.DeserializeObject<LootLockerSessionResponse>(serverResponse.text);
175-
216+
176217
//LootLockerSDKManager.DebugMessage(serverResponse.text, !string.IsNullOrEmpty(serverResponse.Error));
177218
response.text = serverResponse.text;
178219
response.success = serverResponse.success;

Runtime/Game/Requests/WhiteLabelRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public static void WhiteLabelSignUp(LootLockerWhiteLabelUserRequest input, Actio
153153
return;
154154
}
155155
else
156-
{
156+
{
157157
json = JsonConvert.SerializeObject(input);
158158
}
159159

0 commit comments

Comments
 (0)