internal static void RequestMarketHistory()
        {
            if (EveSwaggerInterface.Working())
            {
                return;
            }

            var failedRequests = EveSwaggerInterface.GetFailedHistoryRequests();

            foreach (var failedRequest in failedRequests)
            {
                var esiType = EveSwaggerInterface.GetType(failedRequest.Id);
                if (esiType == null || !esiType.published)
                {
                    var product = EoiDataInterface.GetTypeById(failedRequest.Id);
                    if (product != null)
                    {
                        product.Invalid = true;
                        EoiDataInterface.CheckInvalid();
                    }
                }
            }

            EveSwaggerInterface.ClearFailedHistoryRequests();

            var blueprints = EoiDataInterface.GetBlueprints();

            foreach (var blueprint in blueprints)
            {
                foreach (var product in blueprint.Products)
                {
                    RawEsiPriceHistory marketHistory = null;

                    var region = Regions.GetTradehubRegionId(SolarSystems.GetSolarSystem(SettingsInterface.GlobalSettings.TradeHub));

                    marketHistory = EveSwaggerInterface.GetMarketHistory(product.Id, region);
                    if (marketHistory != null)
                    {
                        var esiDataMarketHistory = _marketHistory.FirstOrDefault(x => Equals(x.History, marketHistory));
                        if (esiDataMarketHistory == null)
                        {
                            var oldEsiDataMarketHistory = _marketHistory.FirstOrDefault(x => x.Id == marketHistory.typeId && x.Region == marketHistory.regionId);
                            if (oldEsiDataMarketHistory != null)
                            {
                                _marketHistory.Remove(oldEsiDataMarketHistory);
                            }

                            _marketHistory.Add(new EsiDataMarketHistory(marketHistory));
                        }
                    }
                }
            }
        }
        public EsiDataMarketHistory(RawEsiPriceHistory history)
        {
            if (history == null)
            {
                this.Invalid = true;
                return;
            }

            History = history;

            this.Id        = history.typeId;
            this.Region    = history.regionId;
            this.Timestamp = history.Timestamp;

            Initialize();
        }