socketry / cloudflare

An asynchronous Ruby wrapper for the CloudFlare V4 API.
138 stars 86 forks source link

Retrieve all zones through pagination #32

Closed shrmnk closed 6 years ago

shrmnk commented 6 years ago

Why

I have multiple zones associated with my Cloudflare account. When retrieving the zones through the library, I noticed that only a subset of zones were retrieved.

Currently, only 20 Zones will be retrieved with connection.zones.all, which is the default value of per_page.

What

This PR fixes the above issue and retrieves all the zones.

Also, the per_page limit is 50 (https://api.cloudflare.com/#zone-list-zones), and the values have been updated in this PR as well.

How

By applying the paginate method in Zones#all, we can retrieve all the records in the same manner as DNSRecords and FirewallRules are retrieved.

ioquatix commented 6 years ago

Thanks for working on this.

I believe some of the stubs in the specs have failed, but I'd be happy to accept this PR. Can you please fix the specs and I will merge.

shrmnk commented 6 years ago

Ah, forgot to update the stub to include the pagination query parameters. Its updated along with the merged changes from master.

ioquatix commented 6 years ago

Released in v3.2.0 :) Thanks for your effort.