using System; using System.Collections.Generic; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V5 { public partial class Client { /// /// Create a task /// /// /// /// public Response TasksCreate(Dictionary task, string site = "") { if (task.Count < 1) { throw new ArgumentException("Parameter `task` must contains a data"); } return Request.MakeRequest( "/tasks/create", Request.MethodPost, FillSite( site, new Dictionary { { "task", new JavaScriptSerializer().Serialize(task) } } ) ); } /// /// Update a task /// /// /// /// public Response TasksUpdate(Dictionary task, string site = "") { if (task.Count < 1) { throw new ArgumentException("Parameter `task` must contains a data"); } if (!task.ContainsKey("id")) { throw new ArgumentException("Parameter `task` must contains an id"); } return Request.MakeRequest( $"/tasks/{task["id"].ToString()}/edit", Request.MethodPost, FillSite( site, new Dictionary { { "task", new JavaScriptSerializer().Serialize(task) } } ) ); } /// /// Get task /// /// /// public Response TasksGet(string id) { return Request.MakeRequest( $"/tasks/{id}", Request.MethodGet ); } /// /// Get tasks list /// /// /// /// /// public Response TasksList(Dictionary filter = null, int page = 1, int limit = 20) { Dictionary parameters = new Dictionary(); if (filter != null && filter.Count > 0) { parameters.Add("filter", filter); } if (page > 0) { parameters.Add("page", page); } if (limit > 0) { parameters.Add("limit", limit); } return Request.MakeRequest("/tasks", Request.MethodGet, parameters); } } }