public void CreateThemeByFileName_Succeeds() { var themeFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AdminAPI", "sample_theme.zip"); var theme = new ThemeRequest(themeFilePath); var themeResponse = auth.UploadTheme(theme); Assert.AreEqual("sample_theme", themeResponse.Name); Assert.AreEqual("casper", themeResponse.Package.Name); Assert.AreEqual("https://demo.ghost.io", themeResponse.Package.Demo); Assert.AreEqual("v3", themeResponse.Package.Engines.GhostAPI); Assert.AreEqual("MIT", themeResponse.Package.License); Assert.AreEqual("assets/screenshot-desktop.jpg", themeResponse.Package.ScreenShots.Desktop); Assert.AreEqual("gulp", themeResponse.Package.Scripts.Dev); Assert.AreEqual("Ghost Foundation", themeResponse.Package.Author.Name); Assert.Greater(themeResponse.Package.GPM.Categories.Count, 0); Assert.Greater(themeResponse.Package.Keywords.Count, 0); Assert.AreEqual("git", themeResponse.Package.Repository.Type); Assert.AreEqual("https://github.com/TryGhost/Casper/issues", themeResponse.Package.Bugs); Assert.Greater(themeResponse.Package.DevDependencies.Count, 10); Assert.Greater(themeResponse.Package.BrowsersList.Count, 0); Assert.AreEqual(25, themeResponse.Package.Config.PostsPerPage); Assert.AreEqual(30, themeResponse.Package.Config.ImageSizes.XXS.Width); Assert.AreEqual(1000, themeResponse.Package.Config.ImageSizes.L.Width); Assert.IsFalse(themeResponse.Active); Assert.IsNull(themeResponse.Templates); }
/// <summary> /// From Theme Request to Theme Request pivot. /// </summary> /// <param name="themeRequest"></param> /// <returns>Theme Request pivot result.</returns> public static ThemeRequestPivot ToPivot(this ThemeRequest themeRequest) { return(new ThemeRequestPivot { FindThemePivot = Utility.EnumToEnum <FindThemeDto, FindThemePivot>(themeRequest.FindThemeDto), ThemePivot = themeRequest.ThemeDto.ToPivot() }); }
/// <summary> /// Upload a theme to the site /// </summary> /// <returns>Returns metadata about the theme.</returns> public Theme UploadTheme(ThemeRequest theme) { var request = new RestRequest("themes/upload/", Method.POST); if (theme.FilePath != null) { request.AddFile("file", theme.FilePath, "application/zip"); } else { request.AddFile("file", theme.File, theme.FileName, "application/zip"); } return(Execute <ThemeResponse>(request).Themes[0]); }
/// <summary> /// Delete Theme. /// </summary> /// <param name="request">theme request.</param> /// <returns>Theme message.</returns> public ThemeMessage DeleteTheme(ThemeRequest request) { ThemeMessage message = new ThemeMessage(); try { _serviceTheme.DeleteTheme(request.ToPivot()); message.OperationSuccess = true; } catch (Exception e) { message.ErrorType = ErrorType.TechnicalError; message.ErrorMessage = e.Message; } return(message); }
public IActionResult Update(ThemeRequest themeRequest) { var theme = new ThemeEditDTO { Name = themeRequest.Name, Open = themeRequest.Open, Text = themeRequest.Text, Id = themeRequest.Id }; var res = ThemeService.Update(theme, GetUser()); if (res == AccessCode.Succsess) { return(RedirectToAction("Index", new { id = themeRequest.Id })); } else { return(Redirect(res)); } }
/// <inheritdoc/> public ClientResponse <ThemeResponse> CreateTheme(Guid?themeId, ThemeRequest request) { return(client.CreateThemeAsync(themeId, request).GetAwaiter().GetResult()); }