code: func (client *Client) PaginateWithContext(ctx context.Context, g Listable, callback IterateItemFunc) {
  	req, err := g.ListRequest()
  	if err != nil {
  		callback(nil, err)
  		return
  	}
  
  	pageSize := client.PageSize
  
  	page := 1
  
  	for {
  		req.SetPage(page)
  		req.SetPageSize(pageSize)
  		resp, err := client.RequestWithContext(ctx, req)
  		if err != nil {
  			// in case of 431, the response is knowingly empty
  			if errResponse, ok := err.(*ErrorResponse); ok && page == 1 && errResponse.ErrorCode == ParamError {
  				break
  			}
  
  			callback(nil, err)
  			break
  		}
  
  		size := 0
  		didErr := false
  		req.Each(resp, func(element interface{}, err error) bool {
  			// If the context was cancelled, kill it in flight
  			if e := ctx.Err(); e != nil {
  				element = nil
  				err = e
  			}
  
  			if callback(element, err) {
  				size++
  				return true
  			}
  
  			didErr = true
  			return false
  		})
  
  		if size < pageSize || didErr {
  			break
  		}
  
  		page++
  	}
  }
docs: // PaginateWithContext runs the ListCommand as long as the ctx is valid