2using Newtonsoft.Json.Linq;
4using System.Collections.Generic;
5using System.ComponentModel;
6using System.Runtime.CompilerServices;
9using UnityEngine.UIElements;
33 bool hasErrored =
false;
36 if (hasErrorSetup ==
false)
40 if (
Error.Equals(
"true", StringComparison.CurrentCultureIgnoreCase))
46 hasErrored = !
string.IsNullOrEmpty(
Error);
56 public class JoinSessionResponse : FailureResponse
63 IEnumerable<JProperty> dataPropertyEnumerator =
Data.Properties();
64 foreach (JProperty property
in dataPropertyEnumerator)
66 if (property.Name.Equals(
"SessionId", StringComparison.OrdinalIgnoreCase))
68 SessionId = JsonConvert.DeserializeObject<
int>(
property.Value.ToString());
85 return (
Error.Equals(
"true", StringComparison.CurrentCultureIgnoreCase));
91 IEnumerable<JProperty> dataPropertyEnumerator =
Data.Properties();
93 foreach (JProperty currentProperty
in dataPropertyEnumerator)
97 currentUser.UserId = currentProperty.Name;
98 currentUser.AvailableModules = JsonConvert.DeserializeObject<List<int>>(
99 currentProperty.Value.ToString()
122 [JsonProperty(PropertyName =
"userIds")]
123 public List<int>
UserIds =
new List<int>();
127 public class LoginData
159 var isSuperAdmin = !String.IsNullOrEmpty(
Role) &&
Role.Equals(
"superadmin", StringComparison.CurrentCultureIgnoreCase);
160 var isPlatformOrg =
Org !=
null && !String.IsNullOrEmpty(
Org.
Type) &&
Org.
Type.Equals(
"platform", StringComparison.CurrentCultureIgnoreCase);
161 return isPlatformOrg && isSuperAdmin;
177 public class UserAccessResponseContent : IPlatformErrorable
248 public SessionData(
float score,
float scaled,
float min,
float max,
int duration,
bool completed,
bool success)
260#if UNITY_6000_0_OR_NEWER
267 public string Name =
"";
289#if UNITY_6000_0_OR_NEWER
295 public List<OrgModuleDownload>
Downloads =
new List<OrgModuleDownload>();
301#if UNITY_6000_0_OR_NEWER
302 public event EventHandler<BindablePropertyChangedEventArgs> propertyChanged;
307 Downloads =
new List<OrgModuleDownload>();
312 Downloads =
new List<OrgModuleDownload>();
318 ID = token.Value<
int>(
"ID");
319 Name = token.Value<
string>(
"Name");
323 Details = token.Value<
string>(
"Details");
327 externalId = token.Value<
string>(
"externalId");
330 var PlayerToken = token.Value<JObject>(
"player");
332 if (PlayerToken !=
null)
337 var DownloadTokens = token.Value<JArray>(
"Downloads");
339 if (DownloadTokens !=
null)
341 foreach (JToken DownloadToken
in DownloadTokens)
349 var availableLanguages = GetValue<JArray>(token,
"availableLanguages");
351 if (availableLanguages !=
null)
353 var availableLanguagesList =
new List<string>();
355 foreach (JToken languageToken
in availableLanguages)
357 string displayName = GetValue<string>(languageToken,
"displayName");
358 if (!
string.IsNullOrEmpty(displayName))
360 availableLanguagesList.Add(displayName);
367 var industry = GetValue<string>(token,
"Industry");
368 if (!
string.IsNullOrEmpty(industry) && industry.Length > 0)
370 Industry =
char.ToUpper(industry[0]) + (industry.Length > 1 ? industry[1..] :
string.Empty);
373 var distributor = GetValue<JToken>(token,
"distributor");
374 if (distributor !=
null)
383 private T
GetValue<T>(JToken token,
string propertyName, T defaultValue =
default)
385 return token[propertyName] !=
null ? token.Value<T>(propertyName) : defaultValue;
388#if UNITY_6000_0_OR_NEWER
389 void Notify([CallerMemberName]
string property =
"")
391 propertyChanged?.Invoke(
this,
new BindablePropertyChangedEventArgs(property));
415 public void Parse(JToken token)
417 ID = token.Value<
int>(
"ID");
418 VersionID = token.Value<
int>(
"VersionID");
420 externalId = token.Value<
string>(
"externalId");
422 Version = token.Value<
string>(
"Version");
423 Platform = token.Value<
string>(
"Platform");
424 ApkName = token.Value<
string>(
"ApkName");
425 URL = token.Value<
string>(
"URL");
426 Status = token.Value<
string>(
"Status");
430 #region Platform Models
432 public class PlatformPlayer
439 public List<PlatformPlayerDownload>
versions =
new List<PlatformPlayerDownload>();
443 id = tokenObject.Value<
int>(
"id");
445 name = tokenObject.Value<
string>(
"name");
446 description = tokenObject.Value<
string>(
"description");
449 var versionTokens = tokenObject.Value<JArray>(
"versions");
450 if (versionTokens ==
null)
452 versionTokens =
new JArray();
455 foreach (JToken Version
in versionTokens)
457 versions.Add(
new PlatformPlayerDownload(Version));
475 id = token.Value<
int>(
"id");
477 version = token.Value<
string>(
"version");
478 status = token.Value<
string>(
"status");
479 URL = token.Value<
string>(
"URL");
480 ApkName = token.Value<
string>(
"ApkName");
490 public string Msg {
get;
set; }
495 return (
User ==
null ||
string.IsNullOrEmpty(
Token));
502 public int Id {
get;
set; }
507 public string Role {
get;
set; }
510 public string LastName {
get;
set; }
511 public string Username {
get;
set; }
512 public string Email {
get;
set; }
513 public string Phone {
get;
set; }
514 public string Status {
get;
set; }
518 public int OrgId {
get;
set; }
536 public class OrgProperties
544 public OrgProperties(
string primaryColor,
string secondaryColor,
string hubLogoURL,
string orgName)
553 public class QuickIDUser
562 public QuickIDUser(
string firstName,
string lastName,
string username,
string email)
572 public class QuickIDLoginData
585 public class UserMetricsResponse : IFailure, IPlatformErrorable
587 public List<UserMetric>
result;
620 [Description(
"superadmin")]
622 [Description(
"admin")]
624 [Description(
"manager")]
626 [Description(
"developer")]
628 [Description(
"user")]
630 [Description(
"student")]
632 [Description(
"trial")]
690 : $
"{username} ({email})";
709 $
"In module {lastModule.description} ({lastModule.abbreviation}) - {lastActiveAt.GetLocalFormattedDateTime()}";
715 $
"Session Completed - {lastActiveAt.GetLocalFormattedDateTime()}";
794 : $
"{user.username} ({user.email})";
809 $
"In module - ({currentApp.abbreviation}) {currentApp.description}";
813 batteryLevelDisplay = $
"{(batteryLevel.HasValue ? batteryLevel.Value.ToString() + "%
" : "N/A
")}";
818 locationDisplay = $
"{location.city}, {location.region}, {location.country}";
897 var endTime =
isComplete() ? completedAt.Value : DateTime.UtcNow;
898 var timeSpan = endTime.Subtract(
startedAt);
900 var totalHours = (int)timeSpan.TotalHours;
903 return $
"{totalHours:D2}:{timeSpan.Minutes:D2}:{timeSpan.Seconds:D2}";
905 return $
"{timeSpan.Minutes:D2}:{timeSpan.Seconds:D2}";
909 public class SessionHistoryResponse : IFailure, IPlatformErrorable
919 public class SessionFilters
927 public class FilterParams
932 public enum SortOrder
void RefreshDisplayFields()
string batteryLevelDisplay
[SerializeField]
string locationDisplay
[SerializeField]
string currentModuleDisplay
[SerializeField]
string currentUsernameEmailDisplay
[SerializeField]
string currentUserDisplay
[SerializeField]
AssistedLoginCode AssistedLogin
List< UserModulesData > ParsedData
LoginData(string username, string password)
bool IsPlatformSuperadmin()
OrgModuleDownload(JToken token)
bool IsAuthenticatedLaunch
string AvailableLanguages
List< OrgModuleDownload > Downloads
T GetValue< T >(JToken token, string propertyName, T defaultValue=default)
OrgProperties(string primaryColor, string secondaryColor, string hubLogoURL, string orgName)
OrgProperties OrgProperties
List< QuickIDUser > QuickIDUsers
QuickIDLoginData(string serialNumber, string username)
QuickIDUser(string firstName, string lastName, string username, string email)
SessionData(float score, float scaled, float min, float max, int duration, bool completed, bool success)
void RefreshDisplayFields()
string sessionModuleDisplay
[SerializeField]
string GetDurationFormatted()
string sessionActiveStatusDisplay
[SerializeField]
LoginResponseContent User
string createdAtDisplay
[SerializeField]
void RefreshDisplayFields()
string LastSessionDisplay
string lastActiveDisplay
[SerializeField]
string lastSessionDisplay
[SerializeField]
string usernameEmail
[SerializeField]
string displayName
[SerializeField]
List< UserMetric > result
List< int > AvailableModules