Skip to content

Commit

Permalink
Add Pagination example
Browse files Browse the repository at this point in the history
  • Loading branch information
jakublabno committed Dec 20, 2024
1 parent ee9622e commit 8e728a2
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions examples/Pagination.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using SMSApi.Api;

var client = new ClientOAuth("token");
var features = new Features(client);

var listSendernames = (uint collectionLimit, uint collectionOffset) =>
{
var list = features.Sendernames().List();

list.Limit = collectionLimit;
list.Offset = collectionOffset;

return list.Execute();
};

const uint limit = 25;
uint offset = 0;
bool hasMoreItems;

do
{
var sendernames = listSendernames(limit, offset);

sendernames.Collection.ForEach(sendername =>
{
Console.WriteLine($"Sender: {sendername.Sender}");
});

hasMoreItems = sendernames.Size > limit + offset;
offset += limit;
} while (hasMoreItems);

0 comments on commit 8e728a2

Please sign in to comment.