using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;
namespace Retailcrm.Versions.V5
{
public partial class Client
{
///
/// Get costs
///
///
///
///
///
public Response CostsList(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("/costs", Request.MethodGet, parameters);
}
///
/// Create cost
///
///
///
///
public Response CostsCreate(Dictionary cost, string site = "")
{
if (cost.Count < 1)
{
throw new ArgumentException("Parameter `cost` must contains a data");
}
if (!cost.ContainsKey("costItem"))
{
throw new ArgumentException("Parameter `costItem` must be set");
}
if (!cost.ContainsKey("summ"))
{
throw new ArgumentException("Parameter `summ` must be set");
}
if (!cost.ContainsKey("dateFrom"))
{
throw new ArgumentException("`dateFrom`: Time interval lower bound must not be blank");
}
if (!cost.ContainsKey("dateTo"))
{
throw new ArgumentException("`dateTo`: Time interval upper bound must not be blank");
}
return Request.MakeRequest(
"/costs/create",
Request.MethodPost,
FillSite(
site,
new Dictionary
{
{ "cost", new JavaScriptSerializer().Serialize(cost) }
}
)
);
}
///
/// Delete cost
///
///
///
public Response CostsDelete(List ids)
{
if (ids.Count < 1)
{
throw new ArgumentException("Parameter `ids` must contains a data");
}
return Request.MakeRequest(
"/costs/delete",
Request.MethodPost,
new Dictionary
{
{ "ids", new JavaScriptSerializer().Serialize(ids) }
}
);
}
///
/// Upload costs
///
///
///
public Response CostsUpload(List