From 8e728a249bd34db9336236a1bc5969b0e5554bf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=81abno?= Date: Fri, 20 Dec 2024 09:53:57 +0000 Subject: [PATCH] Add Pagination example --- examples/Pagination.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 examples/Pagination.cs diff --git a/examples/Pagination.cs b/examples/Pagination.cs new file mode 100644 index 0000000..1f2ddb5 --- /dev/null +++ b/examples/Pagination.cs @@ -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);