|
8 | 8 | using static LootLocker.LootLockerConfig;
|
9 | 9 | using System.Linq;
|
10 | 10 | using static LootLocker.Requests.CurrentPlatform;
|
| 11 | +using static System.Net.WebRequestMethods; |
| 12 | +using static System.Runtime.CompilerServices.RuntimeHelpers; |
| 13 | +using System.Diagnostics; |
| 14 | +using File = System.IO.File; |
11 | 15 | #if UNITY_EDITOR
|
12 | 16 | using UnityEditor;
|
13 | 17 | #endif
|
@@ -1061,6 +1065,90 @@ public static void WhiteLabelLoginAndStartSession(string email, string password,
|
1061 | 1065 |
|
1062 | 1066 | #endregion
|
1063 | 1067 |
|
| 1068 | + #region Account Linking |
| 1069 | + |
| 1070 | + /// <summary> |
| 1071 | + /// Start an account linking process on behalf of the currently signed in player |
| 1072 | + /// When you want to link an additional provider to a player, you start by initiating an account link.The player can then navigate to the online link flow using the code_page_url and code, or the qr_code and continue the linking process. |
| 1073 | + /// For the duration of the linking process you can check the status using the CheckStatusOfAccountLinkingProcess method. |
| 1074 | + /// Returned from this method is the ID of the linking process, make sure to save that so that you can check the status of the process later. |
| 1075 | + /// https://ref.lootlocker.com/game-api/#start-account-link |
| 1076 | + /// </summary> |
| 1077 | + /// <param name="onComplete">onComplete Action for handling the response of type LootLockerAccountLinkStartResponse</param> |
| 1078 | + public static void StartAccountLinkingProcess(Action<LootLockerAccountLinkStartResponse> onComplete) |
| 1079 | + { |
| 1080 | + if (!CheckInitialized()) |
| 1081 | + { |
| 1082 | + onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerAccountLinkStartResponse>()); |
| 1083 | + return; |
| 1084 | + } |
| 1085 | + |
| 1086 | + var endpoint = LootLockerEndPoints.StartAccountLinkingProcess; |
| 1087 | + |
| 1088 | + LootLockerServerRequest.CallAPI(endpoint.endPoint, endpoint.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); }); |
| 1089 | + } |
| 1090 | + |
| 1091 | + /// <summary> |
| 1092 | + /// Check the status of an ongoing account linking process |
| 1093 | + /// https://ref.lootlocker.com/game-api/#check-account-link-status |
| 1094 | + /// </summary> |
| 1095 | + /// <param name="LinkID">The ID of the account linking process which was returned when starting the linking process</param> |
| 1096 | + /// <param name="onComplete">onComplete Action for handling the response of type LootLockerAccountLinkProcessStatusResponse</param> |
| 1097 | + public static void CheckStatusOfAccountLinkingProcess(string LinkID, Action<LootLockerAccountLinkProcessStatusResponse> onComplete) |
| 1098 | + { |
| 1099 | + if (!CheckInitialized()) |
| 1100 | + { |
| 1101 | + onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerAccountLinkProcessStatusResponse>()); |
| 1102 | + return; |
| 1103 | + } |
| 1104 | + |
| 1105 | + var endpoint = LootLockerEndPoints.CheckStatusOfAccountLinkingProcess; |
| 1106 | + |
| 1107 | + LootLockerServerRequest.CallAPI(string.Format(endpoint.endPoint, LinkID), endpoint.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); }); |
| 1108 | + } |
| 1109 | + |
| 1110 | + /// <summary> |
| 1111 | + /// Cancel an ongoing account linking process |
| 1112 | + /// The response will be empty unless an error occurs |
| 1113 | + /// https://ref.lootlocker.com/game-api/#cancel-account-link |
| 1114 | + /// </summary> |
| 1115 | + /// <param name="LinkID">The ID of the account linking process which was returned when starting the linking process</param> |
| 1116 | + /// <param name="onComplete">onComplete Action for handling the response of type LootLockerCancelAccountLinkingProcessResponse</param> |
| 1117 | + public static void CancelAccountLinkingProcess(string LinkID, Action<LootLockerCancelAccountLinkingProcessResponse> onComplete) |
| 1118 | + { |
| 1119 | + if (!CheckInitialized()) |
| 1120 | + { |
| 1121 | + onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerCancelAccountLinkingProcessResponse>()); |
| 1122 | + return; |
| 1123 | + } |
| 1124 | + |
| 1125 | + var endpoint = LootLockerEndPoints.CancelAccountLinkingProcess; |
| 1126 | + |
| 1127 | + LootLockerServerRequest.CallAPI(string.Format(endpoint.endPoint, LinkID), endpoint.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); }); |
| 1128 | + } |
| 1129 | + |
| 1130 | + /// <summary> |
| 1131 | + /// Unlink a provider from the currently signed in player |
| 1132 | + /// The response will be empty unless an error occurs |
| 1133 | + /// https://ref.lootlocker.com/game-api/#unlink-provider |
| 1134 | + /// </summary> |
| 1135 | + /// <param name="Provider">What provider to unlink from the currently logged in player</param> |
| 1136 | + /// <param name="onComplete">onComplete Action for handling the response of type LootLockerUnlinkProviderFromAccountResponse</param> |
| 1137 | + public static void UnlinkProviderFromAccount(Platforms Provider, Action<LootLockerUnlinkProviderFromAccountResponse> onComplete) |
| 1138 | + { |
| 1139 | + if (!CheckInitialized()) |
| 1140 | + { |
| 1141 | + onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerUnlinkProviderFromAccountResponse>()); |
| 1142 | + return; |
| 1143 | + } |
| 1144 | + |
| 1145 | + var endpoint = LootLockerEndPoints.UnlinkProviderFromAccount; |
| 1146 | + |
| 1147 | + LootLockerServerRequest.CallAPI(string.Format(endpoint.endPoint, CurrentPlatform.GetPlatformRepresentation(Provider).PlatformString), endpoint.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); }); |
| 1148 | + } |
| 1149 | + |
| 1150 | + #endregion |
| 1151 | + |
1064 | 1152 | #region Player
|
1065 | 1153 | /// <summary>
|
1066 | 1154 | /// Get general information about the current current player, such as the XP, Level information and their account balance.
|
|
0 commit comments