Example #1
0
        /// <summary>
        /// Creates a new <see cref="SmartCollection"/>.
        /// </summary>
        /// <param name="collection">A new <see cref="SmartCollection"/>. Id should be set to null.</param>
        public virtual async Task <SmartCollection> CreateAsync(SmartCollection collection)
        {
            var req     = PrepareRequest($"smart_collections.json");
            var content = new JsonContent(new
            {
                smart_collection = collection
            });

            return(await ExecuteRequestAsync <SmartCollection>(req, HttpMethod.Post, content, "smart_collection"));
        }
        /// <summary>
        /// Creates a new <see cref="SmartCollection"/>.
        /// </summary>
        /// <param name="collection">A new <see cref="SmartCollection"/>. Id should be set to null.</param>
        public virtual async Task <SmartCollection> CreateAsync(SmartCollection collection, bool published = true)
        {
            var req  = PrepareRequest($"smart_collections.json");
            var body = collection.ToDictionary();

            body.Add("published", published);

            var content = new JsonContent(new
            {
                smart_collection = body
            });

            return(await ExecuteRequestAsync <SmartCollection>(req, HttpMethod.Post, content, "smart_collection"));
        }
Example #3
0
        /// <summary>
        /// Updates the given <see cref="SmartCollection"/>.
        /// </summary>
        /// <param name="smartCollectionId">Id of the object being updated.</param>
        /// <param name="collection">The smart collection to update.</param>
        public virtual async Task <SmartCollection> UpdateAsync(long smartCollectionId, SmartCollection collection)
        {
            var req     = PrepareRequest($"smart_collections/{smartCollectionId}.json");
            var content = new JsonContent(new
            {
                smart_collection = collection
            });
            var response = await ExecuteRequestAsync <SmartCollection>(req, HttpMethod.Put, content, "smart_collection");

            return(response.Result);
        }