/// <summary> /// Creates a new <see cref="SmartCollection"/>. /// </summary> /// <param name="collection">A new <see cref="SmartCollection"/>. Id should be set to null.</param> /// <param name="cancellationToken">Cancellation Token</param> public virtual async Task <Entities.SmartCollection> CreateAsync(Entities.SmartCollection collection, bool published = true, CancellationToken cancellationToken = default) { var req = PrepareRequest($"smart_collections.json"); var body = collection.ToDictionary(); body.Add("published", published); var content = new JsonContent(new { smart_collection = body }); var response = await ExecuteRequestAsync <Entities.SmartCollection>(req, HttpMethod.Post, cancellationToken, content, "smart_collection"); return(response.Result); }
/// <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> /// <param name="cancellationToken">Cancellation Token</param> public virtual async Task <Entities.SmartCollection> UpdateAsync(long smartCollectionId, Entities.SmartCollection collection, CancellationToken cancellationToken = default) { var req = PrepareRequest($"smart_collections/{smartCollectionId}.json"); var content = new JsonContent(new { smart_collection = collection }); var response = await ExecuteRequestAsync <Entities.SmartCollection>(req, HttpMethod.Put, cancellationToken, content, "smart_collection"); return(response.Result); }