private static KeepaRecord writeProductRecord(JToken product) { var p = KeepaRecord.Parse(product); if (!string.IsNullOrEmpty(p.Asin)) { $"Writing keepa record for asin identifier to '{recordPath(p.Asin)}'".ConsoleWriteLine(); File.WriteAllText(recordPath(p.Asin), product.ToString()); } p.EanList?.ForEach(x => { $"Writing record for ean identifier to '{recordPath(x)}'".ConsoleWriteLine(); File.WriteAllText(recordPath(x), product.ToString()); File.WriteAllText(lastLookupPath(x), DateTime.Now.ToString(LAST_CALL_DATEFORMAT)); }); return(p); }
private static void writeRecordsFromResponse(string response_, bool ensureImagesToo_) { var doc = JObject.Parse(response_); var productToken = doc["products"]; if (productToken == null) { return; } var productArray = (JArray)productToken; productArray.ForEach(product => { writeProductRecord(product); if (ensureImagesToo_) { KeepaRecord.Parse(product).DownloadImages(); } }); }
public static IEnumerable <KeepaRecord> AllLocalRecords() => Directory.GetFiles(RECORDS_DIR, "*.json").Select(x => KeepaRecord.Parse(JToken.Parse(File.ReadAllText(x))));
public static KeepaRecord GetRecordForIdentifier(string identifier_) { var path = recordPath(identifier_); return(File.Exists(recordPath(identifier_)) ? KeepaRecord.Parse(JToken.Parse(File.ReadAllText(path))) : null); }