PR for Issue #3038 adds params for getInvoices pagination (#3039)

* ##3038 add pagination elements

* correct skip to take

* updated swagger docs

* set take nullable to true
This commit is contained in:
Troy Anderson
2021-10-31 05:47:12 -05:00
committed by GitHub
parent 1c2728bbfb
commit 8fed8f77ad
4 changed files with 42 additions and 3 deletions

View File

@@ -17,6 +17,8 @@ namespace BTCPayServer.Client
DateTimeOffset? endDate = null,
string textSearch = null,
bool includeArchived = false,
int? skip = null,
int? take = null,
CancellationToken token = default)
{
Dictionary<string, object> queryPayload = new Dictionary<string, object>();
@@ -34,6 +36,14 @@ namespace BTCPayServer.Client
queryPayload.Add(nameof(textSearch), textSearch);
if (status != null)
queryPayload.Add(nameof(status), status.Select(s=> s.ToString().ToLower()).ToArray());
if(skip != null) {
queryPayload.Add(nameof(skip), skip);
}
if(take != null) {
queryPayload.Add(nameof(take), take);
}
var response =
await _httpClient.SendAsync(

View File

@@ -57,7 +57,10 @@ namespace BTCPayServer.Controllers.GreenField
[ModelBinder(typeof(ModelBinders.DateTimeOffsetModelBinder))]
DateTimeOffset? endDate = null,
[FromQuery] string textSearch = null,
[FromQuery] bool includeArchived = false)
[FromQuery] bool includeArchived = false,
[FromQuery] int? skip = null,
[FromQuery] int? take = null
)
{
var store = HttpContext.GetStoreData();
if (store == null)
@@ -77,6 +80,8 @@ namespace BTCPayServer.Controllers.GreenField
var invoices =
await _invoiceRepository.GetInvoices(new InvoiceQuery()
{
Skip = skip,
Take = take,
StoreId = new[] {store.Id},
IncludeArchived = includeArchived,
StartDate = startDate,

View File

@@ -823,12 +823,16 @@ namespace BTCPayServer.Controllers.GreenField
DateTimeOffset? endDate = null,
string textSearch = null,
bool includeArchived = false,
CancellationToken token = default)
int? skip = null,
int? take = null,
CancellationToken token = default
)
{
return GetFromActionResult<IEnumerable<InvoiceData>>(
await _greenFieldInvoiceController.GetInvoices(storeId, orderId,
status?.Select(invoiceStatus => invoiceStatus.ToString())?.ToArray(), startDate,
endDate, textSearch, includeArchived));
endDate, textSearch, includeArchived,skip,take));
}
public override async Task<InvoiceData> GetInvoice(string storeId, string invoiceId,

View File

@@ -58,6 +58,26 @@
"required": false,
"description": "End date of the period to retrieve invoices",
"$ref": "#/components/schemas/UnixTimestamp"
},
{
"name": "skip",
"in": "query",
"required": false,
"description": "Number of records to skip",
"schema": {
"nullable": true,
"type": "number"
}
},
{
"name": "take",
"in": "query",
"required": false,
"description": "Number of records returned in response",
"schema": {
"nullable": true,
"type": "number"
}
}
],
"description": "View information about the existing invoices",