pogobuf/pogobuf.utils.js
function(inventory) {
        if (!inventory || !inventory.success || !inventory.inventory_delta ||
            !inventory.inventory_delta.inventory_items) {
            return {};
        }

        var ret = {
            pokemon: [],
            removed_pokemon: [],
            items: [],
            pokedex: [],
            player: null,
            currency: [],
            camera: null,
            inventory_upgrades: [],
            applied_items: [],
            egg_incubators: [],
            candies: [],
            quests: []
        };

        inventory.inventory_delta.inventory_items.forEach(item => {
            if (item.inventory_item_data) {
                const itemdata = item.inventory_item_data;
                if (itemdata.pokemon_data) {
                    ret.pokemon.push(itemdata.pokemon_data);
                }
                if (itemdata.item) {
                    ret.items.push(itemdata.item);
                }
                if (itemdata.pokedex_entry) {
                    ret.pokedex.push(itemdata.pokedex_entry);
                }
                if (itemdata.player_stats) {
                    ret.player = itemdata.player_stats;
                }
                if (itemdata.player_currency) {
                    ret.currency.push(itemdata.player_currency);
                }
                if (itemdata.player_camera) {
                    ret.camera = itemdata.player_camera;
                }
                if (itemdata.inventory_upgrades) {
                    ret.inventory_upgrades.push(itemdata.inventory_upgrades);
                }
                if (itemdata.applied_items) {
                    ret.applied_items.push(itemdata.applied_items);
                }
                if (itemdata.egg_incubators) {
                    const incubators = itemdata.egg_incubators.egg_incubator || [];
                    ret.egg_incubators = ret.egg_incubators.concat(incubators);
                }
                if (itemdata.candy) {
                    ret.candies.push(itemdata.candy);
                }
                if (itemdata.quest) {
                    ret.quests.push(itemdata.quest);
                }
            }
            if (item.deleted_item && item.deleted_item.pokemon_id) {
                ret.removed_pokemon.push(item.deleted_item.pokemon_id);
            }
        });

        return ret;
    }
function(inventory) {
        if (!inventory || !inventory.success || !inventory.inventory_delta ||
            !inventory.inventory_delta.inventory_items) {
            return {};
        }

        var ret = {
            pokemon: [],
            removed_pokemon: [],
            items: [],
            pokedex: [],
            player: null,
            currency: [],
            camera: null,
            inventory_upgrades: [],
            applied_items: [],
            egg_incubators: [],
            candies: [],
            quests: []
        };

        inventory.inventory_delta.inventory_items.forEach(item => {
            if (item.inventory_item_data) {
                const itemdata = item.inventory_item_data;
                if (itemdata.pokemon_data) {
                    ret.pokemon.push(itemdata.pokemon_data);
                }
                if (itemdata.item) {
                    ret.items.push(itemdata.item);
                }
                if (itemdata.pokedex_entry) {
                    ret.pokedex.push(itemdata.pokedex_entry);
                }
                if (itemdata.player_stats) {
                    ret.player = itemdata.player_stats;
                }
                if (itemdata.player_currency) {
                    ret.currency.push(itemdata.player_currency);
                }
                if (itemdata.player_camera) {
                    ret.camera = itemdata.player_camera;
                }
                if (itemdata.inventory_upgrades) {
                    ret.inventory_upgrades.push(itemdata.inventory_upgrades);
                }
                if (itemdata.applied_items) {
                    ret.applied_items.push(itemdata.applied_items);
                }
                if (itemdata.egg_incubators) {
                    const incubators = itemdata.egg_incubators.egg_incubator || [];
                    ret.egg_incubators = ret.egg_incubators.concat(incubators);
                }
                if (itemdata.candy) {
                    ret.candies.push(itemdata.candy);
                }
                if (itemdata.quest) {
                    ret.quests.push(itemdata.quest);
                }
            }
            if (item.deleted_item && item.deleted_item.pokemon_id) {
                ret.removed_pokemon.push(item.deleted_item.pokemon_id);
            }
        });

        return ret;
    }
Takes a getInventory() response and separates it into pokemon, items, candies, player data,
eggs, quests, and pokedex.
@param {object} inventory - API response message as returned by getInventory()
@returns {object}
@static