model adjustments

This commit is contained in:
Kyle Spearrin 2017-07-12 15:16:36 -04:00
parent 665e66a9a6
commit 18a86d3f12
14 changed files with 153 additions and 25 deletions

View File

@ -103,7 +103,7 @@
<Compile Include="Models\Api\Request\LoginRequest.cs" />
<Compile Include="Models\Api\Request\PasswordHintRequest.cs" />
<Compile Include="Models\Api\Request\TokenRequest.cs" />
<Compile Include="Models\Api\Response\CipherHistoryResponse.cs" />
<Compile Include="Models\Api\Response\AttachmentResponse.cs" />
<Compile Include="Models\Api\Response\CipherResponse.cs" />
<Compile Include="Models\Api\Response\DomainsResponse.cs" />
<Compile Include="Models\Api\Response\ErrorResponse.cs" />
@ -116,8 +116,9 @@
<Compile Include="Models\Api\Response\TokenResponse.cs" />
<Compile Include="Models\Api\Response\ProfileResponse.cs" />
<Compile Include="Models\Api\LoginDataModel.cs" />
<Compile Include="Models\Cipher.cs" />
<Compile Include="Models\CipherString.cs" />
<Compile Include="Models\Data\AttachmentData.cs" />
<Compile Include="Models\Attachment.cs" />
<Compile Include="Models\SymmetricCryptoKey.cs" />
<Compile Include="Models\Data\SettingsData.cs" />
<Compile Include="Models\Data\FolderData.cs" />

View File

@ -7,5 +7,6 @@
public string Username { get; set; }
public string Password { get; set; }
public string Notes { get; set; }
public string Totp { get; set; }
}
}

View File

@ -0,0 +1,11 @@
namespace Bit.App.Models.Api
{
public class AttachmentResponse
{
public string Id { get; set; }
public string Url { get; set; }
public string FileName { get; set; }
public string Size { get; set; }
public string SizeName { get; set; }
}
}

View File

@ -1,10 +0,0 @@
using System.Collections.Generic;
namespace Bit.App.Models.Api
{
public class CipherHistoryResponse
{
public IEnumerable<CipherResponse> Revised { get; set; }
public IEnumerable<string> Deleted { get; set; }
}
}

View File

@ -1,6 +1,7 @@
using Bit.App.Enums;
using System;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
namespace Bit.App.Models.Api
{
@ -12,7 +13,10 @@ namespace Bit.App.Models.Api
public string OrganizationId { get; set; }
public CipherType Type { get; set; }
public bool Favorite { get; set; }
public bool Edit { get; set; }
public bool OrganizationUseTotp { get; set; }
public JObject Data { get; set; }
public IEnumerable<AttachmentResponse> Attachments { get; set; }
public DateTime RevisionDate { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
namespace Bit.App.Models.Api
{
@ -13,7 +14,11 @@ namespace Bit.App.Models.Api
public string Username { get; set; }
public string Password { get; set; }
public string Notes { get; set; }
public string Totp { get; set; }
public bool Favorite { get; set; }
public bool Edit { get; set; }
public bool OrganizationUseTotp { get; set; }
public IEnumerable<AttachmentResponse> Attachments { get; set; }
public DateTime RevisionDate { get; set; }
}
}

View File

@ -6,6 +6,12 @@ namespace Bit.App.Models.Api
{
public string Id { get; set; }
public string Name { get; set; }
public bool UseGroups { get; set; }
public bool UseDirectory { get; set; }
public bool UseTotp { get; set; }
public int Seats { get; set; }
public int MaxCollections { get; set; }
public short? MaxStorageGb { get; set; }
public string Key { get; set; }
public OrganizationUserStatusType Status { get; set; }
public OrganizationUserType Type { get; set; }

View File

@ -7,6 +7,8 @@ namespace Bit.App.Models.Api
public string Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public bool EmailVerified { get; set; }
public bool Premium { get; set; }
public string MasterPasswordHint { get; set; }
public string Culture { get; set; }
public bool TwoFactorEnabled { get; set; }

View File

@ -0,0 +1,40 @@
using Bit.App.Models.Api;
using Bit.App.Models.Data;
namespace Bit.App.Models
{
public class Attachment
{
public Attachment()
{ }
public Attachment(AttachmentData data)
{
Id = data.Id;
Url = data.Url;
FileName = data.FileName;
Size = data.Size;
SizeName = data.SizeName;
}
public Attachment(AttachmentResponse response)
{
Id = response.Id;
Url = response.Url;
FileName = response.FileName;
Size = response.Size;
SizeName = response.SizeName;
}
public string Id { get; set; }
public string Url { get; set; }
public string FileName { get; set; }
public string Size { get; set; }
public string SizeName { get; set; }
public AttachmentData ToAttachmentData(string loginId)
{
return new AttachmentData(this, loginId);
}
}
}

View File

@ -1,10 +0,0 @@
using System;
namespace Bit.App.Models
{
public abstract class Cipher
{
public string Id { get; set; }
public CipherString Name { get; set; }
}
}

View File

@ -0,0 +1,47 @@
using SQLite;
using Bit.App.Abstractions;
using Bit.App.Models.Api;
namespace Bit.App.Models.Data
{
[Table("Attachment")]
public class AttachmentData : IDataObject<string>
{
public AttachmentData()
{ }
public AttachmentData(Attachment attachment, string loginId)
{
Id = attachment.Id;
LoginId = loginId;
Url = attachment.Url;
FileName = attachment.FileName;
Size = attachment.Size;
SizeName = attachment.SizeName;
}
public AttachmentData(AttachmentResponse response, string loginId)
{
Id = response.Id;
LoginId = loginId;
Url = response.Url;
FileName = response.FileName;
Size = response.Size;
SizeName = response.SizeName;
}
[PrimaryKey]
public string Id { get; set; }
[Indexed]
public string LoginId { get; set; }
public string Url { get; set; }
public string FileName { get; set; }
public string Size { get; set; }
public string SizeName { get; set; }
public Attachment ToAttachment()
{
return new Attachment(this);
}
}
}

View File

@ -22,7 +22,10 @@ namespace Bit.App.Models.Data
Username = login.Username?.EncryptedString;
Password = login.Password?.EncryptedString;
Notes = login.Notes?.EncryptedString;
Totp = login?.Notes?.EncryptedString;
Favorite = login.Favorite;
Edit = login.Edit;
OrganizationUseTotp = login.OrganizationUseTotp;
}
public LoginData(LoginResponse login, string userId)
@ -36,8 +39,11 @@ namespace Bit.App.Models.Data
Username = login.Username;
Password = login.Password;
Notes = login.Notes;
Totp = login.Totp;
Favorite = login.Favorite;
RevisionDateTime = login.RevisionDate;
Edit = login.Edit;
OrganizationUseTotp = login.OrganizationUseTotp;
}
public LoginData(CipherResponse cipher, string userId)
@ -58,7 +64,10 @@ namespace Bit.App.Models.Data
Username = data.Username;
Password = data.Password;
Notes = data.Notes;
Totp = data.Totp;
Favorite = cipher.Favorite;
Edit = cipher.Edit;
OrganizationUseTotp = cipher.OrganizationUseTotp;
RevisionDateTime = cipher.RevisionDate;
}
@ -73,7 +82,10 @@ namespace Bit.App.Models.Data
public string Username { get; set; }
public string Password { get; set; }
public string Notes { get; set; }
public string Totp { get; set; }
public bool Favorite { get; set; }
public bool Edit { get; set; }
public bool OrganizationUseTotp { get; set; }
public DateTime RevisionDateTime { get; set; } = DateTime.UtcNow;
public Login ToLogin()

