DavidRouyer / pipedrive-dotnet

Pipedrive.net is an async .NET Standard client for pipedrive.com
MIT License
38 stars 46 forks source link

Auto Paging is not working #23

Open snappet-panksy opened 5 years ago

snappet-panksy commented 5 years ago

I believe the paging is not working with any client but I specifically tested it on the Activity Client with an integration test. - The default page size is 100 there are more than 100 activities in the sandbox. This test fails. I can see that the API Pagination is expecting items in the header which are no longer there.

            [IntegrationTest]
            public async Task ReturnsMultiplePages()
            {
                var pipedrive = Helper.GetAuthenticatedClient();
                var startFilters = new ActivityFilters();
                var allPages = await pipedrive.Activity.GetAll(startFilters);
                Assert.True(allPages.Count > 100);
            }

I put in a nasty hack in a branch I am using but I think there must be a better way to resolve this using your existing pattern.

ReadOnlyPagesCollection never has a next page:

        public async Task<IReadOnlyPagedCollection<T>> GetNextPage()
        {
            var nextPageUrl = _info.GetNextPageUrl();
           if (nextPageUrl == null) return null;

nextPageUrl is always null.

DavidRouyer commented 5 years ago

Indeed, there is no auto paging on the endpoints. It would be fairly easy to implement by using the informations fetched from the endpoints that are populated in https://github.com/DavidRouyer/pipedrive-dotnet/blob/master/src/Pipedrive.net/Models/Response/PaginationInfo.cs, but I don't I'll implement it due to the number of requests it could create (Pipedrive is kinda slow) and there is the rate limiting to take into account.

You can paginate through the pages manually.

redflowIT commented 4 years ago

I'm trying to use manual pagination with Deals but incrementing StartPage in DealsFilter I'm getting next page in the list.....how should I get the 'stop' condition? When I'll get the last one?

..my error is working on StartPage considering as number of page instead of number of item in the list.....probably it's better to change the name of the property.

gregarican commented 4 years ago

It would be beneficial if there was an improved method of auto pagination. Especially since the return type for GetAll() is typically a read-only list. Also, as mentioned above the StartPage property is really the StartRecord.

GuerrillaCoder commented 3 years ago

I am also wondering how to know if there is a next page as no next page value on read only list.