There's no way to paginate through Instruments
Judgeja opened this issue · comments
I think InstrumentSearchFilter needs to be able to take a page?
Oh Sorry, i dont get a Message for the issues.
Youre right. On the begin i dont needed Pages, so i dont added them to the filter. I will add them today.
Great thanks :), also I had to fork the project because Account.Tax_allowance should be a nullable int. I'd make a pull request but it's a 1 character change and had already forked. I was getting exceptions trying to get my account balance; I only have a paper account at the moment so I guess that's why it's null for me!
- I allowed now nullable on Tax_allowance.
- And i implemented pagination on two ways
- First IAsyncEnumarble
the LemonResults inhertance now from IAsyncEnumarble. So it call automaticly NextPageAsync method in the result object
#region getInstruments
InstrumentSearchFilter searchFilter = new(mic: "XMUN");
LemonResults<Instrument> resultInstruments = await lemonApi.Instruments.GetAsync(searchFilter);
// Sollte bei vom HttpClient oder beim Deserialiseren eine exception hochkommen gebe ich die Exception über das Result Objekt zurück
if (resultInstruments.Exception is not null)
{
await Console.Error.WriteLineAsync($"Leider ist eine Exception aufgetreten: {resultInstruments.Exception}");
return 2;
}
// Sollte IsSuccess nicht true sein, dann konnte keine Instruments abgerufen werden.
if (!resultInstruments.IsSuccess || resultInstruments.Results is null)
{
await Console.Error.WriteLineAsync($"Instruments konnten nicht abgerufen werden. HttpCode: '{resultInstruments.HttpCode}', Status: '{resultInstruments.Status}', ErrorCode: '{resultInstruments.Error_code}', ErrorMessage: '{resultInstruments.Error_message}'.");
return 3;
}
Console.WriteLine($"Die Instruments konnten abgerufen werden");
int count = 0;
await foreach (Instrument instrument in resultInstruments)
{
count++;
Console.WriteLine($"Isin: {instrument.ISIN}, Name: {instrument.Name}");
}
Console.WriteLine($"Es wurden {count} Instruments geladen");
#endregion getInstruments
- I add two Methods to the Result Object,
public Task<LemonResults<T>> NextPageAsync()
and
public Task<LemonResults<T>> PreviousPage()
before you call NextPageAsync check please HasNextPages before.
Thanks, you help me with your feedback :)