Skip to content

Commit 5cc9976

Browse files
Merge pull request #10 from LootLocker/feature/nintendo-switch
Nintendo Switch support
2 parents b99b4b9 + 5529b3c commit 5cc9976

File tree

4 files changed

+71
-13
lines changed

4 files changed

+71
-13
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);
@@ -57,15 +58,15 @@ public class LootLockerEndPoints
5758
public static EndPointClass createCharacter = new EndPointClass("v1/player/character", LootLockerHTTPMethod.POST);
5859
public static EndPointClass listCharacterTypes = new EndPointClass("v1/player/character/types", LootLockerHTTPMethod.GET);
5960

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

68-
// Asset storage
69+
// Asset storage
6970
[Header("Assets")]
7071
public static EndPointClass gettingContexts = new EndPointClass("v1/contexts", LootLockerHTTPMethod.GET);
7172
public static EndPointClass gettingAssetListWithCount = new EndPointClass("v1/assets/list?count={0}", LootLockerHTTPMethod.GET);
@@ -77,7 +78,7 @@ public class LootLockerEndPoints
7778
public static EndPointClass addingFavouriteAssets = new EndPointClass("v1/asset/{0}/favourite", LootLockerHTTPMethod.POST);
7879
public static EndPointClass removingFavouriteAssets = new EndPointClass("v1/asset/{0}/favourite", LootLockerHTTPMethod.DELETE);
7980

80-
// Asset storage
81+
// Asset storage
8182
[Header("Asset Instances")]
8283
public static EndPointClass getAllKeyValuePairs = new EndPointClass("v1/asset/instance/storage", LootLockerHTTPMethod.GET);
8384
public static EndPointClass getAllKeyValuePairsToAnInstance = new EndPointClass("v1/asset/instance/{0}/storage", LootLockerHTTPMethod.GET);
@@ -88,7 +89,7 @@ public class LootLockerEndPoints
8889
public static EndPointClass deleteKeyValuePair = new EndPointClass("v1/asset/instance/{0}/storage/{1}", LootLockerHTTPMethod.DELETE);
8990
public static EndPointClass inspectALootBox = new EndPointClass("v1/asset/instance/{0}/inspect", LootLockerHTTPMethod.GET);
9091
public static EndPointClass openALootBox = new EndPointClass("v1/asset/instance/{0}/open", LootLockerHTTPMethod.PUT);
91-
92+
9293
// UGC
9394
[Header("UGC")]
9495
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
@@ -192,7 +192,7 @@ public static void StartSteamSession(string steamId64, Action<LootLockerSessionR
192192

193193
/// <summary>
194194
/// Create new user using the white label login system.
195-
///
195+
///
196196
/// White label platform must be enabled in the web console for this to work.
197197
/// </summary>
198198
public static void StartWhiteLabelSession(string email, string password, Action<LootLockerSessionResponse> onComplete)
@@ -206,6 +206,22 @@ public static void StartWhiteLabelSession(string email, string password, Action<
206206
LootLockerAPIManager.WhiteLabelSession(sessionRequest, onComplete);
207207
}
208208

209+
/// <summary>
210+
/// Create a new session for a Nintendo Switch user
211+
///
212+
/// The Nintendo Switch platform must be enabled in the web console for this to work.
213+
/// </summary>
214+
public static void StartNintendoSwitchSession(string nsa_id_token, Action<LootLockerSessionResponse> onComplete)
215+
{
216+
if (!CheckInitialized())
217+
{
218+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerSessionResponse>());
219+
return;
220+
}
221+
LootLockerNintendoSwitchSessionRequest sessionRequest = new LootLockerNintendoSwitchSessionRequest(nsa_id_token);
222+
LootLockerAPIManager.NintendoSwitchSession(sessionRequest, onComplete);
223+
}
224+
209225
public static void EndSession(string deviceId, Action<LootLockerSessionResponse> onComplete)
210226
{
211227
if (!CheckInitialized())
@@ -227,7 +243,7 @@ public static void EndSession(string deviceId, Action<LootLockerSessionResponse>
227243

228244
/// <summary>
229245
/// Create new user using the white label login system.
230-
///
246+
///
231247
/// White label platform must be enabled in the web console for this to work.
232248
/// </summary>
233249
public static void WhiteLabelSignUp(string email, string password, Action<LootLockerWhiteLabelSignupResponse> onComplete)
@@ -249,7 +265,7 @@ public static void WhiteLabelSignUp(string email, string password, Action<LootLo
249265

250266
/// <summary>
251267
/// Request password reset email for the user.
252-
///
268+
///
253269
/// White label platform must be enabled in the web console for this to work.
254270
/// </summary>
255271
public static void WhiteLabelRequestPassword(string email, Action<LootLockerResponse> onComplete)
@@ -265,7 +281,7 @@ public static void WhiteLabelRequestPassword(string email, Action<LootLockerResp
265281

266282
/// <summary>
267283
/// Request verify account email for the user.
268-
///
284+
///
269285
/// White label platform must be enabled in the web console for this to work.
270286
/// Account verification must also be enabled.
271287
/// </summary>

Runtime/Game/Requests/LootLockerSessionRequest.cs

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,23 @@ public LootLockerWhiteLabelSessionRequest(string email, string password)
4242
}
4343
}
4444

45+
[System.Serializable]
46+
public class LootLockerNintendoSwitchSessionRequest : LootLockerGetRequest
47+
{
48+
public string game_key => LootLockerConfig.current.apiKey?.ToString();
49+
public string nsa_id_token { get; private set; }
50+
public string game_version => LootLockerConfig.current.game_version;
51+
public bool development_mode => LootLockerConfig.current.developmentMode;
52+
public LootLockerNintendoSwitchSessionRequest(string nsa_id_token)
53+
{
54+
this.nsa_id_token = nsa_id_token;
55+
}
56+
}
57+
4558
[System.Serializable]
4659
public class LootLockerSessionResponse : LootLockerResponse
4760
{
48-
61+
4962
public string session_token { get; set; }
5063
public int player_id { get; set; }
5164
public bool seen_before { get; set; }
@@ -103,7 +116,7 @@ public static void Session(LootLockerGetRequest data, Action<LootLockerSessionRe
103116
}, false);
104117
}
105118

106-
public static void WhiteLabelSession(LootLockerGetRequest data, Action<LootLockerSessionResponse> onComplete)
119+
public static void WhiteLabelSession(LootLockerWhiteLabelSessionRequest data, Action<LootLockerSessionResponse> onComplete)
107120
{
108121
EndPointClass endPoint = LootLockerEndPoints.whiteLabelLoginSessionRequest;
109122

@@ -155,6 +168,34 @@ public static void GuestSession(LootLockerGetRequest data, Action<LootLockerGues
155168
}, false);
156169
}
157170

