An object representing a Shopify blog article.
Inheritance: ShopifySharp.ShopifyObject
Beispiel #1
0
        /// <summary>
        /// Creates a new article on the given blog.
        /// </summary>
        /// <param name="blogId">The blog that the article will belong to.</param>
        /// <param name="article">The article being created. Id should be null.</param>
        /// <param name="metafields">Optional metafield data that can be returned by the <see cref="ShopifyMetaFieldService"/>.</param>
        public async Task <ShopifyArticle> CreateAsync(long blogId, ShopifyArticle article, IEnumerable <ShopifyMetaField> metafields = null)
        {
            var req  = RequestEngine.CreateRequest($"blogs/{blogId}/articles.json", Method.POST, "article");
            var body = article.ToDictionary();

            if (metafields != null)
            {
                body.Add("metafields", metafields);
            }

            req.AddJsonBody(new
            {
                article = body
            });

            return(await RequestEngine.ExecuteRequestAsync <ShopifyArticle>(_RestClient, req));
        }
        /// <summary>
        /// Creates a new article on the given blog.
        /// </summary>
        /// <param name="blogId">The blog that the article will belong to.</param>
        /// <param name="article">The article being created. Id should be null.</param>
        /// <param name="metafields">Optional metafield data that can be returned by the <see cref="ShopifyMetaFieldService"/>.</param>
        public async Task<ShopifyArticle> CreateAsync(long blogId, ShopifyArticle article, IEnumerable<ShopifyMetaField> metafields = null)
        {
            var req = RequestEngine.CreateRequest($"blogs/{blogId}/articles.json", Method.POST, "article");
            var body = article.ToDictionary();
            
            if (metafields != null)
            {
                body.Add("metafields", metafields);
            }

            req.AddJsonBody(new
            {
                article = body
            });

            return await RequestEngine.ExecuteRequestAsync<ShopifyArticle>(_RestClient, req);
        }