keepsuit / laravel-zoho-campaigns

Manage Zoho Campaigns from Laravel
MIT License
1 stars 1 forks source link

Get list subscribers does not work if total count of contacts divisible by range #24

Closed andreibaca closed 3 months ago

andreibaca commented 3 months ago

Bug: If there are exactly 20 users in the list, the Campaigns->subscribers method would try to make another request with index 21 which will result in the following exception thrown: "Yet,There are no contacts in this list"

Found this bug while trying to optimise the function by first requesting the number of contacts and setting the range to this number to request all users in one go. This optimisation was wanted because if you need to get 2000+ contacts by getting only 20 per query it would result in 100+ queries which takes a lot of time.

I made a pull request that changes the algorithm a bit. It first queries for the count then goes through this count until it is negative or 0 with the step range. Range being a parameter of the method. If range is set to null it is equal to subscribers count and only one query is used.