using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;
namespace Retailcrm.Versions.V3
{
public partial class Client
{
///
/// Get packs list
///
///
///
///
///
public Response PacksList(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("/orders/packs", Request.MethodGet, parameters);
}
///
/// Create pack
///
///
///
public Response PacksCreate(Dictionary pack)
{
if (pack.Count < 1)
{
throw new ArgumentException("Parameter `pack` must contains a data");
}
return Request.MakeRequest(
"/orders/packs/create",
Request.MethodPost,
new Dictionary
{
{ "pack", new JavaScriptSerializer().Serialize(pack) }
}
);
}
///
/// Update pack data
///
///
///
public Response PacksUpdate(Dictionary pack)
{
if (pack.Count < 1)
{
throw new ArgumentException("Parameter `pack` must contains a data");
}
if (!pack.ContainsKey("id"))
{
throw new ArgumentException("Parameter `pack` must contains an id");
}
return Request.MakeRequest(
$"/orders/packs/{pack["id"].ToString()}/edit",
Request.MethodPost,
new Dictionary
{
{ "pack", new JavaScriptSerializer().Serialize(pack) }
}
);
}
///
/// Delete pack
///
///
///
public Response PacksDelete(string id)
{
return Request.MakeRequest(
$"/orders/packs/{id}/delete",
Request.MethodPost
);
}
///
/// Get pack by id
///
///
///
public Response PacksGet(string id)
{
return Request.MakeRequest(
$"/orders/packs/{id}",
Request.MethodGet
);
}
///
/// Get packs history
///
///
///
///
///
public Response PacksHistory(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 > 1)
{
parameters.Add("page", page);
}
if (limit > 0)
{
parameters.Add("limit", limit);
}
return Request.MakeRequest("/orders/packs/history", Request.MethodGet, parameters);
}
}
}