def ProcessStore(self: Any, data: Dict[str, Any]) -> Optional[Dict[str, Any]]: """Process and return the Store API response.""" featured: List[Dict[str, Any]] = [] operators: List[Dict[str, Any]] = [] blueprints: List[Dict[str, Any]] = [] for bundle in data.get("items"): typeKey: str = bundle.get("typeKey") if typeKey == "FEATURED": featured.append(bundle) elif typeKey == "OPERATOR": operators.append(bundle) elif typeKey == "WEAPON": blueprints.append(bundle) else: log.warning(f"Unknown Bundle typeKey found: {typeKey}") lenF: int = len(featured) lenO: int = len(operators) lenB: int = len(blueprints) if (lenF == 0) or (lenO == 0) or (lenB == 0): if self.config["preferences"].get("verify") is True: log.error( f"Failed to process the Store (Featured: {lenF:,}, Operators: {lenO:,}, Blueprints: {lenB:,})" ) return None return { "updateDate": Utility.ISOtoHumanDate(self, data.get("lastUpdated")), "updateTime": Utility.ISOtoHumanTime(self, data.get("lastUpdated")), "hash": data.get("hash"), "featured": featured, "operators": operators, "blueprints": blueprints, }
def GetStore(self: Any) -> Optional[Dict[str, Any]]: """ Fetch the latest Store data for Modern Warfare and Warzone from the Tracker Network API. """ data: Optional[Any] = Utility.GET( self, "https://api.tracker.gg/api/v1/modern-warfare/store") if data is None: return None store: Dict[str, Any] = data.get("data") updateDate: str = Utility.ISOtoHumanDate(self, store.get("lastUpdated")) updateTime: str = Utility.ISOtoHumanTime(self, store.get("lastUpdated")) log.info(f"Fetched the Store for {updateDate} at {updateTime} UTC") return store