Skip to content

Commit

Permalink
Add pagination support for ListCertificatePacks
Browse files Browse the repository at this point in the history
  • Loading branch information
sxi-yext committed Jan 17, 2023
1 parent d2ab0c0 commit da9bca0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions certificate_packs.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ type CertificatePacksAdvancedDetailResponse struct {
// ListCertificatePacks returns all available TLS certificate packs for a zone.
//
// API Reference: https://api.cloudflare.com/#certificate-packs-list-certificate-packs
func (api *API) ListCertificatePacks(ctx context.Context, zoneID string) ([]CertificatePack, error) {
uri := fmt.Sprintf("/zones/%s/ssl/certificate_packs?status=all", zoneID)
func (api *API) ListCertificatePacks(ctx context.Context, zoneID string, page int) ([]CertificatePack, error) {
uri := fmt.Sprintf("/zones/%s/ssl/certificate_packs?status=all&per_page=50&page=%d", zoneID, page)
res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
if err != nil {
return []CertificatePack{}, err
Expand Down
4 changes: 2 additions & 2 deletions certificate_packs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestListCertificatePacks(t *testing.T) {
handler := func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, http.MethodGet, r.Method, "Expected method 'GET', got %s", r.Method)
w.Header().Set("content-type", "application/json")
fmt.Fprintf(w, `{
fmt.Fprintf(w, `{ListCertificatePacks(
"success": true,
"errors": [],
"messages": [],
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestListCertificatePacks(t *testing.T) {
mux.HandleFunc("/zones/023e105f4ecef8ad9ca31a8372d0c353/ssl/certificate_packs", handler)

want := []CertificatePack{desiredCertificatePack}
actual, err := client.ListCertificatePacks(context.Background(), "023e105f4ecef8ad9ca31a8372d0c353")
actual, err := client.ListCertificatePacks(context.Background(), "023e105f4ecef8ad9ca31a8372d0c353", 1)

if assert.NoError(t, err) {
assert.Equal(t, want, actual)
Expand Down

0 comments on commit da9bca0

Please sign in to comment.