public static Dictionary <string, DeviceStatsData> ParseJsonApiResponse(JsonApiResponse apiResponse, Dictionary <string, int> mappedIDs)
        {
            var ret = new Dictionary <string, DeviceStatsData>();

            // API seems to return these two by algorithm we mine 1 at a time so get first or default
            var devs  = apiResponse?.Devices?.FirstOrDefault();
            var algos = GetAlgorithmStats(apiResponse);

            if (devs != null && algos != null && mappedIDs != null)
            {
                // get all keys and filter out
                var keys = new HashSet <string>();
                foreach (var key in devs.Keys)
                {
                    keys.Add(key);
                }
                foreach (var key in algos.Keys)
                {
                    keys.Add(key);
                }
                keys.RemoveWhere(key => !key.Contains("GPU"));

                foreach (var key in keys)
                {
                    if (key.Contains("GPU"))
                    {
                        var keyGPUStrID = key.Split(' ').LastOrDefault();
                        if (!int.TryParse(keyGPUStrID, out var minerID))
                        {
                            continue;
                        }
                        var devUUIDPair = mappedIDs.Where(kvp => kvp.Value == minerID).FirstOrDefault();
                        if (devUUIDPair.Equals(default(KeyValuePair <string, int>)))
                        {
                            continue;
                        }
                        var devUUID  = devUUIDPair.Key;
                        var hashrate = JsonConvert.DeserializeObject <HashrateStats>(algos[key].ToString());
                        ret[devUUID] = new DeviceStatsData(hashrate, devs[key]);
                    }
                    else if (key.Contains("Total") && algos.ContainsKey(key))
                    {
                        ret[key] = new DeviceStatsData(null, devs[key]);
                    }
                    else
                    {
                        // what??
                    }
                }
            }
            return(ret);
        }
        private static Dictionary <string, object> GetAlgorithmStats(JsonApiResponse apiResponse)
        {
            if (apiResponse == null)
            {
                return(null);
            }
            if (apiResponse.Algorithms == null)
            {
                return(null);
            }
            var algo = apiResponse.Algorithms.FirstOrDefault();

            if (algo == null)
            {
                return(null);
            }
            return(algo.FirstOrDefault().Value);
        }