public string ContainerDataForLanguageAndDevice(string dataField, string language, string device) { try { if (DisplayFamily.Find(device) == null) { throw new Exception($"{device} isn't a valid device name"); } var languages = RawDataDetails.FindAll(d => d.language == language); // IDEA: better error for non existing language if (languages.Count() < 1) { throw new Exception($"{language} isn't an activated language"); } var langDetails = languages.First(); var displayFamilies = langDetails.displayFamilies.value; var deviceDetails = displayFamilies.Find(df => df.name == device); if (deviceDetails == null) { throw new Exception($"Couldn't find device family for {device}"); } if (deviceDetails.GetType().GetProperty(dataField) == null) { throw new Exception($"Unexpected state: missing device details for {device}"); } var jsonSerializer = new JsonSerializer(); StringWriter textWriter = new StringWriter(); if (dataField == "messagesScreenshots") { jsonSerializer.Serialize(textWriter, deviceDetails.messagesScreenshots.value); return(textWriter.ToString()); //return deviceDetails.messagesScreenshots.value; } else if (dataField == "trailers") { jsonSerializer.Serialize(textWriter, deviceDetails.trailers.value); return(textWriter.ToString()); //return deviceDetails.trailers.value; } else { jsonSerializer.Serialize(textWriter, deviceDetails.screenshots.value); return(textWriter.ToString()); //return deviceDetails.screenshots.value; } } catch (Exception ex) { Console.WriteLine(ex.Message); throw new Exception($"App Store Connect error: {ex.Message}"); } }
public void SetupScreenshots() { // Enable Scaling for all screen sizes that don't have at least one screenshot or at least one trailer (app_preview) // We automatically disable scaling once we upload at least one screenshot RawDataDetails.ForEach(currentLanguage => { List <DisplayFamiliesValue> languageDetails = currentLanguage.displayFamilies.value; List <DisplayFamiliesValue> loopList = new List <DisplayFamiliesValue>(); languageDetails.AddRange(loopList); foreach (var deviceLanguageDetails in languageDetails) { // Do not enable scaling if a screenshot already exists if (deviceLanguageDetails.screenshots == null) { continue; } if (deviceLanguageDetails.screenshots.value.Count > 0) { continue; } // Do not enable scaling if a trailer already exists if (deviceLanguageDetails.trailers == null) { continue; } if (deviceLanguageDetails.trailers.value.Count > 0) { continue; } // The current row includes screenshots for all device types // so we need to enable scaling for both iOS and watchOS apps if (deviceLanguageDetails.scaled != null) { deviceLanguageDetails.scaled.value = true; } if (deviceLanguageDetails.messagesScaled != null) { deviceLanguageDetails.messagesScaled.value = true; } // we unset `scaled` or `messagesScaled` as soon as we upload a // screenshot for this device/language combination } }); foreach (var dataDetails in RawDataDetails) { // Now that's one language right here var collectedScreenshots = SetupScreenshotsFor(dataDetails); collectedScreenshots.AddRange(SetupMessagesScreenshotsFor(dataDetails)); screenshots[dataDetails.language] = collectedScreenshots; } }
public void SetupTrailers() { RawDataDetails.ForEach(dataDetails => { // Now that's one language right here trailers[dataDetails.language] = SetupTrailersFor(dataDetails); }); }
// Uploads or removes a screenshot // @param screenshotPath (String): The path to the screenshot. Use nil to remove it // @param sortOrder (Fixnum): The sort_order, from 1 to 5 // @param language (String): The language for this screenshot // @param device (string): The device for this screenshot // @param isMessages (Bool): True if the screenshot is for iMessage public void UploadScreenshot(string screenshotPath, int sortOrder, string language, string device, bool isMessages) { if (sortOrder < 1) { throw new Exception("sortOrder must be higher than 0"); } if (sortOrder > 10) { throw new Exception("sortOrder must be > 10"); } // this will also check both language and device parameters var deviceLangScreenshots = ScreenshotsDataForLanguageAndDevice(language, device, isMessages); var existingSortOrders = deviceLangScreenshots.Select(dls => dls.value.sortOrder).ToList(); if (!string.IsNullOrEmpty(screenshotPath)) { // adding or replacing UploadFile uploadFile = UploadFile.FromPath(screenshotPath); var screenshotData = Globals.TunesClient.UploadScreenshot(this, uploadFile, device, isMessages); // Since October 2016 we also need to pass the size, height, width and checksum // otherwise App Store Connect validation will fail at a later point var newScreenshot = new ScreenshotValue { value = new ImageSharedValues { assetToken = screenshotData.token, sortOrder = sortOrder, originalFileName = uploadFile.fileName, size = screenshotData.length, height = screenshotData.height, width = screenshotData.width, checksum = screenshotData.md5 } }; // We disable "scaling" for this device type / language combination // We only set this, if we actually successfully uploaded a new screenshot // for this device / language combination // if this value is not set, iTC will fallback to another device type for screenshots var languageDetails = RawDataDetails.Find(d => d.language == language).displayFamilies.value; var deviceLanguageDetails = languageDetails.Find(dp => dp.name == device); if (isMessages) { deviceLanguageDetails.messagesScaled.value = false; } else { deviceLanguageDetails.scaled.value = false; } if (existingSortOrders.Contains(sortOrder)) { // replace deviceLangScreenshots[existingSortOrders.IndexOf(sortOrder)] = newScreenshot; } else { // add deviceLangScreenshots.Add(newScreenshot); } } else { // removing if (!existingSortOrders.Contains(sortOrder)) { throw new Exception("cannot remove screenshot with non existing sortOrder"); } deviceLangScreenshots.RemoveAt(existingSortOrders.IndexOf(sortOrder)); } SetupScreenshots(); }