jeevatkm / digitalocean-api-java

DigitalOcean API Client in Java
https://www.digitalocean.com/community/projects/api-client-in-java
MIT License
177 stars 68 forks source link

Pagination Not Working Correctly with /sizes Endpoint #80

Closed Mac-Genius closed 6 years ago

Mac-Genius commented 6 years ago

Description

The function getAvailableSizes in the DigitalOceanClient class ignores the pageNo parameter.

This happens because pageNo is passed to the wrong ApiRequest constructor on line 785 of the DigitalOceanClient class.

This may be an issue with other endpoints that use pagination.

Possible Fix

Instead of using this constructor:

public ApiRequest(ApiAction apiAction, Object data) {
  ...
}

Use the constructor that uses pageNo and perPage:

public ApiRequest(ApiAction apiAction, Integer pageNo, Integer perPage) {
  ...
}

Then pass in the default perPage value on line 785 of DigitalOceanClient:

return (Sizes) perform(new ApiRequest(ApiAction.AVAILABLE_SIZES, pageNo, DEFAULT_PAGE_SIZE)).getData();
jeevatkm commented 6 years ago

@Mac-Genius Thank you for reporting it with detailed information. Yeah, I see an issue. I will fix it tonight or tomorrow and make a release.

Mac-Genius commented 6 years ago

Thank you!

jeevatkm commented 6 years ago

I have fixed the issue, affected methods are -

And published 2.15-SNAPSHOT. Please give it try and let me know.

jeevatkm commented 6 years ago

@Mac-Genius I hope everything seems alright, I'm closing this one. Thank you.

Mac-Genius commented 6 years ago

@jeevatkm Sorry it took me so long, everything seems to be working properly now. Thank you!

jeevatkm commented 6 years ago

@Mac-Genius no worries, good to hear its working properly.