code: def paginate_request(self, path, method, data=None, **kwargs):
          
          next_page = path
          while next_page:
              response = self.request(next_page, method, data=data, **kwargs)
  
              if not isinstance(response.get('data'), list):
                  next_page = None
                  yield response['data']
              else:
                  for entry in response['data']:
                      yield entry
  
                  # Get next page if it exists
                  try:
                      links = response['meta']['pagination']['links']
                      next_page = links.get('next_page')
                  except KeyError:
                      next_page = None
docs: Handle paginated requests to API
  
          :param str path: API endpoint's path to request
          :param str method: HTTP method to use
          :param dict data: Data to send (optional)
          :return: Response data items (:class:`Generator`)
  
          Cachet pagination is handled and next pages requested on demand.
  
          Additional named argument may be passed and are directly transmitted
          to :meth:`request` method of :class:`requests.Session` object.