171+
public static void NintendoSwitchSession(LootLockerNintendoSwitchSessionRequest data, Action<LootLockerSessionResponse> onComplete)
172+
{
173+
EndPointClass endPoint = LootLockerEndPoints.nintendoSwitchSessionRequest;
174+
175+
string json = "";
176+
if (data == null)
177+
{
178+
return;
179+
}
180+
181+
json = JsonConvert.SerializeObject(data);
182+
LootLockerServerRequest.CallAPI(endPoint.endPoint, endPoint.httpMethod, json, (serverResponse) =>
183+
{
184+
LootLockerSessionResponse response = new LootLockerSessionResponse();
185+
if (string.IsNullOrEmpty(serverResponse.Error))
186+
{
187+
response = JsonConvert.DeserializeObject<LootLockerSessionResponse>(serverResponse.text);
188+
LootLockerConfig.current.UpdateToken(response.session_token, (data as LootLockerSessionRequest)?.player_identifier);
189+
}
190+
191+
response.text = serverResponse.text;
192+
response.success = serverResponse.success;
193+
response.Error = serverResponse.Error; response.statusCode = serverResponse.statusCode;
194+
onComplete?.Invoke(response);
195+
196+
}, false);
197+
}
198+
158199
public static void EndSession(LootLockerGetRequest data, Action<LootLockerSessionResponse> onComplete)
159200
{
160201
EndPointClass endPoint = LootLockerEndPoints.endingSession;
@@ -167,7 +208,7 @@ public static void EndSession(LootLockerGetRequest data, Action<LootLockerSessio
167208
LootLockerSessionResponse response = new LootLockerSessionResponse();
168209
if (string.IsNullOrEmpty(serverResponse.Error))
169210
response = JsonConvert.DeserializeObject<LootLockerSessionResponse>(serverResponse.text);
170-
211+
171212
//LootLockerSDKManager.DebugMessage(serverResponse.text, !string.IsNullOrEmpty(serverResponse.Error));
172213
response.text = serverResponse.text;
173214
response.success = serverResponse.success;

Runtime/Game/Requests/WhiteLabelRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static void WhiteLabelSignUp(LootLockerWhiteLabelUserRequest input, Actio
4444
return;
4545
}
4646
else
47-
{
47+
{
4848
json = JsonConvert.SerializeObject(input);
4949
}
5050

0 commit comments

Comments
 (0)