diff --git a/FortnoxAPILibrary.Tests/BaseConnectorTests.cs b/FortnoxAPILibrary.Tests/BaseConnectorTests.cs index db90718f..8d0ce16a 100644 --- a/FortnoxAPILibrary.Tests/BaseConnectorTests.cs +++ b/FortnoxAPILibrary.Tests/BaseConnectorTests.cs @@ -186,7 +186,7 @@ public void Test_AllInOnePage() MyAssert.HasNoError(connector); Assert.IsTrue(result.TotalPages > 1); - connector.Search.Page = APIConstants.AllInOnePage; + connector.Search.Limit = APIConstants.Unlimited; var allInOneResult = connector.Find(); MyAssert.HasNoError(connector); diff --git a/FortnoxAPILibrary/APIConstants.cs b/FortnoxAPILibrary/APIConstants.cs index 59734a8c..8cc279ef 100644 --- a/FortnoxAPILibrary/APIConstants.cs +++ b/FortnoxAPILibrary/APIConstants.cs @@ -26,11 +26,11 @@ public class APIConstants public static int MaxLimit = 500; //Max limit /// - /// Special value for Page field of search settings + /// Unlimited page size. This is special search settings not supported by the server API. /// When used, connector will gather all available pages, and return it as a single large page. /// Note that multiple HTTP requests may be send under the hood. /// The properties like url or response content of a connector will contain only the last one. /// - public static int AllInOnePage = -1; //All pages + public static int Unlimited = -1; } } diff --git a/FortnoxAPILibrary/SearchableEntityConnector.cs b/FortnoxAPILibrary/SearchableEntityConnector.cs index 48e06e45..1df4e238 100644 --- a/FortnoxAPILibrary/SearchableEntityConnector.cs +++ b/FortnoxAPILibrary/SearchableEntityConnector.cs @@ -14,7 +14,7 @@ public class SearchableEntityConnector internal async Task> BaseFind(params string[] indices) { var searchSettings = Search.Clone(); - if (searchSettings.Page == APIConstants.AllInOnePage) + if (searchSettings.Limit == APIConstants.Unlimited) return await GetAllInOnePage(searchSettings, indices); else return await GetSinglePage(searchSettings, indices); diff --git a/FortnoxAPILibrary/Searches/BaseSearch.cs b/FortnoxAPILibrary/Searches/BaseSearch.cs index 55ffb65d..480bfb76 100644 --- a/FortnoxAPILibrary/Searches/BaseSearch.cs +++ b/FortnoxAPILibrary/Searches/BaseSearch.cs @@ -3,33 +3,67 @@ namespace FortnoxAPILibrary { + /// + /// Base settings for filtering search results. + /// More info at official documentation + /// public class BaseSearch { + /// + /// Limit search result to entities modified after specified date + /// [SearchParameter] public DateTime? LastModified { get; set; } + /// + /// Limit search result to entities relevant to specified financial year + /// [SearchParameter("financialyear")] public long? FinancialYearID { get; set; } + /// + /// Limit search result to entities relevant to financial year to which this date belongs. + /// Note, financial years don't overlap, therefore a date defines one (or none) financial year + /// [SearchParameter] public DateTime? FinancialYearDate { get; set; } + /// + /// Limits search result to entities with date (e.g. InvoiceDate) after specified date + /// Only available for invoices, orders, offers and vouchers. + /// [SearchParameter] public DateTime? FromDate { get; set; } + /// + /// Limits search result to entities with date (e.g. InvoiceDate) before specified date + /// Only available for invoices, orders, offers and vouchers. + /// [SearchParameter] public DateTime? ToDate { get; set; } - + /// + /// Defines order for search result + /// [SearchParameter] public Sort.Order? SortOrder { get; set; } + /// + /// Defines page size for the search result. If undefined, API uses page size 100. + /// APIConstants.MaxLimit and APIConstants.Unlimited can be used. + /// [SearchParameter] public int? Limit { get; set; } + /// + /// Defines which page should be retrieved. If undefined, API uses page 1 + /// [SearchParameter] public int? Page { get; set; } + /// + /// Skips specified amount of entities from search result. If undefined, API uses 0 + /// [SearchParameter] public int? Offset { get; set; }