diff --git a/PocketSharp/Components/Get.cs b/PocketSharp/Components/Get.cs index 33d1f8e..753b227 100644 --- a/PocketSharp/Components/Get.cs +++ b/PocketSharp/Components/Get.cs @@ -159,6 +159,7 @@ namespace PocketSharp public async Task> SearchByTag(string tag, CancellationToken cancellationToken = default(CancellationToken)) { return await Get( + state: State.all, cancellationToken: cancellationToken, tag: tag ); @@ -169,37 +170,24 @@ namespace PocketSharp /// Retrieves items which match the specified search string in title and URI /// /// The search string. - /// if set to true [search in URI]. + /// Filter by tag. /// The cancellation token. /// /// Search string length has to be a minimum of 2 chars /// - public async Task> Search(string searchString, bool searchInUri = true, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> Search(string searchString, string tag = null, CancellationToken cancellationToken = default(CancellationToken)) { - List items = await Get(RetrieveFilter.All, cancellationToken); - return Search(items, searchString); - } - - - /// - /// Finds the specified search string in title and URI for an available list of items - /// - /// The available items. - /// The search string. - /// - /// Search string length has to be a minimum of 2 chars - /// - public List Search(List availableItems, string searchString) - { - if (searchString.Length < 2) + if (String.IsNullOrEmpty(searchString) || searchString.Length < 2) { throw new ArgumentOutOfRangeException("Search string length has to be a minimum of 2 chars"); } - return availableItems.Where(item => ( - (!String.IsNullOrEmpty(item.FullTitle) && item.FullTitle.ToLower().Contains(searchString)) - || item.Uri.ToString().ToLower().Contains(searchString) - )).ToList(); + return await Get( + state: State.all, + search: searchString, + tag: tag, + cancellationToken: cancellationToken + ); } } diff --git a/PocketSharp/IPocketClient.cs b/PocketSharp/IPocketClient.cs index 420bacf..c418ebf 100644 --- a/PocketSharp/IPocketClient.cs +++ b/PocketSharp/IPocketClient.cs @@ -182,22 +182,12 @@ namespace PocketSharp /// Retrieves items which match the specified search string in title and URI /// /// The search string. - /// if set to true [search in URI]. + /// Filter by tag. /// The cancellation token. /// /// Search string length has to be a minimum of 2 chars /// - Task> Search(string searchString, bool searchInUri = true, CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Finds the specified search string in title and URI for an available list of items - /// - /// The available items. - /// The search string. - /// - /// Search string length has to be a minimum of 2 chars - /// - List Search(List availableItems, string searchString); + Task> Search(string searchString, string tag = null, CancellationToken cancellationToken = default(CancellationToken)); #endregion #region modify methods