Skip to content

Commit b890314

Browse files
committed
Document base search, change constants
1 parent c418b08 commit b890314

File tree

4 files changed

+39
-5
lines changed

4 files changed

+39
-5
lines changed

FortnoxAPILibrary.Tests/BaseConnectorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public void Test_AllInOnePage()
186186
MyAssert.HasNoError(connector);
187187
Assert.IsTrue(result.TotalPages > 1);
188188

189-
connector.Search.Page = APIConstants.AllInOnePage;
189+
connector.Search.Limit = APIConstants.Unlimited;
190190
var allInOneResult = connector.Find();
191191
MyAssert.HasNoError(connector);
192192

FortnoxAPILibrary/APIConstants.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ public class APIConstants
2626
public static int MaxLimit = 500; //Max limit
2727

2828
/// <summary>
29-
/// Special value for Page field of search settings
29+
/// Unlimited page size. This is special search settings not supported by the server API.
3030
/// When used, connector will gather all available pages, and return it as a single large page.
3131
/// Note that multiple HTTP requests may be send under the hood.
3232
/// The properties like url or response content of a connector will contain only the last one.
3333
/// </summary>
34-
public static int AllInOnePage = -1; //All pages
34+
public static int Unlimited = -1;
3535
}
3636
}

FortnoxAPILibrary/SearchableEntityConnector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class SearchableEntityConnector<TEntity, TEntitySubset, TSearchSettings>
1414
internal async Task<EntityCollection<TEntitySubset>> BaseFind(params string[] indices)
1515
{
1616
var searchSettings = Search.Clone();
17-
if (searchSettings.Page == APIConstants.AllInOnePage)
17+
if (searchSettings.Limit == APIConstants.Unlimited)
1818
return await GetAllInOnePage(searchSettings, indices);
1919
else
2020
return await GetSinglePage(searchSettings, indices);

FortnoxAPILibrary/Searches/BaseSearch.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,67 @@
33

44
namespace FortnoxAPILibrary
55
{
6+
/// <summary>
7+
/// Base settings for filtering search results.
8+
/// More info at official <see href="https://developer.fortnox.se/general/parameters/">documentation</see>
9+
/// </summary>
610
public class BaseSearch
711
{
12+
/// <summary>
13+
/// Limit search result to entities modified after specified date
14+
/// </summary>
815
[SearchParameter]
916
public DateTime? LastModified { get; set; }
1017

18+
/// <summary>
19+
/// Limit search result to entities relevant to specified financial year
20+
/// </summary>
1121
[SearchParameter("financialyear")]
1222
public long? FinancialYearID { get; set; }
1323

24+
/// <summary>
25+
/// Limit search result to entities relevant to financial year to which this date belongs.
26+
/// Note, financial years don't overlap, therefore a date defines one (or none) financial year
27+
/// </summary>
1428
[SearchParameter]
1529
public DateTime? FinancialYearDate { get; set; }
1630

31+
/// <summary>
32+
/// Limits search result to entities with date (e.g. InvoiceDate) after specified date
33+
/// Only available for invoices, orders, offers and vouchers.
34+
/// </summary>
1735
[SearchParameter]
1836
public DateTime? FromDate { get; set; }
1937

38+
/// <summary>
39+
/// Limits search result to entities with date (e.g. InvoiceDate) before specified date
40+
/// Only available for invoices, orders, offers and vouchers.
41+
/// </summary>
2042
[SearchParameter]
2143
public DateTime? ToDate { get; set; }
2244

23-
45+
/// <summary>
46+
/// Defines order for search result
47+
/// </summary>
2448
[SearchParameter]
2549
public Sort.Order? SortOrder { get; set; }
2650

51+
/// <summary>
52+
/// Defines page size for the search result. If undefined, API uses page size 100.
53+
/// APIConstants.MaxLimit and APIConstants.Unlimited can be used.
54+
/// </summary>
2755
[SearchParameter]
2856
public int? Limit { get; set; }
2957

58+
/// <summary>
59+
/// Defines which page should be retrieved. If undefined, API uses page 1
60+
/// </summary>
3061
[SearchParameter]
3162
public int? Page { get; set; }
3263

64+
/// <summary>
65+
/// Skips specified amount of entities from search result. If undefined, API uses 0
66+
/// </summary>
3367
[SearchParameter]
3468
public int? Offset { get; set; }
3569

0 commit comments

Comments
 (0)