/// <summary> /// Creates a new <see cref="ShopifyTheme"/> on the store. The theme always starts out with a role of /// "unpublished." If the theme has a different role, it will be assigned that only after all of its /// files have been extracted and stored by Shopify (which might take a couple of minutes). /// </summary> /// <param name="theme">The new <see cref="ShopifyTheme"/>.</param> /// <param name="sourceUrl">A URL that points to the .zip file containing the theme's source files.</param> /// <returns>The new <see cref="ShopifyTheme"/>.</returns> public async Task<ShopifyTheme> CreateAsync(ShopifyTheme theme, string sourceUrl) { IRestRequest req = RequestEngine.CreateRequest("themes.json", Method.POST, "theme"); //Convert the theme to a dictionary, which will let us add the src URL to the request. var body = theme.ToDictionary(); if (string.IsNullOrEmpty(sourceUrl) == false) { body["src"] = sourceUrl; } req.AddJsonBody(new { theme = body }); return await RequestEngine.ExecuteRequestAsync<ShopifyTheme>(_RestClient, req); }
/// <summary> /// Creates a new <see cref="ShopifyTheme"/> on the store. The theme always starts out with a role of /// "unpublished." If the theme has a different role, it will be assigned that only after all of its /// files have been extracted and stored by Shopify (which might take a couple of minutes). /// </summary> /// <param name="theme">The new <see cref="ShopifyTheme"/>.</param> /// <param name="sourceUrl">A URL that points to the .zip file containing the theme's source files.</param> /// <returns>The new <see cref="ShopifyTheme"/>.</returns> public async Task <ShopifyTheme> CreateAsync(ShopifyTheme theme, string sourceUrl) { IRestRequest req = RequestEngine.CreateRequest("themes.json", Method.POST, "theme"); //Convert the theme to a dictionary, which will let us add the src URL to the request. var body = theme.ToDictionary(); if (string.IsNullOrEmpty(sourceUrl) == false) { body["src"] = sourceUrl; } req.AddJsonBody(new { theme = body }); return(await RequestEngine.ExecuteRequestAsync <ShopifyTheme>(_RestClient, req)); }
/// <summary> /// Updates the given <see cref="ShopifyTheme"/>. Id must not be null. /// </summary> /// <param name="theme">The <see cref="ShopifyTheme"/> to update.</param> /// <returns>The updated <see cref="ShopifyTheme"/>.</returns> public async Task<ShopifyTheme> UpdateAsync(ShopifyTheme theme) { IRestRequest req = RequestEngine.CreateRequest("themes/{0}.json".FormatWith(theme.Id.Value), Method.PUT, "theme"); req.AddJsonBody(new { theme }); return await RequestEngine.ExecuteRequestAsync<ShopifyTheme>(_RestClient, req); }