From d050e01d08276f132a8afb350cb5f8db058e5e7b Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 17 Apr 2019 09:09:54 -0400 Subject: [PATCH] interfaces --- src/Core/Abstractions/ICollectionService.cs | 25 ++++++++++++++++++++ src/Core/Abstractions/IFolderService.cs | 26 +++++++++++++++++++++ src/Core/Services/CollectionService.cs | 10 ++------ src/Core/Services/FolderService.cs | 2 +- 4 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 src/Core/Abstractions/ICollectionService.cs create mode 100644 src/Core/Abstractions/IFolderService.cs diff --git a/src/Core/Abstractions/ICollectionService.cs b/src/Core/Abstractions/ICollectionService.cs new file mode 100644 index 000000000..1f649dba4 --- /dev/null +++ b/src/Core/Abstractions/ICollectionService.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Bit.Core.Models.Data; +using Bit.Core.Models.Domain; +using Bit.Core.Models.View; + +namespace Bit.Core.Abstractions +{ + public interface ICollectionService + { + Task ClearAsync(string userId); + void ClearCache(); + Task> DecryptManyAsync(List collections); + Task DeleteAsync(string id); + Task EncryptAsync(CollectionView model); + Task> GetAllAsync(); + Task> GetAllDecryptedAsync(); + Task>> GetAllNestedAsync(List collections = null); + Task GetAsync(string id); + Task> GetNestedAsync(string id); + Task ReplaceAsync(Dictionary collections); + Task UpsertAsync(CollectionData collection); + Task UpsertAsync(List collection); + } +} \ No newline at end of file diff --git a/src/Core/Abstractions/IFolderService.cs b/src/Core/Abstractions/IFolderService.cs new file mode 100644 index 000000000..818921fa6 --- /dev/null +++ b/src/Core/Abstractions/IFolderService.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Bit.Core.Models.Data; +using Bit.Core.Models.Domain; +using Bit.Core.Models.View; + +namespace Bit.Core.Abstractions +{ + public interface IFolderService + { + Task ClearAsync(string userId); + void ClearCache(); + Task DeleteAsync(string id); + Task DeleteWithServerAsync(string id); + Task EncryptAsync(FolderView model, SymmetricCryptoKey key = null); + Task> GetAllAsync(); + Task> GetAllDecryptedAsync(); + Task>> GetAllNestedAsync(); + Task GetAsync(string id); + Task> GetNestedAsync(string id); + Task ReplaceAsync(Dictionary folders); + Task SaveWithServerAsync(Folder folder); + Task UpsertAsync(FolderData folder); + Task UpsertAsync(List folder); + } +} \ No newline at end of file diff --git a/src/Core/Services/CollectionService.cs b/src/Core/Services/CollectionService.cs index 4fdff9432..226d07f62 100644 --- a/src/Core/Services/CollectionService.cs +++ b/src/Core/Services/CollectionService.cs @@ -11,7 +11,7 @@ using System.Threading.Tasks; namespace Bit.Core.Services { - public class CollectionService + public class CollectionService : ICollectionService { private const string Keys_CollectionsFormat = "collections_{0}"; private const char NestingDelimiter = '/'; @@ -19,25 +19,19 @@ namespace Bit.Core.Services private List _decryptedCollectionCache; private readonly ICryptoService _cryptoService; private readonly IUserService _userService; - private readonly IApiService _apiService; private readonly IStorageService _storageService; private readonly II18nService _i18nService; - private readonly ICipherService _cipherService; public CollectionService( ICryptoService cryptoService, IUserService userService, - IApiService apiService, IStorageService storageService, - II18nService i18nService, - ICipherService cipherService) + II18nService i18nService) { _cryptoService = cryptoService; _userService = userService; - _apiService = apiService; _storageService = storageService; _i18nService = i18nService; - _cipherService = cipherService; } public void ClearCache() diff --git a/src/Core/Services/FolderService.cs b/src/Core/Services/FolderService.cs index 2d2a6bb57..435c22e40 100644 --- a/src/Core/Services/FolderService.cs +++ b/src/Core/Services/FolderService.cs @@ -13,7 +13,7 @@ using System.Threading.Tasks; namespace Bit.Core.Services { - public class FolderService + public class FolderService : IFolderService { private const string Keys_CiphersFormat = "ciphers_{0}"; private const string Keys_FoldersFormat = "folders_{0}";