def process_posts_response(self, response, path, params, max_pages):
        """
        Insert / update all posts in a posts list response, in batches.

        :param response: a response that contains a list of posts from the WP API
        :param path: the path we're using to get the list of posts (for subsquent pages)
        :param params: the path we're using to get the list of posts (for subsquent pages)
        :param max_pages: kill counter to avoid infinite looping
        :return: None
        """
        page = 1
        num_processed_posts = 0
        api_posts_found = None
        while response.ok and response.text and page < max_pages:

            logger.info(" - page: %d", page)

            posts = []
            post_categories = {}
            post_tags = {}
            post_media_attachments = {}

            api_json = response.json()
            api_posts = api_json.get("posts")
            if not api_posts_found:
                api_posts_found = api_json.get("found", max_pages * self.batch_size)
                logger.info("Found %s posts", api_posts_found)

            # we're done if no posts left to process
            if not api_posts:
                break

            logger.info("Processing post modified date: %s", api_posts[0]["modified"])

            for api_post in api_posts:
                self.load_wp_post(api_post,
                                  bulk_mode=True,
                                  post_categories=post_categories,
                                  post_tags=post_tags,
                                  post_media_attachments=post_media_attachments,
                                  posts=posts)
                num_processed_posts += 1
                logger.debug("Processed %s of %s posts, modified date: %s", num_processed_posts, api_posts_found, api_post["modified"])

            if posts:
                self.bulk_create_posts(posts, post_categories, post_tags, post_media_attachments)

            # we're done if we've processed all posts
            if num_processed_posts >= api_posts_found:
                break

            # get next page
            page += 1
            next_page_handle = api_json.get("meta", {}).get("next_page")
            if next_page_handle:
                params["page_handle"] = next_page_handle
            else:
                # no more pages left
                break

            response = self.get(path, params)

            if not response.ok:
                logger.warning("Response NOT OK! status_code=%s\n%s", response.status_code, response.text)
                break
Insert / update all posts in a posts list response, in batches.

        :param response: a response that contains a list of posts from the WP API
        :param path: the path we're using to get the list of posts (for subsquent pages)
        :param params: the path we're using to get the list of posts (for subsquent pages)
        :param max_pages: kill counter to avoid infinite looping
        :return: None