|
| 1 | +using Newtonsoft.Json; |
| 2 | +using System; |
| 3 | +using System.Collections; |
| 4 | +using System.Collections.Generic; |
| 5 | +using UnityEngine; |
| 6 | +using LootLocker; |
| 7 | +using LootLocker.Requests; |
| 8 | +using LootLocker.LootLockerEnums; |
| 9 | + |
| 10 | + |
| 11 | +namespace LootLocker.Requests |
| 12 | +{ |
| 13 | + public class ReportType |
| 14 | + { |
| 15 | + public int ID { get; set; } |
| 16 | + public string Text { get; set; } |
| 17 | + } |
| 18 | + |
| 19 | + public class LootLockerReportsGetTypesResponse : LootLockerResponse |
| 20 | + { |
| 21 | + public ReportType[] Types { get; set; } |
| 22 | + } |
| 23 | + |
| 24 | + public class LootLockerReportsCreatePlayerResponse : LootLockerResponse |
| 25 | + { |
| 26 | + public int ID { get; set; } |
| 27 | + public int PlayerID { get; set; } |
| 28 | + public string Text { get; set; } |
| 29 | + public int[] ReportTypes { get; set; } |
| 30 | + public string ReportDate { get; set; } |
| 31 | + } |
| 32 | + |
| 33 | + public class LootLockerReportsCreateAssetResponse : LootLockerResponse |
| 34 | + { |
| 35 | + public int ID { get; set; } |
| 36 | + public int AssetID { get; set; } |
| 37 | + public string Text { get; set; } |
| 38 | + public int[] ReportTypes { get; set; } |
| 39 | + public string ReportDate { get; set; } |
| 40 | + } |
| 41 | + |
| 42 | + public class RemovedAsset |
| 43 | + { |
| 44 | + public int ID { get; set; } |
| 45 | + public int AssetID { get; set; } |
| 46 | + public string Name { get; set; } |
| 47 | + public int[] ReportTypes { get; set; } |
| 48 | + public string RemovedAt { get; set; } |
| 49 | + } |
| 50 | + public class LootLockerReportsGetRemovedAssetsResponse : LootLockerResponse |
| 51 | + { |
| 52 | + public RemovedAsset[] Assets { get; set; } |
| 53 | + } |
| 54 | + |
| 55 | + public class GetRemovedUGCForPlayerInput |
| 56 | + { |
| 57 | + /// <summary> |
| 58 | + /// Only get UGC removed after this date. |
| 59 | + /// |
| 60 | + /// Should follow RFC3339 format |
| 61 | + /// </summary> |
| 62 | + public string Since { get; set; } |
| 63 | + |
| 64 | + /// <summary> |
| 65 | + /// Used for pagination. |
| 66 | + /// |
| 67 | + /// Set this to the ID of the last retrieved report to get the next ones after. |
| 68 | + /// </summary> |
| 69 | + public string After { get; set; } |
| 70 | + |
| 71 | + /// <summary> |
| 72 | + /// Number of report you want to retrieve |
| 73 | + /// </summary> |
| 74 | + public int Count { get; set; } |
| 75 | + } |
| 76 | + |
| 77 | + public class ReportsCreatePlayerRequest |
| 78 | + { |
| 79 | + public int[] report_types { get; set; } |
| 80 | + public string text { get; set; } |
| 81 | + public int player_id { get; set; } |
| 82 | + } |
| 83 | + |
| 84 | + public class ReportsCreateAssetRequest |
| 85 | + { |
| 86 | + public int[] report_types { get; set; } |
| 87 | + public string text { get; set; } |
| 88 | + public int asset_id { get; set; } |
| 89 | + } |
| 90 | +} |
| 91 | + |
| 92 | +namespace LootLocker |
| 93 | +{ |
| 94 | + public partial class LootLockerAPIManager |
| 95 | + { |
| 96 | + public static void GetReportTypes(Action<LootLockerReportsGetTypesResponse> onComplete) |
| 97 | + { |
| 98 | + EndPointClass endPoint = LootLockerEndPoints.reportsGetTypes; |
| 99 | + LootLockerServerRequest.CallAPI(endPoint.endPoint, endPoint.httpMethod, null, ((serverResponse) => |
| 100 | + { |
| 101 | + LootLockerReportsGetTypesResponse response = new LootLockerReportsGetTypesResponse(); |
| 102 | + if (string.IsNullOrEmpty(serverResponse.Error)) |
| 103 | + { |
| 104 | + response = JsonConvert.DeserializeObject<LootLockerReportsGetTypesResponse>(serverResponse.text); |
| 105 | + } |
| 106 | + |
| 107 | + response.text = serverResponse.text; |
| 108 | + response.success = serverResponse.success; |
| 109 | + response.Error = serverResponse.Error; response.statusCode = serverResponse.statusCode; |
| 110 | + onComplete?.Invoke(response); |
| 111 | + }), true, LootLockerCallerRole.User); |
| 112 | + } |
| 113 | + |
| 114 | + public static void GetRemovedUGCForPlayer(GetRemovedUGCForPlayerInput input, Action<LootLockerReportsGetRemovedAssetsResponse> onComplete) |
| 115 | + { |
| 116 | + EndPointClass endPoint = LootLockerEndPoints.reportsGetRemovedUGCForPlayer; |
| 117 | + string tempEndpoint = endPoint.endPoint; |
| 118 | + |
| 119 | + if (!string.IsNullOrEmpty(input.After)) |
| 120 | + { |
| 121 | + tempEndpoint = tempEndpoint + "?after={0}"; |
| 122 | + tempEndpoint = string.Format(tempEndpoint, input.After); |
| 123 | + } |
| 124 | + |
| 125 | + if (input.Count > 0) |
| 126 | + { |
| 127 | + if (tempEndpoint.IndexOf("?") > -1) |
| 128 | + { |
| 129 | + tempEndpoint = tempEndpoint + "&"; |
| 130 | + } else |
| 131 | + { |
| 132 | + tempEndpoint = tempEndpoint + "?"; |
| 133 | + } |
| 134 | + |
| 135 | + tempEndpoint = tempEndpoint + "count={0}"; |
| 136 | + tempEndpoint = string.Format(tempEndpoint, input.Count); |
| 137 | + } |
| 138 | + |
| 139 | + if (!string.IsNullOrEmpty(input.Since)) |
| 140 | + { |
| 141 | + if (tempEndpoint.IndexOf("?") > -1) |
| 142 | + { |
| 143 | + tempEndpoint = tempEndpoint + "&"; |
| 144 | + } |
| 145 | + else |
| 146 | + { |
| 147 | + tempEndpoint = tempEndpoint + "?"; |
| 148 | + } |
| 149 | + |
| 150 | + tempEndpoint = tempEndpoint + "since={0}"; |
| 151 | + tempEndpoint = string.Format(tempEndpoint, input.Since); |
| 152 | + } |
| 153 | + |
| 154 | + LootLockerServerRequest.CallAPI(tempEndpoint, endPoint.httpMethod, null, ((serverResponse) => |
| 155 | + { |
| 156 | + LootLockerReportsGetRemovedAssetsResponse response = new LootLockerReportsGetRemovedAssetsResponse(); |
| 157 | + if (string.IsNullOrEmpty(serverResponse.Error)) |
| 158 | + { |
| 159 | + response = JsonConvert.DeserializeObject<LootLockerReportsGetRemovedAssetsResponse>(serverResponse.text); |
| 160 | + } |
| 161 | + |
| 162 | + response.text = serverResponse.text; |
| 163 | + response.success = serverResponse.success; |
| 164 | + response.Error = serverResponse.Error; response.statusCode = serverResponse.statusCode; |
| 165 | + onComplete?.Invoke(response); |
| 166 | + }), true, LootLockerCallerRole.User); |
| 167 | + } |
| 168 | + |
| 169 | + public static void CreatePlayerReport(ReportsCreatePlayerRequest data, Action<LootLockerReportsCreatePlayerResponse> onComplete) |
| 170 | + { |
| 171 | + EndPointClass requestEndPoint = LootLockerEndPoints.reportsCreatePlayer; |
| 172 | + string json = ""; |
| 173 | + if (data == null) return; |
| 174 | + else json = JsonConvert.SerializeObject(data); |
| 175 | + |
| 176 | + LootLockerServerRequest.CallAPI(requestEndPoint.endPoint, requestEndPoint.httpMethod, json, ((serverResponse) => |
| 177 | + { |
| 178 | + LootLockerReportsCreatePlayerResponse response = new LootLockerReportsCreatePlayerResponse(); |
| 179 | + if (string.IsNullOrEmpty(serverResponse.Error)) { |
| 180 | + response = JsonConvert.DeserializeObject<LootLockerReportsCreatePlayerResponse>(serverResponse.text); |
| 181 | + } |
| 182 | + |
| 183 | + response.text = serverResponse.text; |
| 184 | + response.success = serverResponse.success; |
| 185 | + response.Error = serverResponse.Error; response.statusCode = serverResponse.statusCode; |
| 186 | + |
| 187 | + onComplete?.Invoke(response); |
| 188 | + }), true, LootLockerCallerRole.User); |
| 189 | + } |
| 190 | + |
| 191 | + public static void CreateAssetReport(ReportsCreateAssetRequest data, Action<LootLockerReportsCreateAssetResponse> onComplete) |
| 192 | + { |
| 193 | + EndPointClass requestEndPoint = LootLockerEndPoints.reportsCreateAsset; |
| 194 | + string json = ""; |
| 195 | + if (data == null) return; |
| 196 | + else json = JsonConvert.SerializeObject(data); |
| 197 | + |
| 198 | + LootLockerServerRequest.CallAPI(requestEndPoint.endPoint, requestEndPoint.httpMethod, json, ((serverResponse) => |
| 199 | + { |
| 200 | + LootLockerReportsCreateAssetResponse response = new LootLockerReportsCreateAssetResponse(); |
| 201 | + if (string.IsNullOrEmpty(serverResponse.Error)) |
| 202 | + { |
| 203 | + response = JsonConvert.DeserializeObject<LootLockerReportsCreateAssetResponse>(serverResponse.text); |
| 204 | + } |
| 205 | + |
| 206 | + response.text = serverResponse.text; |
| 207 | + response.success = serverResponse.success; |
| 208 | + response.Error = serverResponse.Error; response.statusCode = serverResponse.statusCode; |
| 209 | + |
| 210 | + onComplete?.Invoke(response); |
| 211 | + }), true, LootLockerCallerRole.User); |
| 212 | + } |
| 213 | + } |
| 214 | +} |
0 commit comments