using System; using System.Collections.Generic; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V4 { public partial class Client { /// /// Get products /// /// /// /// /// public Response StoreProducts(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("/store/products", Request.MethodGet, parameters); } /// /// Upload prices /// /// /// public Response StorePricesUpload(List prices) { if (prices.Count< 1) { throw new ArgumentException("Parameter `prices` must contains a data"); } if (prices.Count > 250) { throw new ArgumentException("Parameter `prices` must contain 250 or less records"); } return Request.MakeRequest( "/store/prices/upload", Request.MethodPost, new Dictionary { { "prices", new JavaScriptSerializer().Serialize(prices) } } ); } /// /// Get store settings /// /// /// public Response StoreSettingGet(string code) { if (string.IsNullOrEmpty(code)) { throw new ArgumentException("Parameter `code` is mandatory"); } return Request.MakeRequest( $"/store/setting/{code}", Request.MethodGet ); } /// /// Edit store settings /// /// /// public Response StoreSettingsEdit(Dictionary configuration) { if (configuration.Count < 1) { throw new ArgumentException("Parameter `configuration` must contain data"); } if (!configuration.ContainsKey("clientId")) { throw new ArgumentException("Parameter `configuration` should contain `clientId`"); } if (!configuration.ContainsKey("baseUrl")) { throw new ArgumentException("Parameter `configuration` should contain `baseUrl`"); } if (!configuration.ContainsKey("code")) { throw new ArgumentException("Parameter `configuration` should contain `code`"); } if (!configuration.ContainsKey("name")) { throw new ArgumentException("Parameter `configuration` should contain `name`"); } return Request.MakeRequest( $"/store/setting/{configuration["code"].ToString()}/edit", Request.MethodPost, new Dictionary { { "configuration", new JavaScriptSerializer().Serialize(configuration) } } ); } } }