Documentation for the Unity C# Library
Loading...
Searching...
No Matches
ApexTypes.cs
Go to the documentation of this file.
1using Newtonsoft.Json;
2using Newtonsoft.Json.Linq;
3using System;
4using System.Collections;
5using System.Collections.Generic;
6using System.Linq;
7
8namespace PixoVR.Apex
9{
10 public interface IPlatformErrorable
11 {
12 public abstract bool HasErrored();
13 }
14
15 public interface IFailure
16 {
17 // Empty so we can check all failure types against this
18 }
19
20 [Serializable]
22 {
23 public string Error;
24 public string HttpCode;
25 public string Message;
26
27 public bool HasErrored()
28 {
29 bool hasErrored = false;
30 bool hasErrorSetup = !(Error == null && Message == null && HttpCode == null);
32 if (hasErrorSetup == false)
33 {
34 if(Error != null && Error.Equals("true", StringComparison.CurrentCultureIgnoreCase))
35 {
36 hasErrored = true;
37 }
38 }
39
40 return hasErrored;
41 }
42 }
43
44 [Serializable]
45 public class JoinSessionResponse : FailureResponse
46 {
47 public JObject Data;
48 public int SessionId;
49
50 public void ParseData()
51 {
52 IEnumerable<JProperty> dataPropertyEnumerator = Data.Properties();
53 foreach(JProperty property in dataPropertyEnumerator)
54 {
55 if(property.Name.Equals("SessionId", StringComparison.OrdinalIgnoreCase))
56 {
57 SessionId = JsonConvert.DeserializeObject<int>(property.Value.ToString());
58 }
59 }
60 }
61 }
63 [Serializable]
65 {
66 public string Error;
67 public string HttpCode;
68 public string Message;
69 public JObject Data;
70 public List<UserModulesData> ParsedData;
71 public bool HasErrored()
72 {
73 return (Error.Equals("true", StringComparison.CurrentCultureIgnoreCase));
74 }
75
76 public void ParseData()
77 {
78 ParsedData = new List<UserModulesData>();
79 IEnumerable<JProperty> dataPropertyEnumerator = Data.Properties();
80 UserModulesData currentUser;
81 foreach(JProperty currentProperty in dataPropertyEnumerator)
82 {
83 currentUser = new UserModulesData();
85 currentUser.UserId = currentProperty.Name;
86 currentUser.AvailableModules = JsonConvert.DeserializeObject<List<int>>(currentProperty.Value.ToString());
88 ParsedData.Add(currentUser);
89 }
90 }
91 }
92
93 [Serializable]
94 public class UserModulesData
95 {
96 public string UserId;
97 public List<int> AvailableModules;
98
99 public UserModulesData()
100 {
101 AvailableModules = new List<int>();
102 }
103 }
104
105 [Serializable]
106 public class UserModulesRequestData
107 {
108 [JsonProperty(PropertyName = "userIds")]
109 public List<int> UserIds = new List<int>();
110 }
111
112 [Serializable]
113 public class LoginData
114 {
115 public string Login;
116 public string Password;
117
118 public LoginData(string username, string password)
119 {
120 Login = username;
121 Password = password;
122 }
124
125 [Serializable]
127 {
128 public int ID;
129 public int OrgId;
130 public string First;
131 public string Last;
132 public string Email;
133 public string Token;
134 public Organization Org;
135 public int MinimumPassingScore;
137 public bool HasErrored()
138 {
139 return (Email == null || Token == null);
140 }
141 }
142
143 [Serializable]
144 public class UserLoginResponseContent : IPlatformErrorable
145 {
146 public LoginResponseContent User;
147
148 public bool HasErrored()
150 return User == null;
153
154 [Serializable]
156 {
157 public int UserId = -1;
158 public int ModuleId = -1;
159 public bool Access;
160 public int? PassingScore;
161
162 public bool HasErrored()
163 {
164 return (UserId == -1 || ModuleId == -1);
165 }
166 }
167
168 [Serializable]
169 public class Organization
171 public int ID;
172 public string Name;
173 public string Status;
174 public string DownloadRegion;
177 [Serializable]
180 public int ID;
181 public string First;
182 public string Last;
183 public string Email;
184 public string Username;
185
186 public bool HasErrored()
187 {
188 return (Email == null);
189 }
190 }
191
192 [Serializable]
197 public bool HasErrored()
198 {
199 return (AssistedLogin == null);
200 }
201 }
202
203 public class AssistedLoginCode
204 {
205 public string AuthCode;
206 public string Expires;
207 }
208
209 [Serializable]
210 public class SessionData
212 public float Score;
213 public float ScaledScore;
214 public float MinimumScore;
215 public float MaximumScore;
216 public int Duration;
217 public bool Complete;
218 public bool Success;
219
220 public SessionData() { }
221 public SessionData(float score, float scaled, float min, float max, int duration, bool completed, bool success)
222 {
223 Score = score;
224 ScaledScore = scaled;
225 MinimumScore = min;
226 MaximumScore = max;
227 Duration = duration;
228 Complete = completed;
229 Success = success;
230 }
233 public class OrgModule
235 public int ID = -1;
236 public string Name = "";
237 public string Description = "";
238 public string ShortDescription = "";
239 public string LongDescription = "";
240 public string Industry = "";
241 public string Details = "";
242 public string IconURL = "";
243 public List<OrgModuleDownload> Downloads = new List<OrgModuleDownload>();
244 public int? PassingScore = null;
245 public string Categories = "";
246 public string externalId = "";
247 public PlatformPlayer player = null;
249 public OrgModule(JToken token)
251 ID = token.Value<int>("ID");
252 Name = token.Value<string>("Name");
253 Description = token.Value<string>("Description");
254 ShortDescription = token.Value<string>("ShortDescription");
255 LongDescription = token.Value<string>("LongDescription");
256 Industry = token.Value<string>("Industry");
257 Details = token.Value<string>("Details");
258 IconURL = token.Value<string>("IconURL");
259 PassingScore = token.Value<int?>("PassingScore");
260 Categories = token.Value<string>("Categories");
261 externalId = token.Value<string>("externalId");
262 var PlayerToken = token.Value<JObject>("player");
263
264 if(PlayerToken != null)
266 player = new PlatformPlayer(PlayerToken);
268
269 var DownloadTokens = token.Value<JArray>("Downloads");
270
271 if(DownloadTokens != null)
272 {
273 foreach(JToken DownloadToken in DownloadTokens)
274 {
275 Downloads.Add(new OrgModuleDownload(DownloadToken));
276 }
279 }
280
281 [Serializable]
282 public class OrgModuleDownload
283 {
284 public int ID;
285 public int VersionID;
286 public string FileLocation;
287 public string Version;
288 public string Platform;
289 public long DownloadSize;
290 public string ApkName;
291 public string URL;
292 public string Status;
293 public string externalId;
295 public OrgModuleDownload(JToken token)
297 ID = token.Value<int>("ID");
298 VersionID = token.Value<int>("VersionID");
299 DownloadSize = token.Value<long>("DownloadSize");
300 externalId = token.Value<string>("externalId");
301 FileLocation = token.Value<string>("FileLocation");
302 Version = token.Value<string>("Version");
303 Platform = token.Value<string>("Platform");
304 ApkName = token.Value<string>("ApkName");
305 URL = token.Value<string>("URL");
306 Status = token.Value<string>("Status");
307 }
308 }
309
310 [Serializable]
311 public class PlatformPlayer
312 {
313 public int id;
314 public string name;
315 public string description;
316 public int distributorId;
317 public List<PlatformPlayerDownload> versions = new List<PlatformPlayerDownload>();
319 public PlatformPlayer(JObject tokenObject)
321 id = tokenObject.Value<int>("id");
322 distributorId = tokenObject.Value<int>("distributorId");
323 name = tokenObject.Value<string>("name");
324 description = tokenObject.Value<string>("description");
326 var VersionTokens = tokenObject.Value<JArray>("versions");
328 foreach (JToken Version in VersionTokens)
329 {
330 versions.Add(new PlatformPlayerDownload(Version));
331 }
332 }
333 }
334
335 [Serializable]
336 public class PlatformPlayerDownload
337 {
338 public int id;
339 public string version;
340 public int modulePlayerId;
341 public string status;
342 public string URL;
343 public string ApkName;
344 public string platform;
345
346 public PlatformPlayerDownload(JToken token)
347 {
348 id = token.Value<int>("id");
349 modulePlayerId = token.Value<int>("modulePlayerId");
350 version = token.Value<string>("version");
351 status = token.Value<string>("status");
352 URL = token.Value<string>("URL");
353 ApkName = token.Value<string>("ApkName");
354 platform = token.Value<string>("platform");
355 }
356 }
357}
List< UserModulesData > ParsedData
Definition ApexTypes.cs:88
[Serializable]
Definition ApexTypes.cs:150
LoginData(string username, string password)
Definition ApexTypes.cs:154
OrgModuleDownload(JToken token)
Definition ApexTypes.cs:379
PlatformPlayer player
Definition ApexTypes.cs:325
List< OrgModuleDownload > Downloads
Definition ApexTypes.cs:321
OrgModule(JToken token)
Definition ApexTypes.cs:327
List< PlatformPlayerDownload > versions
Definition ApexTypes.cs:407
PlatformPlayer(JObject tokenObject)
Definition ApexTypes.cs:409
SessionData(float score, float scaled, float min, float max, int duration, bool completed, bool success)
Definition ApexTypes.cs:299