using System; using xCommons.Extensions; using xModels.Base; using xModels.Dtos; namespace xIdentityModels.Dtos { /// /// a List of Available Open Actions ... /// public struct XOpenActions { public const string HandShake = "HandShake"; public const string GetUserInfo = "GetUserInfo"; public const string GetUserInfos = "GetUserInfos"; } /// /// Open Actions Request Model ... /// public class XOpenActionRequestDto : XBaseDto { // public string Action { get; set; } public string Payload { get; set; } public string Checksum { get; set; } public XDeviceDto Device { get; set; } public string Timestamp { get; set; } /// /// Validate Model ... /// /// public bool Validate() { // var result = !Device.IsNull() && !Timestamp.IsNull() && !Action.IsNullOrEmpty() && (Action == XOpenActions.HandShake || Action == XOpenActions.GetUserInfo || Action == XOpenActions.GetUserInfos) && !Int64.Parse(Timestamp).FromTimestamp().IsExPired(); // return result; } /// /// Checksum Digest Model ... /// /// public string ToOpenActionToken() { // var result = string.Empty; if (!Validate()) { return result; } // var tmp = this; tmp.Checksum = string.Empty; // result = $"{tmp.ToJSON()}" .ToMd5String(); return result; } /// /// Validate a Token is Correspond to Model or not ... /// /// /// public bool ValidateToken(string token) { // var result = Validate() && !token.IsNullOrEmpty() && token == ToOpenActionToken(); // return result; } } /// /// aa Dto which used between Api's ... /// public class XOpenActionInnerDto : XBaseDto { public string Token { get; set; } public string Payload { get; set; } } /// /// User Info Providing in Open Actions ... /// public class XOpenActionUserInfoDto : XBaseDto { public string Username { get; set; } public string Firstname { get; set; } public string Lastname { get; set; } public string Avatar { get; set; } } }