using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;
namespace Retailcrm.Versions.V3
{
public partial class Client
{
///
/// Countries
///
///
public Response Countries()
{
return Request.MakeRequest(
"/reference/countries",
Request.MethodGet
);
}
///
/// Delivery services
///
///
public Response DeliveryServices()
{
return Request.MakeRequest(
"/reference/delivery-services",
Request.MethodGet
);
}
///
/// Delivery types
///
///
public Response DeliveryTypes()
{
return Request.MakeRequest(
"/reference/delivery-types",
Request.MethodGet
);
}
///
/// Order methods
///
///
public Response OrderMethods()
{
return Request.MakeRequest(
"/reference/order-methods",
Request.MethodGet
);
}
///
/// Order types
///
///
public Response OrderTypes()
{
return Request.MakeRequest(
"/reference/order-types",
Request.MethodGet
);
}
///
/// Payment statuses
///
///
public Response PaymentStatuses()
{
return Request.MakeRequest(
"/reference/payment-statuses",
Request.MethodGet
);
}
///
/// Payment types
///
///
public Response PaymentTypes()
{
return Request.MakeRequest(
"/reference/payment-types",
Request.MethodGet
);
}
///
/// Product statuses
///
///
public Response ProductStatuses()
{
return Request.MakeRequest(
"/reference/product-statuses",
Request.MethodGet
);
}
///
/// Sites
///
///
public Response Sites()
{
return Request.MakeRequest(
"/reference/sites",
Request.MethodGet
);
}
///
/// Statuses groups
///
///
public Response StatusGroups()
{
return Request.MakeRequest(
"/reference/status-groups",
Request.MethodGet
);
}
///
/// Statuses
///
///
public Response Statuses()
{
return Request.MakeRequest(
"/reference/statuses",
Request.MethodGet
);
}
///
/// Stores
///
///
public Response Stores()
{
return Request.MakeRequest(
"/reference/stores",
Request.MethodGet
);
}
///
/// Delivery services edit
///
///
///
public Response DeliveryServicesEdit(Dictionary service)
{
if (!service.ContainsKey("code"))
{
throw new ArgumentException("Parameter `code` is missing");
}
if (!service.ContainsKey("name"))
{
throw new ArgumentException("Parameter `name` is missing");
}
return Request.MakeRequest(
$"/reference/delivery-services/{service["code"].ToString()}/edit",
Request.MethodPost,
new Dictionary
{
{ "deliveryService", new JavaScriptSerializer().Serialize(service) }
}
);
}
///
/// Delivery types edit
///
///
///
public Response DeliveryTypesEdit(Dictionary type)
{
if (!type.ContainsKey("code"))
{
throw new ArgumentException("Parameter `code` is missing");
}
if (!type.ContainsKey("name"))
{
throw new ArgumentException("Parameter `name` is missing");
}
if (!type.ContainsKey("defaultCost"))
{
throw new ArgumentException("Parameter `defaultCost` is missing");
}
if (!type.ContainsKey("defaultNetCost"))
{
throw new ArgumentException("Parameter `defaultCost` is missing");
}
return Request.MakeRequest(
$"/reference/delivery-types/{type["code"].ToString()}/edit",
Request.MethodPost,
new Dictionary
{
{ "deliveryType", new JavaScriptSerializer().Serialize(type) }
}
);
}
///
/// Orders methods edit
///
///
///
public Response OrderMethodsEdit(Dictionary method)
{
if (!method.ContainsKey("code"))
{
throw new ArgumentException("Parameter `code` is missing");
}
if (!method.ContainsKey("name"))
{
throw new ArgumentException("Parameter `name` is missing");
}
return Request.MakeRequest(
$"/reference/order-methods/{method["code"].ToString()}/edit",
Request.MethodPost,
new Dictionary
{
{ "orderMethod", new JavaScriptSerializer().Serialize(method) }
}
);
}
///
/// Order types edit
///
///
///
public Response OrderTypesEdit(Dictionary type)
{
if (!type.ContainsKey("code"))
{
throw new ArgumentException("Parameter `code` is missing");
}
if (!type.ContainsKey("name"))
{
throw new ArgumentException("Parameter `name` is missing");
}
return Request.MakeRequest(
$"/reference/order-types/{type["code"].ToString()}/edit",
Request.MethodPost,
new Dictionary
{
{ "orderType", new JavaScriptSerializer().Serialize(type) }
}
);
}
///
/// Payment statuses edit
///
///
///
public Response PaymentStatusesEdit(Dictionary status)
{
if (!status.ContainsKey("code"))
{
throw new ArgumentException("Parameter `code` is missing");
}
if (!status.ContainsKey("name"))
{
throw new ArgumentException("Parameter `name` is missing");
}
return Request.MakeRequest(
$"/reference/payment-statuses/{status["code"].ToString()}/edit",
Request.MethodPost,
new Dictionary
{
{ "paymentStatus", new JavaScriptSerializer().Serialize(status) }
}
);
}
///
/// Payment types edit
///
///
///
public Response PaymentTypesEdit(Dictionary type)
{
if (!type.ContainsKey("code"))
{
throw new ArgumentException("Parameter `code` is missing");
}
if (!type.ContainsKey("name"))
{
throw new ArgumentException("Parameter `name` is missing");
}
return Request.MakeRequest(
$"/reference/payment-types/{type["code"].ToString()}/edit",
Request.MethodPost,
new Dictionary
{
{ "paymentType", new JavaScriptSerializer().Serialize(type) }
}
);
}
///
/// Product statuses edit
///
///
///
public Response ProductStatusesEdit(Dictionary status)
{
if (!status.ContainsKey("code"))
{
throw new ArgumentException("Parameter `code` is missing");
}
if (!status.ContainsKey("name"))
{
throw new ArgumentException("Parameter `name` is missing");
}
return Request.MakeRequest(
$"/reference/product-statuses/{status["code"].ToString()}/edit",
Request.MethodPost,
new Dictionary
{
{ "productStatus", new JavaScriptSerializer().Serialize(status) }
}
);
}
///
/// Sites edit
///
///
///
public Response SitesEdit(Dictionary site)
{
if (!site.ContainsKey("code"))
{
throw new ArgumentException("Parameter `code` is missing");
}
if (!site.ContainsKey("name"))
{
throw new ArgumentException("Parameter `name` is missing");
}
if (!site.ContainsKey("url"))
{
throw new ArgumentException("Parameter `url` is missing");
}
return Request.MakeRequest(
$"/reference/sites/{site["code"].ToString()}/edit",
Request.MethodPost,
new Dictionary
{
{ "site", new JavaScriptSerializer().Serialize(site) }
}
);
}
///
/// Statuses edit
///
///
///
public Response StatusesEdit(Dictionary status)
{
if (!status.ContainsKey("code"))
{
throw new ArgumentException("Parameter `code` is missing");
}
if (!status.ContainsKey("name"))
{
throw new ArgumentException("Parameter `name` is missing");
}
if (!status.ContainsKey("ordering"))
{
throw new ArgumentException("Parameter `ordering` is missing");
}
if (!status.ContainsKey("group"))
{
throw new ArgumentException("Parameter `group` is missing");
}
return Request.MakeRequest(
$"/reference/statuses/{status["code"].ToString()}/edit",
Request.MethodPost,
new Dictionary
{
{ "status", new JavaScriptSerializer().Serialize(status) }
}
);
}
///
/// Stores edit
///
///
///
public Response StoresEdit(Dictionary store)
{
if (!store.ContainsKey("code"))
{
throw new ArgumentException("Parameter `code` is missing");
}
if (!store.ContainsKey("name"))
{
throw new ArgumentException("Parameter `name` is missing");
}
List types = new List
{
"store-type-online",
"store-type-retail",
"store-type-supplier",
"store-type-warehouse"
};
if (store.ContainsKey("type") && !types.Contains(store["type"].ToString()))
{
throw new ArgumentException("Parameter `type` should be equal to one of `store-type-online|store-type-retail|store-type-supplier|store-type-warehouse`");
}
return Request.MakeRequest(
$"/reference/stores/{store["code"].ToString()}/edit",
Request.MethodPost,
new Dictionary
{
{ "store", new JavaScriptSerializer().Serialize(store) }
}
);
}
}
}