Skip to content

Commit

Permalink
feat: update via SDK Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Feb 19, 2024
1 parent e4f1f2a commit bfb221d
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions internal/shared/pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,10 @@ import (
"github.com/cloudflare/cloudflare-sdk-go/internal/requestconfig"
)

type V4PagePaginationResult struct {
Items []T `json:"items"`
JSON v4PagePaginationResultJSON `json:"-"`
}

// v4PagePaginationResultJSON contains the JSON metadata for the struct
// [V4PagePaginationResult]
type v4PagePaginationResultJSON struct {
Items apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *V4PagePaginationResult) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

type V4PagePagination[T any] struct {
Result V4PagePaginationResult `json:"result"`
ResultInfo interface{} `json:"result_info"`
JSON v4PagePaginationJSON `json:"-"`
Result []T `json:"result"`
ResultInfo interface{} `json:"result_info"`
JSON v4PagePaginationJSON `json:"-"`
cfg *requestconfig.RequestConfig
res *http.Response
}
Expand Down Expand Up @@ -95,17 +78,17 @@ func NewV4PagePaginationAutoPager[T any](page *V4PagePagination[T], err error) *
}

func (r *V4PagePaginationAutoPager[T]) Next() bool {
if r.page == nil || len(r.page.Result.Items) == 0 {
if r.page == nil || len(r.page.Result) == 0 {
return false
}
if r.idx >= len(r.page.Result.Items) {
if r.idx >= len(r.page.Result) {
r.idx = 0
r.page, r.err = r.page.GetNextPage()
if r.err != nil || r.page == nil || len(r.page.Result.Items) == 0 {
if r.err != nil || r.page == nil || len(r.page.Result) == 0 {
return false
}
}
r.cur = r.page.Result.Items[r.idx]
r.cur = r.page.Result[r.idx]
r.run += 1
r.idx += 1
return true
Expand Down

0 comments on commit bfb221d

Please sign in to comment.