mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 01:48:25 +03:00
api models
This commit is contained in:
parent
567ebcd06e
commit
5d2f4e6ca4
11 changed files with 244 additions and 0 deletions
10
src/Core/Models/Request/AttachmentRequest.cs
Normal file
10
src/Core/Models/Request/AttachmentRequest.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
|
||||
namespace Bit.Core.Models.Request
|
||||
{
|
||||
public class AttachmentRequest
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
public string Key { get; set; }
|
||||
}
|
||||
}
|
14
src/Core/Models/Request/CipherCollectionsRequest.cs
Normal file
14
src/Core/Models/Request/CipherCollectionsRequest.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Bit.Core.Models.Request
|
||||
{
|
||||
public class CipherCollectionsRequest
|
||||
{
|
||||
public CipherCollectionsRequest(List<string> collectionIds)
|
||||
{
|
||||
CollectionIds = collectionIds ?? new List<string>();
|
||||
}
|
||||
|
||||
public List<string> CollectionIds { get; set; }
|
||||
}
|
||||
}
|
18
src/Core/Models/Request/CipherCreateRequest.cs
Normal file
18
src/Core/Models/Request/CipherCreateRequest.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using Bit.Core.Models.Domain;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bit.Core.Models.Request
|
||||
{
|
||||
public class CipherCreateRequest
|
||||
{
|
||||
public CipherCreateRequest(Cipher cipher)
|
||||
{
|
||||
Cipher = new CipherRequest(cipher);
|
||||
CollectionIds = cipher.CollectionIds?.ToList();
|
||||
}
|
||||
|
||||
public CipherRequest Cipher { get; set; }
|
||||
public List<string> CollectionIds { get; set; }
|
||||
}
|
||||
}
|
122
src/Core/Models/Request/CipherRequest.cs
Normal file
122
src/Core/Models/Request/CipherRequest.cs
Normal file
|
@ -0,0 +1,122 @@
|
|||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Api;
|
||||
using Bit.Core.Models.Domain;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bit.Core.Models.Request
|
||||
{
|
||||
public class CipherRequest
|
||||
{
|
||||
public CipherRequest(Cipher cipher)
|
||||
{
|
||||
Type = cipher.Type;
|
||||
OrganizationId = cipher.OrganizationId;
|
||||
FolderId = cipher.FolderId;
|
||||
Name = cipher.Name?.EncryptedString;
|
||||
Notes = cipher.Notes?.EncryptedString;
|
||||
Favorite = cipher.Favorite;
|
||||
|
||||
switch(Type)
|
||||
{
|
||||
case CipherType.Login:
|
||||
Login = new LoginApi
|
||||
{
|
||||
Uris = cipher.Login.Uris?.Select(
|
||||
u => new LoginUriApi { Match = u.Match, Uri = u.Uri?.EncryptedString }).ToList(),
|
||||
Username = cipher.Login.Username?.EncryptedString,
|
||||
Password = cipher.Login.Password?.EncryptedString,
|
||||
PasswordRevisionDate = cipher.Login.PasswordRevisionDate,
|
||||
Totp = cipher.Login.Totp?.EncryptedString
|
||||
};
|
||||
break;
|
||||
case CipherType.Card:
|
||||
Card = new CardApi
|
||||
{
|
||||
CardholderName = cipher.Card.CardholderName?.EncryptedString,
|
||||
Brand = cipher.Card.Brand?.EncryptedString,
|
||||
Number = cipher.Card.Number?.EncryptedString,
|
||||
ExpMonth = cipher.Card.ExpMonth?.EncryptedString,
|
||||
ExpYear = cipher.Card.ExpYear?.EncryptedString,
|
||||
Code = cipher.Card.Code?.EncryptedString
|
||||
};
|
||||
break;
|
||||
case CipherType.Identity:
|
||||
Identity = new IdentityApi
|
||||
{
|
||||
Title = cipher.Identity.Title?.EncryptedString,
|
||||
FirstName = cipher.Identity.FirstName?.EncryptedString,
|
||||
MiddleName = cipher.Identity.MiddleName?.EncryptedString,
|
||||
LastName = cipher.Identity.LastName?.EncryptedString,
|
||||
Address1 = cipher.Identity.Address1?.EncryptedString,
|
||||
Address2 = cipher.Identity.Address2?.EncryptedString,
|
||||
Address3 = cipher.Identity.Address3?.EncryptedString,
|
||||
City = cipher.Identity.City?.EncryptedString,
|
||||
State = cipher.Identity.State?.EncryptedString,
|
||||
PostalCode = cipher.Identity.PostalCode?.EncryptedString,
|
||||
Country = cipher.Identity.Country?.EncryptedString,
|
||||
Company = cipher.Identity.Company?.EncryptedString,
|
||||
Email = cipher.Identity.Email?.EncryptedString,
|
||||
Phone = cipher.Identity.Phone?.EncryptedString,
|
||||
SSN = cipher.Identity.SSN?.EncryptedString,
|
||||
Username = cipher.Identity.Username?.EncryptedString,
|
||||
PassportNumber = cipher.Identity.PassportNumber?.EncryptedString,
|
||||
LicenseNumber = cipher.Identity.LicenseNumber?.EncryptedString
|
||||
};
|
||||
break;
|
||||
case CipherType.SecureNote:
|
||||
SecureNote = new SecureNoteApi
|
||||
{
|
||||
Type = cipher.SecureNote.Type
|
||||
};
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Fields = cipher.Fields?.Select(f => new FieldApi
|
||||
{
|
||||
Type = f.Type,
|
||||
Name = f.Name?.EncryptedString,
|
||||
Value = f.Value?.EncryptedString
|
||||
}).ToList();
|
||||
|
||||
PasswordHistory = cipher.PasswordHistory?.Select(ph => new PasswordHistoryRequest
|
||||
{
|
||||
Password = ph.Password?.EncryptedString,
|
||||
LastUsedDate = ph.LastUsedDate
|
||||
}).ToList();
|
||||
|
||||
if(cipher.Attachments != null)
|
||||
{
|
||||
Attachments = new Dictionary<string, string>();
|
||||
Attachments2 = new Dictionary<string, AttachmentRequest>();
|
||||
foreach(var attachment in cipher.Attachments)
|
||||
{
|
||||
var fileName = attachment.FileName?.EncryptedString;
|
||||
Attachments.Add(attachment.Id, fileName);
|
||||
Attachments2.Add(attachment.Id, new AttachmentRequest
|
||||
{
|
||||
FileName = fileName,
|
||||
Key = attachment.Key?.EncryptedString
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CipherType Type { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public string FolderId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public bool Favorite { get; set; }
|
||||
public LoginApi Login { get; set; }
|
||||
public SecureNoteApi SecureNote { get; set; }
|
||||
public CardApi Card { get; set; }
|
||||
public IdentityApi Identity { get; set; }
|
||||
public List<FieldApi> Fields { get; set; }
|
||||
public List<PasswordHistoryRequest> PasswordHistory { get; set; }
|
||||
public Dictionary<string, string> Attachments { get; set; }
|
||||
public Dictionary<string, AttachmentRequest> Attachments2 { get; set; }
|
||||
}
|
||||
}
|
18
src/Core/Models/Request/CipherShareRequest.cs
Normal file
18
src/Core/Models/Request/CipherShareRequest.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using Bit.Core.Models.Domain;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bit.Core.Models.Request
|
||||
{
|
||||
public class CipherShareRequest
|
||||
{
|
||||
public CipherShareRequest(Cipher cipher)
|
||||
{
|
||||
Cipher = new CipherRequest(cipher);
|
||||
CollectionIds = cipher.CollectionIds?.ToList();
|
||||
}
|
||||
|
||||
public CipherRequest Cipher { get; set; }
|
||||
public List<string> CollectionIds { get; set; }
|
||||
}
|
||||
}
|
14
src/Core/Models/Request/FolderRequest.cs
Normal file
14
src/Core/Models/Request/FolderRequest.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using Bit.Core.Models.Domain;
|
||||
|
||||
namespace Bit.Core.Models.Request
|
||||
{
|
||||
public class FolderRequest
|
||||
{
|
||||
public FolderRequest(Folder folder)
|
||||
{
|
||||
Name = folder.Name?.EncryptedString;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
10
src/Core/Models/Request/PasswordHistoryRequest.cs
Normal file
10
src/Core/Models/Request/PasswordHistoryRequest.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
|
||||
namespace Bit.Core.Models.Request
|
||||
{
|
||||
public class PasswordHistoryRequest
|
||||
{
|
||||
public string Password { get; set; }
|
||||
public DateTime? LastUsedDate { get; set; }
|
||||
}
|
||||
}
|
|
@ -6,6 +6,10 @@
|
|||
public string OrganizationId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ExternalId { get; set; }
|
||||
}
|
||||
|
||||
public class CollectionDetailsResponse : CollectionResponse
|
||||
{
|
||||
public bool ReadOnly { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
10
src/Core/Models/Response/DomainsResponse.cs
Normal file
10
src/Core/Models/Response/DomainsResponse.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Bit.Core.Models.Response
|
||||
{
|
||||
public class DomainsResponse
|
||||
{
|
||||
public List<List<string>> EquivalentDomains { get; set; }
|
||||
public List<GlobalDomainResponse> GlobalEquivalentDomains { get; set; } = new List<GlobalDomainResponse>();
|
||||
}
|
||||
}
|
11
src/Core/Models/Response/GlobalDomainResponse.cs
Normal file
11
src/Core/Models/Response/GlobalDomainResponse.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Bit.Core.Models.Response
|
||||
{
|
||||
public class GlobalDomainResponse
|
||||
{
|
||||
public int Type { get; set; }
|
||||
public List<string> Domains { get; set; }
|
||||
public bool Excluded { get; set; }
|
||||
}
|
||||
}
|
13
src/Core/Models/Response/SyncResponse.cs
Normal file
13
src/Core/Models/Response/SyncResponse.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Bit.Core.Models.Response
|
||||
{
|
||||
public class SyncResponse
|
||||
{
|
||||
public ProfileResponse Profile { get; set; }
|
||||
public List<FolderResponse> Folders { get; set; } = new List<FolderResponse>();
|
||||
public List<CollectionResponse> Collections { get; set; } = new List<CollectionResponse>();
|
||||
public List<CipherResponse> Ciphers { get; set; } = new List<CipherResponse>();
|
||||
public DomainsResponse Domains { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue