using System; using System.Collections.Generic; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V4 { public partial class Client { /// /// Get delivery settings /// /// /// public Response DeliverySettingGet(string code) { if (string.IsNullOrEmpty(code)) { throw new ArgumentException("Parameter `code` is mandatory"); } return Request.MakeRequest( $"/delivery/generic/setting/{code}", Request.MethodGet ); } /// /// Edit delivery settings /// /// /// public Response DeliverySettingsEdit(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( $"/delivery/generic/setting/{configuration["code"].ToString()}/edit", Request.MethodPost, new Dictionary { { "configuration", new JavaScriptSerializer().Serialize(configuration) } } ); } /// /// Update delivery tracking /// /// /// /// public Response DeliveryTracking(string code, List statusUpdate) { if (string.IsNullOrEmpty(code)) { throw new ArgumentException("Parameter `code` is mandatory"); } if (statusUpdate.Count < 1) { throw new ArgumentException("Parameter `statusUpdate` must contain data"); } return Request.MakeRequest( $"delivery/generic/{code}/edit", Request.MethodPost, new Dictionary { { "statusUpdate", new JavaScriptSerializer().Serialize(statusUpdate) } } ); } } }