View File

@ -3,7 +3,7 @@ using Bit.App.Models.Api;
namespace Bit.App.Models
{
public class Folder : Cipher
public class Folder
{
public Folder()
{ }
@ -20,6 +20,9 @@ namespace Bit.App.Models
Name = response.Name != null ? new CipherString(response.Name) : null;
}
public string Id { get; set; }
public CipherString Name { get; set; }
public FolderRequest ToFolderRequest()
{
return new FolderRequest(this);

View File

@ -1,14 +1,16 @@
using Bit.App.Models.Api;
using Bit.App.Models.Data;
using System.Collections.Generic;
using System.Linq;
namespace Bit.App.Models
{
public class Login : Cipher
public class Login
{
public Login()
{ }
public Login(LoginData data)
public Login(LoginData data, IEnumerable<AttachmentData> attachments = null)
{
Id = data.Id;
UserId = data.UserId;
@ -19,7 +21,11 @@ namespace Bit.App.Models
Username = data.Username != null ? new CipherString(data.Username) : null;
Password = data.Password != null ? new CipherString(data.Password) : null;
Notes = data.Notes != null ? new CipherString(data.Notes) : null;
Totp = data.Totp != null ? new CipherString(data.Totp) : null;
Favorite = data.Favorite;
Edit = data.Edit;
OrganizationUseTotp = data.OrganizationUseTotp;
Attachments = attachments?.Select(a => new Attachment(a));
}
public Login(LoginResponse response)
@ -33,17 +39,27 @@ namespace Bit.App.Models
Username = response.Username != null ? new CipherString(response.Username) : null;
Password = response.Password != null ? new CipherString(response.Password) : null;
Notes = response.Notes != null ? new CipherString(response.Notes) : null;
Totp = response.Totp != null ? new CipherString(response.Totp) : null;
Favorite = response.Favorite;
Edit = response.Edit;
OrganizationUseTotp = response.OrganizationUseTotp;
Attachments = response.Attachments?.Select(a => new Attachment(a));
}
public string Id { get; set; }
public string UserId { get; set; }
public string OrganizationId { get; set; }
public string FolderId { get; set; }
public CipherString Name { get; set; }
public CipherString Uri { get; set; }
public CipherString Username { get; set; }
public CipherString Password { get; set; }
public CipherString Notes { get; set; }
public CipherString Totp { get; set; }
public bool Favorite { get; set; }
public bool Edit { get; set; }
public bool OrganizationUseTotp { get; set; }
public IEnumerable<Attachment> Attachments { get; set; }
public LoginRequest ToLoginRequest()
{