File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -234,11 +234,6 @@ type ListPagesOptions struct {
234234// calls Flattener to write each element into TempData, then invokes Callback for further
235235// processing of each item.
236236func ListPages (opt ListPagesOptions ) error {
237- itemKey := opt .ItemName
238- if itemKey == "" {
239- itemKey = "items"
240- }
241-
242237 params := make (map [string ]string )
243238 if opt .Filter != "" {
244239 params ["filter" ] = opt .Filter
@@ -266,8 +261,12 @@ func ListPages(opt ListPagesOptions) error {
266261 return HandleListGoogleApiError (err , url )
267262 }
268263
269- if v , ok := res [itemKey ].([]interface {}); ok {
270- for _ , item := range v {
264+ items , ok := res [opt .ItemName ].([]interface {})
265+ if ! ok && opt .ItemName != "items" {
266+ items , ok = res ["items" ].([]interface {})
267+ }
268+ if ok {
269+ for _ , item := range items {
271270 itemMap , ok := item .(map [string ]interface {})
272271 if ! ok {
273272 return fmt .Errorf ("expected item to be map[string]interface{}, got %T" , item )
You can’t perform that action at this time.
0 commit comments