diff --git a/Retailcrm/Connection.cs b/Retailcrm/Connection.cs index db3540b..6eb61be 100644 --- a/Retailcrm/Connection.cs +++ b/Retailcrm/Connection.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading.Tasks; namespace Retailcrm { @@ -17,12 +18,8 @@ namespace Retailcrm public Connection(string url, string key) { if ("/" != url.Substring(url.Length - 1, 1)) - { url += "/"; - } - url += "api/"; - _request = new Request(url, new Dictionary { { "apiKey", key } }); } @@ -30,11 +27,11 @@ namespace Retailcrm /// Get available API versions /// /// - public Response Versions() + public Task Versions() { return _request.MakeRequest( "api-versions", - Request.MethodGet + System.Net.Http.HttpMethod.Get ); } @@ -42,11 +39,11 @@ namespace Retailcrm /// Get available API methods /// /// - public Response Credentials() + public Task Credentials() { return _request.MakeRequest( "credentials", - Request.MethodGet + System.Net.Http.HttpMethod.Get ); } } diff --git a/Retailcrm/Http2RequestHandler.cs b/Retailcrm/Http2RequestHandler.cs new file mode 100644 index 0000000..433f80b --- /dev/null +++ b/Retailcrm/Http2RequestHandler.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; + +namespace Retailcrm +{ + public class Http2CustomHandler : WinHttpHandler + { + protected override Task SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) + { + request.Version = new Version("2.0"); + return base.SendAsync(request, cancellationToken); + } + } +} diff --git a/Retailcrm/Request.cs b/Retailcrm/Request.cs index 7b7492a..5fe1c48 100644 --- a/Retailcrm/Request.cs +++ b/Retailcrm/Request.cs @@ -3,7 +3,9 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; +using System.Net.Http; using System.Text; +using System.Threading.Tasks; namespace Retailcrm { @@ -12,19 +14,16 @@ namespace Retailcrm /// public class Request { - /// - /// Get method - /// - public const string MethodGet = "GET"; - /// - /// Post method - /// - public const string MethodPost = "POST"; private const string UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; private const string ContentType = "application/x-www-form-urlencoded"; private readonly string _url; private readonly Dictionary _defaultParameters; + private static readonly HttpClient DefaultClient = new(new Http2CustomHandler + { + EnableMultipleHttp2Connections = true, + }); + private readonly HttpClient _httpClient; /// /// Request constructor @@ -33,12 +32,18 @@ namespace Retailcrm /// /// public Request(string apiUrl, Dictionary parameters = null) + : this(DefaultClient, apiUrl, parameters) + { + + } + + public Request(HttpClient client, string apiUrl, Dictionary parameters = null) { if (apiUrl.IndexOf("https://", StringComparison.Ordinal) == -1) { throw new ArgumentException("API schema requires HTTPS protocol"); } - + _httpClient = client; _url = apiUrl; _defaultParameters = parameters; } @@ -52,69 +57,30 @@ namespace Retailcrm /// /// /// - public Response MakeRequest(string path, string method, Dictionary parameters = null) + public async Task MakeRequest(string path, HttpMethod method, Dictionary parameters = null) { - string[] allowedMethods = { MethodGet, MethodPost }; - - if (allowedMethods.Contains(method) == false) - { - throw new ArgumentException($"Method {method} is not valid. Allowed HTTP methods are {string.Join(", ", allowedMethods)}"); - } - - if (parameters == null) - { - parameters = new Dictionary(); - } + if (method != HttpMethod.Get && method != HttpMethod.Post) + throw new ArgumentException($"Method {method} is not valid. Allowed HTTP methods are GET and POST"); + parameters ??= []; parameters = _defaultParameters.Union(parameters).ToDictionary(k => k.Key, v => v.Value); path = _url + path; - string httpQuery = QueryBuilder.BuildQueryString(parameters); - - if (method.Equals(MethodGet) && parameters.Count > 0) - { + if (method == HttpMethod.Get && parameters.Count > 0) path += "?" + httpQuery; - } - - Exception exception = null; - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(path); - request.Method = method; - - if (method.Equals(MethodPost)) + using var httpRequest = new HttpRequestMessage(method, path); + using var content = new StringContent(httpQuery); + if (method == HttpMethod.Post) { - UTF8Encoding encoding = new UTF8Encoding(); - byte[] bytes = encoding.GetBytes(httpQuery); - request.ContentLength = bytes.Length; - request.ContentType = ContentType; - request.UserAgent = UserAgent; - - Stream post = request.GetRequestStream(); - post.Write(bytes, 0, bytes.Length); - post.Flush(); - post.Close(); + httpRequest.Content = content; + httpRequest.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(ContentType); + httpRequest.Headers.UserAgent.ParseAdd(UserAgent); } - HttpWebResponse response; - - try - { - response = (HttpWebResponse)request.GetResponse(); - } - catch (WebException webException) - { - response = (HttpWebResponse)webException.Response; - exception = webException; - } - - if (request == null || response == null) - { - throw new WebException(exception.ToString(), exception); - } - - StreamReader reader = new StreamReader(response.GetResponseStream()); + using var response = await _httpClient.SendAsync(httpRequest); + using StreamReader reader = new(await response.Content.ReadAsStreamAsync()); string responseBody = reader.ReadToEnd(); int statusCode = (int)response.StatusCode; - return new Response(statusCode, responseBody); } } diff --git a/Retailcrm/Retailcrm.csproj b/Retailcrm/Retailcrm.csproj index 2e23b14..33f276b 100644 --- a/Retailcrm/Retailcrm.csproj +++ b/Retailcrm/Retailcrm.csproj @@ -9,8 +9,10 @@ Properties Retailcrm Retailcrm - v4.5 + v4.6.2 512 + + latest true @@ -32,7 +34,24 @@ + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + ..\packages\System.Net.Http.WinHttpHandler.9.0.0\lib\net462\System.Net.Http.WinHttpHandler.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + @@ -41,6 +60,7 @@ + @@ -78,6 +98,7 @@ + diff --git a/Retailcrm/Retailcrm.nuspec b/Retailcrm/Retailcrm.nuspec index b96a331..3512ccd 100644 --- a/Retailcrm/Retailcrm.nuspec +++ b/Retailcrm/Retailcrm.nuspec @@ -1,18 +1,21 @@ - - Retailcrm.SDK - 5.1.3 - $title$ - RetailCRM - RetailCRM - MIT - https://github.com/retailcrmapi-client-dotnet - https://s3-s1.retailcrm.tech/eu-central-1/retailcrm-static/branding/retailcrm/favicon/favicon.ico - false - Multiversion API client for RetailCRM - Rebranding - Copyright 2017-2020 - crm ecommerce retailcrm sdk - + + Retailcrm.SDK + 5.2.0 + $title$ + RetailCRM + RetailCRM + MIT + https://github.com/retailcrmapi-client-dotnet + https://s3-s1.retailcrm.tech/eu-central-1/retailcrm-static/branding/retailcrm/favicon/favicon.ico + false + Multiversion API client for RetailCRM + Move to async and Http 2.0 + Copyright 2017-2024 + crm ecommerce retailcrm sdk + + + + \ No newline at end of file diff --git a/Retailcrm/Versions/V3/Customers.cs b/Retailcrm/Versions/V3/Customers.cs index 3204bf8..c33ed7b 100644 --- a/Retailcrm/Versions/V3/Customers.cs +++ b/Retailcrm/Versions/V3/Customers.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V3 @@ -13,7 +14,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response CustomersCreate(Dictionary customer, string site = "") + public Task CustomersCreate(Dictionary customer, string site = "") { if (customer.Count < 1) { @@ -22,7 +23,7 @@ namespace Retailcrm.Versions.V3 return Request.MakeRequest( "/customers/create", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, FillSite( site, new Dictionary @@ -41,7 +42,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response CustomersUpdate(Dictionary customer, string by = "externalId", string site = "") + public Task CustomersUpdate(Dictionary customer, string by = "externalId", string site = "") { if (customer.Count < 1) { @@ -59,7 +60,7 @@ namespace Retailcrm.Versions.V3 return Request.MakeRequest( $"/customers/{uid}/edit", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, FillSite( site, new Dictionary @@ -78,13 +79,13 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response CustomersGet(string id, string by = "externalId", string site = "") + public Task CustomersGet(string id, string by = "externalId", string site = "") { CheckIdParameter(by); return Request.MakeRequest( $"/customers/{id}", - Request.MethodGet, + System.Net.Http.HttpMethod.Get, FillSite( site, new Dictionary @@ -102,26 +103,18 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response CustomersList(Dictionary filter = null, int page = 1, int limit = 20) + public Task CustomersList(Dictionary filter = null, int page = 1, int limit = 20) { - Dictionary parameters = new Dictionary(); + Dictionary parameters = []; if (filter != null && filter.Count > 0) - { - parameters.Add("filter", filter); - } + parameters.Add("filter", filter); if (page > 0) - { parameters.Add("page", page); - } - if (limit > 0) - { parameters.Add("limit", limit); - } - - return Request.MakeRequest("/customers", Request.MethodGet, parameters); + return Request.MakeRequest("/customers", System.Net.Http.HttpMethod.Get, parameters); } /// @@ -129,11 +122,11 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response CustomersFixExternalIds(Dictionary[] ids) + public Task CustomersFixExternalIds(Dictionary[] ids) { return Request.MakeRequest( "/customers/fix-external-ids", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, new Dictionary { { "customers", new JavaScriptSerializer().Serialize(ids) } @@ -148,21 +141,15 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response CustomersUpload(List customers, string site = "") + public Task CustomersUpload(List customers, string site = "") { if (customers.Count < 1) - { throw new ArgumentException("Parameter `customers` must contains a data"); - } - if (customers.Count > 50) - { throw new ArgumentException("Parameter `customers` must contain 50 or less records"); - } - return Request.MakeRequest( "/customers/upload", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, FillSite( site, new Dictionary diff --git a/Retailcrm/Versions/V3/Orders.cs b/Retailcrm/Versions/V3/Orders.cs index 8630e73..0dcdb6e 100644 --- a/Retailcrm/Versions/V3/Orders.cs +++ b/Retailcrm/Versions/V3/Orders.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V3 @@ -12,7 +13,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response OrdersCreate(Dictionary order, string site = "") + public Task OrdersCreate(Dictionary order, string site = "") { if (order.Count < 1) { @@ -21,7 +22,7 @@ namespace Retailcrm.Versions.V3 return Request.MakeRequest( "/orders/create", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, FillSite( site, new Dictionary @@ -39,7 +40,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response OrdersUpdate(Dictionary order, string by = "externalId", string site = "") + public Task OrdersUpdate(Dictionary order, string by = "externalId", string site = "") { if (order.Count < 1) { @@ -57,7 +58,7 @@ namespace Retailcrm.Versions.V3 return Request.MakeRequest( $"/orders/{uid}/edit", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, FillSite( site, new Dictionary @@ -76,13 +77,13 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response OrdersGet(string id, string by = "externalId", string site = "") + public Task OrdersGet(string id, string by = "externalId", string site = "") { CheckIdParameter(by); return Request.MakeRequest( $"/orders/{id}", - Request.MethodGet, + System.Net.Http.HttpMethod.Get, FillSite( site, new Dictionary @@ -100,7 +101,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response OrdersList(Dictionary filter = null, int page = 1, int limit = 20) + public Task OrdersList(Dictionary filter = null, int page = 1, int limit = 20) { Dictionary parameters = new Dictionary(); @@ -119,7 +120,7 @@ namespace Retailcrm.Versions.V3 parameters.Add("limit", limit); } - return Request.MakeRequest("/orders", Request.MethodGet, parameters); + return Request.MakeRequest("/orders", System.Net.Http.HttpMethod.Get, parameters); } /// @@ -127,11 +128,11 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response OrdersFixExternalIds(Dictionary[] ids) + public Task OrdersFixExternalIds(Dictionary[] ids) { return Request.MakeRequest( "/orders/fix-external-ids", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, new Dictionary { { "orders", new JavaScriptSerializer().Serialize(ids) } @@ -148,9 +149,9 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response OrdersHistory(DateTime? startDate = null, DateTime? endDate = null, int limit = 200, int offset = 0, bool skipMyChanges = true) + public Task OrdersHistory(DateTime? startDate = null, DateTime? endDate = null, int limit = 200, int offset = 0, bool skipMyChanges = true) { - Dictionary parameters = new Dictionary(); + Dictionary parameters = []; if (startDate != null) { @@ -176,7 +177,7 @@ namespace Retailcrm.Versions.V3 return Request.MakeRequest( "/orders/history", - Request.MethodGet, + System.Net.Http.HttpMethod.Get, parameters ); } @@ -187,9 +188,9 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response OrdersStatuses(List ids, List externalIds = null) + public Task OrdersStatuses(List ids, List externalIds = null) { - Dictionary parameters = new Dictionary(); + Dictionary parameters = []; if (ids == null && externalIds == null) { @@ -217,7 +218,7 @@ namespace Retailcrm.Versions.V3 return Request.MakeRequest( "/orders/statuses", - Request.MethodGet, + System.Net.Http.HttpMethod.Get, parameters ); } @@ -228,7 +229,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response OrdersUpload(List orders, string site = "") + public Task OrdersUpload(List orders, string site = "") { if (orders.Count < 1) { @@ -242,7 +243,7 @@ namespace Retailcrm.Versions.V3 return Request.MakeRequest( "/orders/upload", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, FillSite( site, new Dictionary diff --git a/Retailcrm/Versions/V3/Packs.cs b/Retailcrm/Versions/V3/Packs.cs index 44ecb80..4e15d0f 100644 --- a/Retailcrm/Versions/V3/Packs.cs +++ b/Retailcrm/Versions/V3/Packs.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V3 @@ -13,9 +15,9 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response PacksList(Dictionary filter = null, int page = 1, int limit = 20) + public Task PacksList(Dictionary filter = null, int page = 1, int limit = 20) { - Dictionary parameters = new Dictionary(); + Dictionary parameters = []; if (filter != null && filter.Count > 0) { @@ -32,7 +34,7 @@ namespace Retailcrm.Versions.V3 parameters.Add("limit", limit); } - return Request.MakeRequest("/orders/packs", Request.MethodGet, parameters); + return Request.MakeRequest("/orders/packs", System.Net.Http.HttpMethod.Get, parameters); } /// @@ -40,7 +42,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response PacksCreate(Dictionary pack) + public Task PacksCreate(Dictionary pack) { if (pack.Count < 1) { @@ -49,7 +51,7 @@ namespace Retailcrm.Versions.V3 return Request.MakeRequest( "/orders/packs/create", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, new Dictionary { { "pack", new JavaScriptSerializer().Serialize(pack) } @@ -62,7 +64,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response PacksUpdate(Dictionary pack) + public Task PacksUpdate(Dictionary pack) { if (pack.Count < 1) { @@ -75,8 +77,8 @@ namespace Retailcrm.Versions.V3 } return Request.MakeRequest( - $"/orders/packs/{pack["id"].ToString()}/edit", - Request.MethodPost, + $"/orders/packs/{pack["id"]}/edit", + HttpMethod.Post, new Dictionary { { "pack", new JavaScriptSerializer().Serialize(pack) } @@ -89,11 +91,11 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response PacksDelete(string id) + public Task PacksDelete(string id) { return Request.MakeRequest( $"/orders/packs/{id}/delete", - Request.MethodPost + HttpMethod.Post ); } @@ -102,11 +104,11 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response PacksGet(string id) + public Task PacksGet(string id) { return Request.MakeRequest( $"/orders/packs/{id}", - Request.MethodGet + HttpMethod.Get ); } @@ -117,7 +119,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response PacksHistory(Dictionary filter = null, int page = 1, int limit = 20) + public Task PacksHistory(Dictionary filter = null, int page = 1, int limit = 20) { Dictionary parameters = new Dictionary(); @@ -136,7 +138,7 @@ namespace Retailcrm.Versions.V3 parameters.Add("limit", limit); } - return Request.MakeRequest("/orders/packs/history", Request.MethodGet, parameters); + return Request.MakeRequest("/orders/packs/history", HttpMethod.Get, parameters); } } } diff --git a/Retailcrm/Versions/V3/References.cs b/Retailcrm/Versions/V3/References.cs index 8aa8b71..e0ed14a 100644 --- a/Retailcrm/Versions/V3/References.cs +++ b/Retailcrm/Versions/V3/References.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V3 @@ -10,11 +12,11 @@ namespace Retailcrm.Versions.V3 /// Countries /// /// - public Response Countries() + public Task Countries() { return Request.MakeRequest( "/reference/countries", - Request.MethodGet + HttpMethod.Get ); } @@ -22,11 +24,11 @@ namespace Retailcrm.Versions.V3 /// Delivery services /// /// - public Response DeliveryServices() + public Task DeliveryServices() { return Request.MakeRequest( "/reference/delivery-services", - Request.MethodGet + HttpMethod.Get ); } @@ -34,11 +36,11 @@ namespace Retailcrm.Versions.V3 /// Delivery types /// /// - public Response DeliveryTypes() + public Task DeliveryTypes() { return Request.MakeRequest( "/reference/delivery-types", - Request.MethodGet + HttpMethod.Get ); } @@ -46,11 +48,11 @@ namespace Retailcrm.Versions.V3 /// Order methods /// /// - public Response OrderMethods() + public Task OrderMethods() { return Request.MakeRequest( "/reference/order-methods", - Request.MethodGet + HttpMethod.Get ); } @@ -58,11 +60,11 @@ namespace Retailcrm.Versions.V3 /// Order types /// /// - public Response OrderTypes() + public Task OrderTypes() { return Request.MakeRequest( "/reference/order-types", - Request.MethodGet + HttpMethod.Get ); } @@ -70,84 +72,63 @@ namespace Retailcrm.Versions.V3 /// Payment statuses /// /// - public Response PaymentStatuses() + public Task PaymentStatuses() { - return Request.MakeRequest( - "/reference/payment-statuses", - Request.MethodGet - ); + return Request.MakeRequest("/reference/payment-statuses", HttpMethod.Get); } /// /// Payment types /// /// - public Response PaymentTypes() + public Task PaymentTypes() { - return Request.MakeRequest( - "/reference/payment-types", - Request.MethodGet - ); + return Request.MakeRequest("/reference/payment-types", HttpMethod.Get); } /// /// Product statuses /// /// - public Response ProductStatuses() + public Task ProductStatuses() { - return Request.MakeRequest( - "/reference/product-statuses", - Request.MethodGet - ); + return Request.MakeRequest("/reference/product-statuses", HttpMethod.Get); } /// /// Sites /// /// - public Response Sites() + public Task Sites() { - return Request.MakeRequest( - "/reference/sites", - Request.MethodGet - ); + return Request.MakeRequest("/reference/sites", HttpMethod.Get); } /// /// Statuses groups /// /// - public Response StatusGroups() + public Task StatusGroups() { - return Request.MakeRequest( - "/reference/status-groups", - Request.MethodGet - ); + return Request.MakeRequest("/reference/status-groups", HttpMethod.Get); } /// /// Statuses /// /// - public Response Statuses() + public Task Statuses() { - return Request.MakeRequest( - "/reference/statuses", - Request.MethodGet - ); + return Request.MakeRequest("/reference/statuses", HttpMethod.Get); } /// /// Stores /// /// - public Response Stores() + public Task Stores() { - return Request.MakeRequest( - "/reference/stores", - Request.MethodGet - ); + return Request.MakeRequest("/reference/stores", HttpMethod.Get); } /// @@ -155,7 +136,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response DeliveryServicesEdit(Dictionary service) + public Task DeliveryServicesEdit(Dictionary service) { if (!service.ContainsKey("code")) { @@ -168,8 +149,8 @@ namespace Retailcrm.Versions.V3 } return Request.MakeRequest( - $"/reference/delivery-services/{service["code"].ToString()}/edit", - Request.MethodPost, + $"/reference/delivery-services/{service["code"]}/edit", + HttpMethod.Post, new Dictionary { { "deliveryService", new JavaScriptSerializer().Serialize(service) } @@ -182,7 +163,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response DeliveryTypesEdit(Dictionary type) + public Task DeliveryTypesEdit(Dictionary type) { if (!type.ContainsKey("code")) { @@ -205,8 +186,8 @@ namespace Retailcrm.Versions.V3 } return Request.MakeRequest( - $"/reference/delivery-types/{type["code"].ToString()}/edit", - Request.MethodPost, + $"/reference/delivery-types/{type["code"]}/edit", + HttpMethod.Post, new Dictionary { { "deliveryType", new JavaScriptSerializer().Serialize(type) } @@ -219,7 +200,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response OrderMethodsEdit(Dictionary method) + public Task OrderMethodsEdit(Dictionary method) { if (!method.ContainsKey("code")) { @@ -232,8 +213,8 @@ namespace Retailcrm.Versions.V3 } return Request.MakeRequest( - $"/reference/order-methods/{method["code"].ToString()}/edit", - Request.MethodPost, + $"/reference/order-methods/{method["code"]}/edit", + HttpMethod.Post, new Dictionary { { "orderMethod", new JavaScriptSerializer().Serialize(method) } @@ -246,7 +227,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response OrderTypesEdit(Dictionary type) + public Task OrderTypesEdit(Dictionary type) { if (!type.ContainsKey("code")) { @@ -259,8 +240,8 @@ namespace Retailcrm.Versions.V3 } return Request.MakeRequest( - $"/reference/order-types/{type["code"].ToString()}/edit", - Request.MethodPost, + $"/reference/order-types/{type["code"]}/edit", + HttpMethod.Post, new Dictionary { { "orderType", new JavaScriptSerializer().Serialize(type) } @@ -273,7 +254,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response PaymentStatusesEdit(Dictionary status) + public Task PaymentStatusesEdit(Dictionary status) { if (!status.ContainsKey("code")) { @@ -286,8 +267,8 @@ namespace Retailcrm.Versions.V3 } return Request.MakeRequest( - $"/reference/payment-statuses/{status["code"].ToString()}/edit", - Request.MethodPost, + $"/reference/payment-statuses/{status["code"]}/edit", + HttpMethod.Post, new Dictionary { { "paymentStatus", new JavaScriptSerializer().Serialize(status) } @@ -300,7 +281,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response PaymentTypesEdit(Dictionary type) + public Task PaymentTypesEdit(Dictionary type) { if (!type.ContainsKey("code")) { @@ -313,8 +294,8 @@ namespace Retailcrm.Versions.V3 } return Request.MakeRequest( - $"/reference/payment-types/{type["code"].ToString()}/edit", - Request.MethodPost, + $"/reference/payment-types/{type["code"]}/edit", + HttpMethod.Post, new Dictionary { { "paymentType", new JavaScriptSerializer().Serialize(type) } @@ -327,7 +308,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response ProductStatusesEdit(Dictionary status) + public Task ProductStatusesEdit(Dictionary status) { if (!status.ContainsKey("code")) { @@ -340,8 +321,8 @@ namespace Retailcrm.Versions.V3 } return Request.MakeRequest( - $"/reference/product-statuses/{status["code"].ToString()}/edit", - Request.MethodPost, + $"/reference/product-statuses/{status["code"]}/edit", + HttpMethod.Post, new Dictionary { { "productStatus", new JavaScriptSerializer().Serialize(status) } @@ -354,7 +335,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response SitesEdit(Dictionary site) + public Task SitesEdit(Dictionary site) { if (!site.ContainsKey("code")) { @@ -372,8 +353,8 @@ namespace Retailcrm.Versions.V3 } return Request.MakeRequest( - $"/reference/sites/{site["code"].ToString()}/edit", - Request.MethodPost, + $"/reference/sites/{site["code"]}/edit", + HttpMethod.Post, new Dictionary { { "site", new JavaScriptSerializer().Serialize(site) } @@ -386,7 +367,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response StatusesEdit(Dictionary status) + public Task StatusesEdit(Dictionary status) { if (!status.ContainsKey("code")) { @@ -409,8 +390,8 @@ namespace Retailcrm.Versions.V3 } return Request.MakeRequest( - $"/reference/statuses/{status["code"].ToString()}/edit", - Request.MethodPost, + $"/reference/statuses/{status["code"]}/edit", + HttpMethod.Post, new Dictionary { { "status", new JavaScriptSerializer().Serialize(status) } @@ -423,7 +404,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response StoresEdit(Dictionary store) + public Task StoresEdit(Dictionary store) { if (!store.ContainsKey("code")) { @@ -435,13 +416,13 @@ namespace Retailcrm.Versions.V3 throw new ArgumentException("Parameter `name` is missing"); } - List types = new List - { + List types = + [ "store-type-online", "store-type-retail", "store-type-supplier", "store-type-warehouse" - }; + ]; if (store.ContainsKey("type") && !types.Contains(store["type"].ToString())) { @@ -449,8 +430,8 @@ namespace Retailcrm.Versions.V3 } return Request.MakeRequest( - $"/reference/stores/{store["code"].ToString()}/edit", - Request.MethodPost, + $"/reference/stores/{store["code"]}/edit", + HttpMethod.Post, new Dictionary { { "store", new JavaScriptSerializer().Serialize(store) } diff --git a/Retailcrm/Versions/V3/Statistic.cs b/Retailcrm/Versions/V3/Statistic.cs index fbb93f2..43356f9 100644 --- a/Retailcrm/Versions/V3/Statistic.cs +++ b/Retailcrm/Versions/V3/Statistic.cs @@ -1,4 +1,6 @@ -namespace Retailcrm.Versions.V3 +using System.Threading.Tasks; + +namespace Retailcrm.Versions.V3 { public partial class Client { @@ -6,11 +8,11 @@ /// Update statistic /// /// - public Response StatisticUpdate() + public Task StatisticUpdate() { return Request.MakeRequest( "/statistic/update", - Request.MethodGet + System.Net.Http.HttpMethod.Get ); } } diff --git a/Retailcrm/Versions/V3/Stores.cs b/Retailcrm/Versions/V3/Stores.cs index 536ccc9..ed21460 100644 --- a/Retailcrm/Versions/V3/Stores.cs +++ b/Retailcrm/Versions/V3/Stores.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V3 @@ -13,9 +14,9 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response StoreInventoriesGet(Dictionary filter = null, int page = 1, int limit = 20) + public Task StoreInventoriesGet(Dictionary filter = null, int page = 1, int limit = 20) { - Dictionary parameters = new Dictionary(); + Dictionary parameters = []; if (filter != null && filter.Count > 0) { @@ -32,7 +33,7 @@ namespace Retailcrm.Versions.V3 parameters.Add("limit", limit); } - return Request.MakeRequest("/store/inventories", Request.MethodGet, parameters); + return Request.MakeRequest("/store/inventories", System.Net.Http.HttpMethod.Get, parameters); } /// @@ -41,7 +42,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response StoreInventoriesUpload(List offers, string site = "") + public Task StoreInventoriesUpload(List offers, string site = "") { if (offers.Count< 1) { @@ -55,7 +56,7 @@ namespace Retailcrm.Versions.V3 return Request.MakeRequest( "/store/inventories/upload", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, FillSite( site, new Dictionary diff --git a/Retailcrm/Versions/V3/Telephony.cs b/Retailcrm/Versions/V3/Telephony.cs index 330ad95..ab0ff86 100644 --- a/Retailcrm/Versions/V3/Telephony.cs +++ b/Retailcrm/Versions/V3/Telephony.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V3 @@ -12,9 +13,9 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response TelephonyManagerGet(string phone, string details = "1") + public Task TelephonyManagerGet(string phone, string details = "1") { - Dictionary parameters = new Dictionary(); + Dictionary parameters = []; if (string.IsNullOrEmpty(phone)) { @@ -24,7 +25,7 @@ namespace Retailcrm.Versions.V3 parameters.Add("details", details); parameters.Add("phone", phone); - return Request.MakeRequest("/telephony/manager", Request.MethodGet, parameters); + return Request.MakeRequest("/telephony/manager", System.Net.Http.HttpMethod.Get, parameters); } /// @@ -35,7 +36,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response TelephonyCallEvent(string phone, string type, string status, string code) + public Task TelephonyCallEvent(string phone, string type, string status, string code) { if (string.IsNullOrEmpty(phone)) { @@ -47,8 +48,8 @@ namespace Retailcrm.Versions.V3 throw new ArgumentException("Parameter `phone` must contains a data"); } - List statuses = new List { "answered", "busy", "cancel", "failed", "no answered" }; - List types = new List { "hangup", "in", "out" }; + List statuses = ["answered", "busy", "cancel", "failed", "no answered"]; + List types = ["hangup", "in", "out"]; if (!statuses.Contains(status)) { @@ -62,7 +63,7 @@ namespace Retailcrm.Versions.V3 return Request.MakeRequest( "/telephony/call/event", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, new Dictionary { { "phone", phone }, @@ -78,7 +79,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response TelephonyCallsUpload(List calls) + public Task TelephonyCallsUpload(List calls) { if (calls.Count < 1) { @@ -92,7 +93,7 @@ namespace Retailcrm.Versions.V3 return Request.MakeRequest( "/telephony/calls/upload", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, new Dictionary { { "calls", new JavaScriptSerializer().Serialize(calls) } @@ -110,7 +111,7 @@ namespace Retailcrm.Versions.V3 /// /// /// - public Response TelephonySettingsEdit(string code, string clientId, string url, string name, string logo, string active = "true") + public Task TelephonySettingsEdit(string code, string clientId, string url, string name, string logo, string active = "true") { if (string.IsNullOrEmpty(name)) { @@ -134,7 +135,7 @@ namespace Retailcrm.Versions.V3 return Request.MakeRequest( $"/telephony/setting/{code}", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, new Dictionary { { "code", code }, diff --git a/Retailcrm/Versions/V4/Customers.cs b/Retailcrm/Versions/V4/Customers.cs index ce63f78..03dd117 100644 --- a/Retailcrm/Versions/V4/Customers.cs +++ b/Retailcrm/Versions/V4/Customers.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading.Tasks; namespace Retailcrm.Versions.V4 { @@ -11,7 +12,7 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response CustomersHistory(Dictionary filter = null, int page = 1, int limit = 20) + public Task CustomersHistory(Dictionary filter = null, int page = 1, int limit = 20) { Dictionary parameters = new Dictionary(); @@ -30,7 +31,7 @@ namespace Retailcrm.Versions.V4 parameters.Add("limit", limit); } - return Request.MakeRequest("/customers/history", Request.MethodGet, parameters); + return Request.MakeRequest("/customers/history", System.Net.Http.HttpMethod.Get, parameters); } } } diff --git a/Retailcrm/Versions/V4/Delivery.cs b/Retailcrm/Versions/V4/Delivery.cs index c33774b..d1e844f 100644 --- a/Retailcrm/Versions/V4/Delivery.cs +++ b/Retailcrm/Versions/V4/Delivery.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V4 @@ -11,7 +13,7 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response DeliverySettingGet(string code) + public Task DeliverySettingGet(string code) { if (string.IsNullOrEmpty(code)) { @@ -20,7 +22,7 @@ namespace Retailcrm.Versions.V4 return Request.MakeRequest( $"/delivery/generic/setting/{code}", - Request.MethodGet + HttpMethod.Get ); } @@ -29,7 +31,7 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response DeliverySettingsEdit(Dictionary configuration) + public Task DeliverySettingsEdit(Dictionary configuration) { if (configuration.Count < 1) { @@ -57,8 +59,8 @@ namespace Retailcrm.Versions.V4 } return Request.MakeRequest( - $"/delivery/generic/setting/{configuration["code"].ToString()}/edit", - Request.MethodPost, + $"/delivery/generic/setting/{configuration["code"]}/edit", + HttpMethod.Post, new Dictionary { { "configuration", new JavaScriptSerializer().Serialize(configuration) } @@ -72,7 +74,7 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response DeliveryTracking(string code, List statusUpdate) + public Task DeliveryTracking(string code, List statusUpdate) { if (string.IsNullOrEmpty(code)) { @@ -86,7 +88,7 @@ namespace Retailcrm.Versions.V4 return Request.MakeRequest( $"delivery/generic/{code}/edit", - Request.MethodPost, + HttpMethod.Post, new Dictionary { { "statusUpdate", new JavaScriptSerializer().Serialize(statusUpdate) } diff --git a/Retailcrm/Versions/V4/Marketplace.cs b/Retailcrm/Versions/V4/Marketplace.cs index 9e13f7c..57bb3b2 100644 --- a/Retailcrm/Versions/V4/Marketplace.cs +++ b/Retailcrm/Versions/V4/Marketplace.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V4 @@ -11,7 +12,7 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response MarketplaceSettingsEdit(Dictionary configuration) + public Task MarketplaceSettingsEdit(Dictionary configuration) { if (configuration.Count < 1) { @@ -29,8 +30,8 @@ namespace Retailcrm.Versions.V4 } return Request.MakeRequest( - $"/marketplace/external/setting/{configuration["code"].ToString()}/edit", - Request.MethodPost, + $"/marketplace/external/setting/{configuration["code"]}/edit", + System.Net.Http.HttpMethod.Post, new Dictionary { { "configuration", new JavaScriptSerializer().Serialize(configuration) } diff --git a/Retailcrm/Versions/V4/Orders.cs b/Retailcrm/Versions/V4/Orders.cs index 36008fd..58b0723 100644 --- a/Retailcrm/Versions/V4/Orders.cs +++ b/Retailcrm/Versions/V4/Orders.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; namespace Retailcrm.Versions.V4 { @@ -11,7 +13,7 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response OrdersHistory(Dictionary filter = null, int page = 1, int limit = 20) + public Task OrdersHistory(Dictionary filter = null, int page = 1, int limit = 20) { Dictionary parameters = new Dictionary(); @@ -30,7 +32,7 @@ namespace Retailcrm.Versions.V4 parameters.Add("limit", limit); } - return Request.MakeRequest("/orders/history", Request.MethodGet, parameters); + return Request.MakeRequest("/orders/history", HttpMethod.Get, parameters); } } } diff --git a/Retailcrm/Versions/V4/References.cs b/Retailcrm/Versions/V4/References.cs index f9a9a26..8dbcf6a 100644 --- a/Retailcrm/Versions/V4/References.cs +++ b/Retailcrm/Versions/V4/References.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V4 @@ -10,11 +12,11 @@ namespace Retailcrm.Versions.V4 /// Price types /// /// - public Response PriceTypes() + public Task PriceTypes() { return Request.MakeRequest( "/reference/price-types", - Request.MethodGet + HttpMethod.Get ); } @@ -23,7 +25,7 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response PriceTypesEdit(Dictionary type) + public Task PriceTypesEdit(Dictionary type) { if (!type.ContainsKey("code")) { @@ -36,8 +38,8 @@ namespace Retailcrm.Versions.V4 } return Request.MakeRequest( - $"/reference/price-types/{type["code"].ToString()}/edit", - Request.MethodPost, + $"/reference/price-types/{type["code"]}/edit", + HttpMethod.Post, new Dictionary { { "priceType", new JavaScriptSerializer().Serialize(type) } diff --git a/Retailcrm/Versions/V4/Stores.cs b/Retailcrm/Versions/V4/Stores.cs index 80069f6..c9fdbdd 100644 --- a/Retailcrm/Versions/V4/Stores.cs +++ b/Retailcrm/Versions/V4/Stores.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V4 @@ -13,26 +15,16 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response StoreProducts(Dictionary filter = null, int page = 1, int limit = 20) + public Task StoreProducts(Dictionary filter = null, int page = 1, int limit = 20) { - Dictionary parameters = new Dictionary(); - + Dictionary parameters = []; 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); + return Request.MakeRequest("/store/products", HttpMethod.Get, parameters); } /// @@ -40,21 +32,15 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response StorePricesUpload(List prices) + public Task 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, + HttpMethod.Post, new Dictionary { { "prices", new JavaScriptSerializer().Serialize(prices) } @@ -67,16 +53,13 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response StoreSettingGet(string code) + public Task StoreSettingGet(string code) { if (string.IsNullOrEmpty(code)) - { throw new ArgumentException("Parameter `code` is mandatory"); - } - return Request.MakeRequest( $"/store/setting/{code}", - Request.MethodGet + HttpMethod.Get ); } @@ -85,7 +68,7 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response StoreSettingsEdit(Dictionary configuration) + public Task StoreSettingsEdit(Dictionary configuration) { if (configuration.Count < 1) { @@ -113,8 +96,8 @@ namespace Retailcrm.Versions.V4 } return Request.MakeRequest( - $"/store/setting/{configuration["code"].ToString()}/edit", - Request.MethodPost, + $"/store/setting/{configuration["code"]}/edit", + HttpMethod.Post, new Dictionary { { "configuration", new JavaScriptSerializer().Serialize(configuration) } diff --git a/Retailcrm/Versions/V4/Telephony.cs b/Retailcrm/Versions/V4/Telephony.cs index 25f176f..98ea281 100644 --- a/Retailcrm/Versions/V4/Telephony.cs +++ b/Retailcrm/Versions/V4/Telephony.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V4 @@ -11,7 +13,7 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response TelephonyCallEvent(Dictionary ievent) + public Task TelephonyCallEvent(Dictionary ievent) { if (ievent.Count < 1) { @@ -33,8 +35,8 @@ namespace Retailcrm.Versions.V4 throw new ArgumentException("Parameter `hangupStatus` must contains a data"); } - List statuses = new List { "answered", "busy", "cancel", "failed", "no answered" }; - List types = new List { "hangup", "in", "out" }; + List statuses = ["answered", "busy", "cancel", "failed", "no answered"]; + List types = ["hangup", "in", "out"]; if (!statuses.Contains(ievent["hangupStatus"].ToString())) { @@ -48,7 +50,7 @@ namespace Retailcrm.Versions.V4 return Request.MakeRequest( "/telephony/call/event", - Request.MethodPost, + HttpMethod.Post, new Dictionary { { "event", new JavaScriptSerializer().Serialize(ievent) } @@ -61,14 +63,14 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response TelephonySettingsGet(string code) + public Task TelephonySettingsGet(string code) { if (string.IsNullOrEmpty(code)) { throw new ArgumentException("Parameter `code` should contain data"); } - return Request.MakeRequest($"/telephony/setting/{code}", Request.MethodGet); + return Request.MakeRequest($"/telephony/setting/{code}", HttpMethod.Get); } /// @@ -76,7 +78,7 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response TelephonySettingsEdit(Dictionary configuration) + public Task TelephonySettingsEdit(Dictionary configuration) { if (configuration.Count < 1) { @@ -104,8 +106,8 @@ namespace Retailcrm.Versions.V4 } return Request.MakeRequest( - $"/telephony/setting/{configuration["code"].ToString()}/edit", - Request.MethodPost, + $"/telephony/setting/{configuration["code"]}/edit", + HttpMethod.Post, new Dictionary { { "configuration", new JavaScriptSerializer().Serialize(configuration) } diff --git a/Retailcrm/Versions/V4/Users.cs b/Retailcrm/Versions/V4/Users.cs index 82b778e..bdf2790 100644 --- a/Retailcrm/Versions/V4/Users.cs +++ b/Retailcrm/Versions/V4/Users.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; namespace Retailcrm.Versions.V4 { @@ -11,9 +13,9 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response Users(Dictionary filter = null, int page = 0, int limit = 0) + public Task Users(Dictionary filter = null, int page = 0, int limit = 0) { - Dictionary parameters = new Dictionary(); + Dictionary parameters = []; if (filter != null && filter.Count > 0) { @@ -30,7 +32,7 @@ namespace Retailcrm.Versions.V4 parameters.Add("limit", limit); } - return Request.MakeRequest("/users", Request.MethodGet, parameters); + return Request.MakeRequest("/users", HttpMethod.Get, parameters); } /// @@ -39,9 +41,9 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response UsersGroups(int page = 1, int limit = 20) + public Task UsersGroups(int page = 1, int limit = 20) { - Dictionary parameters = new Dictionary(); + Dictionary parameters = []; if (page > 0) { @@ -53,7 +55,7 @@ namespace Retailcrm.Versions.V4 parameters.Add("limit", limit); } - return Request.MakeRequest("/user-groups", Request.MethodGet, parameters); + return Request.MakeRequest("/user-groups", HttpMethod.Get, parameters); } /// @@ -61,9 +63,9 @@ namespace Retailcrm.Versions.V4 /// /// /// - public Response User(int id) + public Task User(int id) { - return Request.MakeRequest($"/users/{id}", Request.MethodGet); + return Request.MakeRequest($"/users/{id}", HttpMethod.Get); } } } diff --git a/Retailcrm/Versions/V5/Costs.cs b/Retailcrm/Versions/V5/Costs.cs index 55109d4..3e043ff 100644 --- a/Retailcrm/Versions/V5/Costs.cs +++ b/Retailcrm/Versions/V5/Costs.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V5 @@ -13,9 +15,9 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CostsList(Dictionary filter = null, int page = 1, int limit = 20) + public Task CostsList(Dictionary filter = null, int page = 1, int limit = 20) { - Dictionary parameters = new Dictionary(); + Dictionary parameters = []; if (filter != null && filter.Count > 0) { @@ -32,7 +34,7 @@ namespace Retailcrm.Versions.V5 parameters.Add("limit", limit); } - return Request.MakeRequest("/costs", Request.MethodGet, parameters); + return Request.MakeRequest("/costs", HttpMethod.Get, parameters); } /// @@ -41,7 +43,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CostsCreate(Dictionary cost, string site = "") + public Task CostsCreate(Dictionary cost, string site = "") { if (cost.Count < 1) { @@ -70,7 +72,7 @@ namespace Retailcrm.Versions.V5 return Request.MakeRequest( "/costs/create", - Request.MethodPost, + HttpMethod.Post, FillSite( site, new Dictionary @@ -86,7 +88,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CostsDelete(List ids) + public Task CostsDelete(List ids) { if (ids.Count < 1) { @@ -95,7 +97,7 @@ namespace Retailcrm.Versions.V5 return Request.MakeRequest( "/costs/delete", - Request.MethodPost, + HttpMethod.Post, new Dictionary { { "ids", new JavaScriptSerializer().Serialize(ids) } @@ -108,7 +110,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CostsUpload(List costs) + public Task CostsUpload(List costs) { if (costs.Count < 1) { @@ -122,7 +124,7 @@ namespace Retailcrm.Versions.V5 return Request.MakeRequest( "/costs/upload", - Request.MethodPost, + HttpMethod.Post, new Dictionary { { "costs", new JavaScriptSerializer().Serialize(costs) } @@ -135,9 +137,9 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CostsGet(int id) + public Task CostsGet(int id) { - return Request.MakeRequest($"/costs/{id}", Request.MethodGet); + return Request.MakeRequest($"/costs/{id}", HttpMethod.Get); } /// @@ -145,11 +147,11 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CostsDelete(string id) + public Task CostsDelete(string id) { return Request.MakeRequest( $"/costs/{id}/delete", - Request.MethodPost + HttpMethod.Post ); } @@ -159,7 +161,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CostsUpdate(Dictionary cost, string site = "") + public Task CostsUpdate(Dictionary cost, string site = "") { if (cost.Count < 1) { @@ -172,8 +174,8 @@ namespace Retailcrm.Versions.V5 } return Request.MakeRequest( - $"/costs/{cost["id"].ToString()}/edit", - Request.MethodPost, + $"/costs/{cost["id"]}/edit", + HttpMethod.Post, FillSite( site, new Dictionary diff --git a/Retailcrm/Versions/V5/CustomFields.cs b/Retailcrm/Versions/V5/CustomFields.cs index f6733a5..cfbdaf9 100644 --- a/Retailcrm/Versions/V5/CustomFields.cs +++ b/Retailcrm/Versions/V5/CustomFields.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V5 @@ -13,9 +15,9 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CustomFieldsList(Dictionary filter = null, int page = 1, int limit = 20) + public Task CustomFieldsList(Dictionary filter = null, int page = 1, int limit = 20) { - Dictionary parameters = new Dictionary(); + Dictionary parameters = []; if (filter != null && filter.Count > 0) { @@ -32,7 +34,7 @@ namespace Retailcrm.Versions.V5 parameters.Add("limit", limit); } - return Request.MakeRequest("/custom-fields", Request.MethodGet, parameters); + return Request.MakeRequest("/custom-fields", HttpMethod.Get, parameters); } /// @@ -40,12 +42,12 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CustomFieldsCreate(Dictionary customField) + public Task CustomFieldsCreate(Dictionary customField) { - List types = new List - { + List types = + [ "boolean", "date", "dictionary", "email", "integer", "numeric", "string", "text" - }; + ]; if (customField.Count < 1) { @@ -80,8 +82,8 @@ namespace Retailcrm.Versions.V5 } return Request.MakeRequest( - $"/custom-fields/{customField["entity"].ToString()}/create", - Request.MethodPost, + $"/custom-fields/{customField["entity"]}/create", + HttpMethod.Post, new Dictionary { { "customField", new JavaScriptSerializer().Serialize(customField) } @@ -95,11 +97,11 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CustomFieldsGet(string code, string entity) + public Task CustomFieldsGet(string code, string entity) { return Request.MakeRequest( $"/custom-fields/{entity}/{code}", - Request.MethodGet + HttpMethod.Get ); } @@ -108,7 +110,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CustomFieldsUpdate(Dictionary customField) + public Task CustomFieldsUpdate(Dictionary customField) { if (customField.Count < 1) { @@ -126,8 +128,8 @@ namespace Retailcrm.Versions.V5 } return Request.MakeRequest( - $"/custom-fields/{customField["entity"].ToString()}/{customField["code"].ToString()}/edit", - Request.MethodPost, + $"/custom-fields/{customField["entity"]}/{customField["code"]}/edit", + HttpMethod.Post, new Dictionary { { "customField", new JavaScriptSerializer().Serialize(customField) } @@ -142,9 +144,9 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CustomDictionaryList(Dictionary filter = null, int page = 1, int limit = 20) + public Task CustomDictionaryList(Dictionary filter = null, int page = 1, int limit = 20) { - Dictionary parameters = new Dictionary(); + Dictionary parameters = []; if (filter != null && filter.Count > 0) { @@ -161,7 +163,7 @@ namespace Retailcrm.Versions.V5 parameters.Add("limit", limit); } - return Request.MakeRequest("/custom-fields/dictionaries", Request.MethodGet, parameters); + return Request.MakeRequest("/custom-fields/dictionaries", HttpMethod.Get, parameters); } /// @@ -169,7 +171,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CustomDictionaryCreate(Dictionary customDictionary) + public Task CustomDictionaryCreate(Dictionary customDictionary) { if (customDictionary.Count < 1) { @@ -188,7 +190,7 @@ namespace Retailcrm.Versions.V5 return Request.MakeRequest( "/custom-fields/dictionaries/create", - Request.MethodPost, + HttpMethod.Post, new Dictionary { { "customDictionary", new JavaScriptSerializer().Serialize(customDictionary) } @@ -201,11 +203,11 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CustomDictionaryGet(string code) + public Task CustomDictionaryGet(string code) { return Request.MakeRequest( $"/custom-fields/dictionaries/{code}", - Request.MethodGet + HttpMethod.Get ); } @@ -214,7 +216,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CustomDictionaryUpdate(Dictionary customDictionary) + public Task CustomDictionaryUpdate(Dictionary customDictionary) { if (customDictionary.Count < 1) { @@ -232,8 +234,8 @@ namespace Retailcrm.Versions.V5 } return Request.MakeRequest( - $"/custom-fields/dictionaries/{customDictionary["code"].ToString()}/edit", - Request.MethodPost, + $"/custom-fields/dictionaries/{customDictionary["code"]}/edit", + HttpMethod.Post, new Dictionary { { "customDictionary", new JavaScriptSerializer().Serialize(customDictionary) } diff --git a/Retailcrm/Versions/V5/Delivery.cs b/Retailcrm/Versions/V5/Delivery.cs index 923b90c..ab570b1 100644 --- a/Retailcrm/Versions/V5/Delivery.cs +++ b/Retailcrm/Versions/V5/Delivery.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; namespace Retailcrm.Versions.V5 { @@ -10,7 +11,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public new Response DeliverySettingGet(string code) + public new Task DeliverySettingGet(string code) { throw new ArgumentException("This method is unavailable in API V5", code); } @@ -20,7 +21,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public new Response DeliverySettingsEdit(Dictionary configuration) + public new Task DeliverySettingsEdit(Dictionary configuration) { throw new ArgumentException("This method is unavailable in API V5"); } diff --git a/Retailcrm/Versions/V5/Integrations.cs b/Retailcrm/Versions/V5/Integrations.cs index 70858a3..ec76cef 100644 --- a/Retailcrm/Versions/V5/Integrations.cs +++ b/Retailcrm/Versions/V5/Integrations.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V5 @@ -11,7 +13,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response IntegrationsSettingGet(string code) + public Task IntegrationsSettingGet(string code) { if (string.IsNullOrEmpty(code)) { @@ -20,7 +22,7 @@ namespace Retailcrm.Versions.V5 return Request.MakeRequest( $"/integration-modules/{code}", - Request.MethodGet + HttpMethod.Get ); } @@ -29,7 +31,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response IntegrationsSettingsEdit(Dictionary integrationModule) + public Task IntegrationsSettingsEdit(Dictionary integrationModule) { if (integrationModule.Count < 1) { @@ -47,8 +49,8 @@ namespace Retailcrm.Versions.V5 } return Request.MakeRequest( - $"/integration-modules/{integrationModule["code"].ToString()}/edit", - Request.MethodPost, + $"/integration-modules/{integrationModule["code"]}/edit", + HttpMethod.Post, new Dictionary { { "integrationModule", new JavaScriptSerializer().Serialize(integrationModule) } diff --git a/Retailcrm/Versions/V5/Notes.cs b/Retailcrm/Versions/V5/Notes.cs index d9e8ed1..e70fee3 100644 --- a/Retailcrm/Versions/V5/Notes.cs +++ b/Retailcrm/Versions/V5/Notes.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V5 @@ -12,7 +14,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response NotesCreate(Dictionary note, string site = "") + public Task NotesCreate(Dictionary note, string site = "") { if (note.Count < 1) { @@ -21,7 +23,7 @@ namespace Retailcrm.Versions.V5 return Request.MakeRequest( "/customers/notes/create", - Request.MethodPost, + HttpMethod.Post, FillSite( site, new Dictionary @@ -37,11 +39,11 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response NotesDelete(string id) + public Task NotesDelete(string id) { return Request.MakeRequest( $"/customers/notes/{id}/delete", - Request.MethodPost + HttpMethod.Post ); } @@ -52,9 +54,9 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response NotesList(Dictionary filter = null, int page = 1, int limit = 20) + public Task NotesList(Dictionary filter = null, int page = 1, int limit = 20) { - Dictionary parameters = new Dictionary(); + Dictionary parameters = []; if (filter != null && filter.Count > 0) { @@ -71,7 +73,7 @@ namespace Retailcrm.Versions.V5 parameters.Add("limit", limit); } - return Request.MakeRequest("/customers/notes", Request.MethodGet, parameters); + return Request.MakeRequest("/customers/notes", HttpMethod.Get, parameters); } } } diff --git a/Retailcrm/Versions/V5/Orders.cs b/Retailcrm/Versions/V5/Orders.cs index 0b1e3b9..42a607d 100644 --- a/Retailcrm/Versions/V5/Orders.cs +++ b/Retailcrm/Versions/V5/Orders.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V5 @@ -13,7 +14,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response OrdersCombine(Dictionary order, Dictionary resultOrder, string technique = "ours") + public Task OrdersCombine(Dictionary order, Dictionary resultOrder, string technique = "ours") { if (order.Count <= 0) { @@ -37,7 +38,7 @@ namespace Retailcrm.Versions.V5 return Request.MakeRequest( "/orders/combine", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, new Dictionary { { "technique", technique }, diff --git a/Retailcrm/Versions/V5/Payments.cs b/Retailcrm/Versions/V5/Payments.cs index 39e920b..11bab5a 100644 --- a/Retailcrm/Versions/V5/Payments.cs +++ b/Retailcrm/Versions/V5/Payments.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V5 @@ -12,7 +13,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response PaymentsCreate(Dictionary payment, string site = "") + public Task PaymentsCreate(Dictionary payment, string site = "") { if (payment.Count < 1) { @@ -31,7 +32,7 @@ namespace Retailcrm.Versions.V5 return Request.MakeRequest( "/orders/payments/create", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, FillSite( site, new Dictionary @@ -49,7 +50,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response PaymentsUpdate(Dictionary payment, string by = "id", string site = "") + public Task PaymentsUpdate(Dictionary payment, string by = "id", string site = "") { if (payment.Count < 1) { @@ -67,7 +68,7 @@ namespace Retailcrm.Versions.V5 return Request.MakeRequest( $"/orders/payments/{uid}/edit", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, FillSite( site, new Dictionary @@ -84,11 +85,11 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response PaymentsDelete(string id) + public Task PaymentsDelete(string id) { return Request.MakeRequest( $"/orders/payments/{id}/delete", - Request.MethodPost + System.Net.Http.HttpMethod.Post ); } } diff --git a/Retailcrm/Versions/V5/References.cs b/Retailcrm/Versions/V5/References.cs index fd5a5d3..aefe105 100644 --- a/Retailcrm/Versions/V5/References.cs +++ b/Retailcrm/Versions/V5/References.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V5 @@ -10,11 +11,11 @@ namespace Retailcrm.Versions.V5 /// Costs groups /// /// - public Response CostGroups() + public Task CostGroups() { return Request.MakeRequest( "/reference/cost-groups", - Request.MethodGet + System.Net.Http.HttpMethod.Get ); } @@ -22,11 +23,11 @@ namespace Retailcrm.Versions.V5 /// Costs /// /// - public Response CostItems() + public Task CostItems() { return Request.MakeRequest( "/reference/cost-items", - Request.MethodGet + System.Net.Http.HttpMethod.Get ); } @@ -34,11 +35,11 @@ namespace Retailcrm.Versions.V5 /// Legal entities /// /// - public Response LegalEntities() + public Task LegalEntities() { return Request.MakeRequest( "/reference/legal-entities", - Request.MethodGet + System.Net.Http.HttpMethod.Get ); } @@ -47,7 +48,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CostGroupsEdit(Dictionary group) + public Task CostGroupsEdit(Dictionary group) { if (!group.ContainsKey("code")) { @@ -66,7 +67,7 @@ namespace Retailcrm.Versions.V5 return Request.MakeRequest( $"/reference/cost-groups/{@group["code"]}/edit", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, new Dictionary { { "costGroup", new JavaScriptSerializer().Serialize(group) } @@ -79,7 +80,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CostItemsEdit(Dictionary item) + public Task CostItemsEdit(Dictionary item) { if (!item.ContainsKey("code")) { @@ -96,11 +97,10 @@ namespace Retailcrm.Versions.V5 throw new ArgumentException("Parameter `group` is missing"); } - List types = new List - { + List types = [ "const", "var" - }; + ]; if (item.ContainsKey("type") && !types.Contains(item["type"].ToString())) { @@ -109,7 +109,7 @@ namespace Retailcrm.Versions.V5 return Request.MakeRequest( $"/reference/cost-items/{item["code"]}/edit", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, new Dictionary { { "costItem", new JavaScriptSerializer().Serialize(item) } @@ -122,7 +122,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response LegalEntitiesEdit(Dictionary entity) + public Task LegalEntitiesEdit(Dictionary entity) { if (!entity.ContainsKey("code")) { @@ -146,7 +146,7 @@ namespace Retailcrm.Versions.V5 return Request.MakeRequest( $"/reference/legal-entities/{entity["code"]}/edit", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, new Dictionary { { "legalEntity", new JavaScriptSerializer().Serialize(entity) } @@ -158,11 +158,11 @@ namespace Retailcrm.Versions.V5 /// Couriers list /// /// - public Response Couriers() + public Task Couriers() { return Request.MakeRequest( "/reference/couriers", - Request.MethodGet + System.Net.Http.HttpMethod.Get ); } @@ -171,11 +171,11 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CouriersCreate(Dictionary courier) + public Task CouriersCreate(Dictionary courier) { return Request.MakeRequest( "/reference/couriers/create", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, new Dictionary { { "courier", new JavaScriptSerializer().Serialize(courier) } @@ -188,7 +188,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response CouriersEdit(Dictionary courier) + public Task CouriersEdit(Dictionary courier) { if (!courier.ContainsKey("id")) { @@ -197,7 +197,7 @@ namespace Retailcrm.Versions.V5 return Request.MakeRequest( $"/reference/couriers/{courier["id"]}/edit", - Request.MethodPost, + System.Net.Http.HttpMethod.Post, new Dictionary { { "courier", new JavaScriptSerializer().Serialize(courier) } diff --git a/Retailcrm/Versions/V5/Segments.cs b/Retailcrm/Versions/V5/Segments.cs index 89a5b05..9fc8156 100644 --- a/Retailcrm/Versions/V5/Segments.cs +++ b/Retailcrm/Versions/V5/Segments.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading.Tasks; namespace Retailcrm.Versions.V5 { @@ -11,7 +12,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response Segments(Dictionary filter = null, int page = 1, int limit = 20) + public Task Segments(Dictionary filter = null, int page = 1, int limit = 20) { Dictionary parameters = new Dictionary(); @@ -30,7 +31,7 @@ namespace Retailcrm.Versions.V5 parameters.Add("limit", limit); } - return Request.MakeRequest("/segments", Request.MethodGet, parameters); + return Request.MakeRequest("/segments", System.Net.Http.HttpMethod.Get, parameters); } } } diff --git a/Retailcrm/Versions/V5/Stores.cs b/Retailcrm/Versions/V5/Stores.cs index cebc55d..e420e35 100644 --- a/Retailcrm/Versions/V5/Stores.cs +++ b/Retailcrm/Versions/V5/Stores.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; namespace Retailcrm.Versions.V5 { @@ -10,7 +11,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public new Response StoreSettingGet(string code) + public new Task StoreSettingGet(string code) { throw new ArgumentException("This method is unavailable in API V5", code); } @@ -20,7 +21,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public new Response StoreSettingsEdit(Dictionary configuration) + public new Task StoreSettingsEdit(Dictionary configuration) { throw new ArgumentException("This method is unavailable in API V5"); } @@ -32,9 +33,9 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response StoreProductsGroups(Dictionary filter = null, int page = 1, int limit = 20) + public Task StoreProductsGroups(Dictionary filter = null, int page = 1, int limit = 20) { - Dictionary parameters = new Dictionary(); + Dictionary parameters = []; if (filter != null && filter.Count > 0) { @@ -51,7 +52,7 @@ namespace Retailcrm.Versions.V5 parameters.Add("limit", limit); } - return Request.MakeRequest("/store/products-groups", Request.MethodGet, parameters); + return Request.MakeRequest("/store/products-groups", System.Net.Http.HttpMethod.Get, parameters); } /// @@ -61,9 +62,9 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response StoreProductsProperties(Dictionary filter = null, int page = 1, int limit = 20) + public Task StoreProductsProperties(Dictionary filter = null, int page = 1, int limit = 20) { - Dictionary parameters = new Dictionary(); + Dictionary parameters = []; if (filter != null && filter.Count > 0) { @@ -80,7 +81,7 @@ namespace Retailcrm.Versions.V5 parameters.Add("limit", limit); } - return Request.MakeRequest("/store/products/properties", Request.MethodGet, parameters); + return Request.MakeRequest("/store/products/properties", System.Net.Http.HttpMethod.Get, parameters); } } } diff --git a/Retailcrm/Versions/V5/Tasks.cs b/Retailcrm/Versions/V5/Tasks.cs index 44466a5..4cf6d87 100644 --- a/Retailcrm/Versions/V5/Tasks.cs +++ b/Retailcrm/Versions/V5/Tasks.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; using System.Web.Script.Serialization; namespace Retailcrm.Versions.V5 @@ -12,7 +14,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response TasksCreate(Dictionary task, string site = "") + public Task TasksCreate(Dictionary task, string site = "") { if (task.Count < 1) { @@ -21,7 +23,7 @@ namespace Retailcrm.Versions.V5 return Request.MakeRequest( "/tasks/create", - Request.MethodPost, + HttpMethod.Post, FillSite( site, new Dictionary @@ -38,7 +40,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response TasksUpdate(Dictionary task, string site = "") + public Task TasksUpdate(Dictionary task, string site = "") { if (task.Count < 1) { @@ -51,8 +53,8 @@ namespace Retailcrm.Versions.V5 } return Request.MakeRequest( - $"/tasks/{task["id"].ToString()}/edit", - Request.MethodPost, + $"/tasks/{task["id"]}/edit", + HttpMethod.Post, FillSite( site, new Dictionary @@ -68,11 +70,11 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response TasksGet(string id) + public Task TasksGet(string id) { return Request.MakeRequest( $"/tasks/{id}", - Request.MethodGet + HttpMethod.Get ); } @@ -83,9 +85,9 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response TasksList(Dictionary filter = null, int page = 1, int limit = 20) + public Task TasksList(Dictionary filter = null, int page = 1, int limit = 20) { - Dictionary parameters = new Dictionary(); + Dictionary parameters = []; if (filter != null && filter.Count > 0) { @@ -102,7 +104,7 @@ namespace Retailcrm.Versions.V5 parameters.Add("limit", limit); } - return Request.MakeRequest("/tasks", Request.MethodGet, parameters); + return Request.MakeRequest("/tasks", HttpMethod.Get, parameters); } } } diff --git a/Retailcrm/Versions/V5/Telephony.cs b/Retailcrm/Versions/V5/Telephony.cs index 90923bb..ea4c589 100644 --- a/Retailcrm/Versions/V5/Telephony.cs +++ b/Retailcrm/Versions/V5/Telephony.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; namespace Retailcrm.Versions.V5 { @@ -10,7 +11,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public new Response TelephonySettingsGet(string code) + public new Task TelephonySettingsGet(string code) { throw new ArgumentException("This method is unavailable in API V5", code); } @@ -20,7 +21,7 @@ namespace Retailcrm.Versions.V5 /// /// /// - public new Response TelephonySettingsEdit(Dictionary configuration) + public new Task TelephonySettingsEdit(Dictionary configuration) { throw new ArgumentException("This method is unavailable in API V5", configuration.ToString()); } diff --git a/Retailcrm/Versions/V5/Users.cs b/Retailcrm/Versions/V5/Users.cs index be6f3bb..7224457 100644 --- a/Retailcrm/Versions/V5/Users.cs +++ b/Retailcrm/Versions/V5/Users.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; namespace Retailcrm.Versions.V5 { @@ -11,9 +13,9 @@ namespace Retailcrm.Versions.V5 /// /// /// - public Response UsersStatus(int id, string status) + public Task UsersStatus(int id, string status) { - List statuses = new List { "free", "busy", "dinner", "break"}; + List statuses = [ "free", "busy", "dinner", "break"]; if (!statuses.Contains(status)) { @@ -22,7 +24,7 @@ namespace Retailcrm.Versions.V5 return Request.MakeRequest( $"/users/{id}/status", - Request.MethodPost, + HttpMethod.Post, new Dictionary { { "status", status } diff --git a/Retailcrm/packages.config b/Retailcrm/packages.config new file mode 100644 index 0000000..c568df9 --- /dev/null +++ b/Retailcrm/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/RetailcrmUnitTest/ApiTest.cs b/RetailcrmUnitTest/ApiTest.cs index a3e6352..ed0b6b3 100644 --- a/RetailcrmUnitTest/ApiTest.cs +++ b/RetailcrmUnitTest/ApiTest.cs @@ -1,5 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; +using System.Threading.Tasks; namespace RetailcrmUnitTest { @@ -17,9 +18,9 @@ namespace RetailcrmUnitTest } [TestMethod] - public void Versions() + public async Task Versions() { - Response response = _connection.Versions(); + Response response = await _connection.Versions(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsInstanceOfType(response, typeof(Response)); @@ -27,9 +28,9 @@ namespace RetailcrmUnitTest } [TestMethod] - public void Credentials() + public async Task Credentials() { - Response response = _connection.Credentials(); + Response response = await _connection.Credentials(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsInstanceOfType(response, typeof(Response)); diff --git a/RetailcrmUnitTest/ILLink/ILLink.Descriptors.LibraryBuild.xml b/RetailcrmUnitTest/ILLink/ILLink.Descriptors.LibraryBuild.xml new file mode 100644 index 0000000..a42d7f0 --- /dev/null +++ b/RetailcrmUnitTest/ILLink/ILLink.Descriptors.LibraryBuild.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/RetailcrmUnitTest/RetailcrmUnitTest.csproj b/RetailcrmUnitTest/RetailcrmUnitTest.csproj index 2fc57e2..3d92a22 100644 --- a/RetailcrmUnitTest/RetailcrmUnitTest.csproj +++ b/RetailcrmUnitTest/RetailcrmUnitTest.csproj @@ -1,6 +1,9 @@  - + + + + Debug AnyCPU @@ -9,7 +12,7 @@ Properties RetailcrmUnitTest RetailcrmUnitTest - v4.5 + v4.6.2 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15.0 @@ -19,6 +22,7 @@ UnitTest + true @@ -37,16 +41,75 @@ prompt 4 + + true + true + + + ..\packages\Microsoft.ApplicationInsights.2.22.0\lib\net46\Microsoft.ApplicationInsights.dll + + + + ..\packages\Microsoft.Testing.Extensions.Telemetry.1.4.3\lib\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.dll + + + ..\packages\Microsoft.Testing.Extensions.TrxReport.Abstractions.1.4.3\lib\netstandard2.0\Microsoft.Testing.Extensions.TrxReport.Abstractions.dll + + + ..\packages\Microsoft.Testing.Extensions.VSTestBridge.1.4.3\lib\netstandard2.0\Microsoft.Testing.Extensions.VSTestBridge.dll + + + ..\packages\Microsoft.Testing.Platform.1.4.3\lib\netstandard2.0\Microsoft.Testing.Platform.dll + + + ..\packages\Microsoft.Testing.Platform.MSBuild.1.4.3\lib\netstandard2.0\Microsoft.Testing.Platform.MSBuild.dll + + + ..\packages\Microsoft.TestPlatform.ObjectModel.17.12.0\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll + + + ..\packages\Microsoft.TestPlatform.ObjectModel.17.12.0\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll + + + ..\packages\Microsoft.TestPlatform.ObjectModel.17.12.0\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll + - ..\packages\MSTest.TestFramework.2.1.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + ..\packages\MSTest.TestFramework.3.6.4\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - ..\packages\MSTest.TestFramework.2.1.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + ..\packages\MSTest.TestFramework.3.6.4\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + ..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll + + + ..\packages\System.Collections.Immutable.9.0.0\lib\net462\System.Collections.Immutable.dll + + + ..\packages\System.Diagnostics.DiagnosticSource.9.0.0\lib\net462\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll + + + + ..\packages\System.Net.Http.WinHttpHandler.9.0.0\lib\net462\System.Net.Http.WinHttpHandler.dll + + + + ..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll + + + ..\packages\System.Reflection.Metadata.9.0.0\lib\net462\System.Reflection.Metadata.dll + + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + @@ -87,16 +150,25 @@ + + + + - Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}. + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + + + + + - + + \ No newline at end of file diff --git a/RetailcrmUnitTest/V3/ClientTest.cs b/RetailcrmUnitTest/V3/ClientTest.cs index ab2a986..3d2c7b6 100644 --- a/RetailcrmUnitTest/V3/ClientTest.cs +++ b/RetailcrmUnitTest/V3/ClientTest.cs @@ -1,6 +1,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V3; +using System.Threading.Tasks; namespace RetailcrmUnitTest.V3 { @@ -30,9 +31,9 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void StatisticUpdate() + public async Task StatisticUpdate() { - Response response = _client.StatisticUpdate(); + Response response = await _client.StatisticUpdate(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsInstanceOfType(response, typeof(Response)); diff --git a/RetailcrmUnitTest/V3/CustomersTest.cs b/RetailcrmUnitTest/V3/CustomersTest.cs index 8ede393..6a0bf1e 100644 --- a/RetailcrmUnitTest/V3/CustomersTest.cs +++ b/RetailcrmUnitTest/V3/CustomersTest.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V3; @@ -20,7 +21,7 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void CustomersCreateReadUpdate() + public async Task CustomersCreateReadUpdate() { Dictionary customer = new Dictionary { @@ -31,7 +32,7 @@ namespace RetailcrmUnitTest.V3 {"phone", "+78888888888"} }; - Response createResponse = _client.CustomersCreate(customer); + Response createResponse = await _client.CustomersCreate(customer); Assert.IsTrue(createResponse.IsSuccessfull()); Assert.IsInstanceOfType(createResponse, typeof(Response)); @@ -40,7 +41,7 @@ namespace RetailcrmUnitTest.V3 string id = createResponse.GetResponse()["id"].ToString(); - Response getResponse = _client.CustomersGet(id, "id"); + Response getResponse = await _client.CustomersGet(id, "id"); Assert.IsTrue(getResponse.IsSuccessfull()); Assert.IsInstanceOfType(getResponse, typeof(Response)); Assert.IsTrue(createResponse.GetStatusCode() == 201); @@ -52,14 +53,14 @@ namespace RetailcrmUnitTest.V3 {"email", "frodobaggins@example.com"} }; - Response updateResponse = _client.CustomersUpdate(update, "id"); + Response updateResponse = await _client.CustomersUpdate(update, "id"); Assert.IsTrue(updateResponse.IsSuccessfull()); Assert.IsInstanceOfType(updateResponse, typeof(Response)); Assert.IsTrue(updateResponse.GetStatusCode() == 200); } [TestMethod] - public void CustomersFixExternalId() + public async Task CustomersFixExternalId() { long epochTicks = new DateTime(1970, 1, 1).Ticks; long unixTime = ((DateTime.UtcNow.Ticks - epochTicks) / TimeSpan.TicksPerSecond); @@ -74,7 +75,7 @@ namespace RetailcrmUnitTest.V3 {"phone", "+77777777777"} }; - Response createResponse = _client.CustomersCreate(customer); + Response createResponse = await _client.CustomersCreate(customer); string id = createResponse.GetResponse()["id"].ToString(); string externalId = $"{unixTime}ID"; @@ -92,18 +93,18 @@ namespace RetailcrmUnitTest.V3 Assert.IsTrue(createResponse.GetStatusCode() == 201); Assert.IsTrue(createResponse.GetResponse().ContainsKey("id")); - Response fixResponse = _client.CustomersFixExternalIds(fix); + Response fixResponse = await _client.CustomersFixExternalIds(fix); Assert.IsTrue(fixResponse.IsSuccessfull()); Assert.IsInstanceOfType(fixResponse, typeof(Response)); Assert.IsTrue(fixResponse.GetStatusCode() == 200); } [TestMethod] - public void CustomersList() + public async Task CustomersList() { _client.SetSite(Environment.GetEnvironmentVariable("RETAILCRM_SITE")); - Response response = _client.CustomersList(); + Response response = await _client.CustomersList(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -116,7 +117,7 @@ namespace RetailcrmUnitTest.V3 { "dateTo", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} }; - Response responseFiltered = _client.CustomersList(filter, 2, 100); + Response responseFiltered = await _client.CustomersList(filter, 2, 100); Assert.IsTrue(responseFiltered.IsSuccessfull()); Assert.IsTrue(responseFiltered.GetStatusCode() == 200); @@ -125,7 +126,7 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void CustomersUpload() + public async Task CustomersUpload() { List customers = new List(); @@ -143,7 +144,7 @@ namespace RetailcrmUnitTest.V3 customers.Add(customer); } - Response response = _client.CustomersUpload(customers); + Response response = await _client.CustomersUpload(customers); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 201); diff --git a/RetailcrmUnitTest/V3/OrdersTest.cs b/RetailcrmUnitTest/V3/OrdersTest.cs index 2125370..32cdc4a 100644 --- a/RetailcrmUnitTest/V3/OrdersTest.cs +++ b/RetailcrmUnitTest/V3/OrdersTest.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V3; @@ -20,7 +22,7 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void OrdersCreateReadUpdate() + public async Task OrdersCreateReadUpdate() { long epochTicks = new DateTime(1970, 1, 1).Ticks; long unixTime = ((DateTime.UtcNow.Ticks - epochTicks) / TimeSpan.TicksPerSecond); @@ -36,14 +38,14 @@ namespace RetailcrmUnitTest.V3 }; - Response createResponse = _client.OrdersCreate(order); + Response createResponse = await _client.OrdersCreate(order); Assert.IsTrue(createResponse.IsSuccessfull()); Assert.IsInstanceOfType(createResponse, typeof(Response)); Assert.IsTrue(createResponse.GetResponse().ContainsKey("id")); string id = createResponse.GetResponse()["id"].ToString(); - Response getResponse = _client.OrdersGet(id, "id"); + Response getResponse = await _client.OrdersGet(id, "id"); Assert.IsTrue(getResponse.IsSuccessfull()); Assert.IsInstanceOfType(getResponse, typeof(Response)); Assert.IsTrue(getResponse.GetResponse().ContainsKey("order")); @@ -54,14 +56,14 @@ namespace RetailcrmUnitTest.V3 {"status", "cancel-other"} }; - Response updateResponse = _client.OrdersUpdate(update, "id"); + Response updateResponse = await _client.OrdersUpdate(update, "id"); Assert.IsTrue(updateResponse.IsSuccessfull()); Assert.IsInstanceOfType(updateResponse, typeof(Response)); Assert.IsTrue(updateResponse.GetStatusCode() == 200); } [TestMethod] - public void OrdersFixExternalId() + public async Task OrdersFixExternalId() { long epochTicks = new DateTime(1970, 1, 1).Ticks; long unixTime = ((DateTime.UtcNow.Ticks - epochTicks) / TimeSpan.TicksPerSecond); @@ -76,7 +78,7 @@ namespace RetailcrmUnitTest.V3 {"phone", "+79999999999"} }; - Response createResponse = _client.OrdersCreate(order); + Response createResponse = await _client.OrdersCreate(order); string id = createResponse.GetResponse()["id"].ToString(); string externalId = $"{unixTime}ID"; @@ -93,15 +95,15 @@ namespace RetailcrmUnitTest.V3 Assert.IsInstanceOfType(createResponse, typeof(Response)); Assert.IsTrue(createResponse.GetResponse().ContainsKey("id")); - Response fixResponse = _client.OrdersFixExternalIds(fix); + Response fixResponse = await _client.OrdersFixExternalIds(fix); Assert.IsTrue(fixResponse.IsSuccessfull()); Assert.IsInstanceOfType(fixResponse, typeof(Response)); } [TestMethod] - public void OrdersList() + public async Task OrdersList() { - Response response = _client.OrdersList(); + Response response = await _client.OrdersList(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -114,7 +116,7 @@ namespace RetailcrmUnitTest.V3 { "createdAtTo", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} }; - Response responseFiltered = _client.OrdersList(filter, 2, 100); + Response responseFiltered = await _client.OrdersList(filter, 2, 100); Assert.IsTrue(responseFiltered.IsSuccessfull()); Assert.IsTrue(responseFiltered.GetStatusCode() == 200); @@ -123,9 +125,9 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void OrdersHistory() + public async Task OrdersHistory() { - Response response = _client.OrdersHistory(); + Response response = await _client.OrdersHistory(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -137,7 +139,7 @@ namespace RetailcrmUnitTest.V3 DateTime from = datetime.AddHours(-24); DateTime to = datetime.AddHours(-1); - Response responseFiltered = _client.OrdersHistory(from, to, 50, 1, false); + Response responseFiltered = await _client.OrdersHistory(from, to, 50, 1, false); Assert.IsTrue(responseFiltered.IsSuccessfull()); Assert.IsTrue(responseFiltered.GetStatusCode() == 200); @@ -146,7 +148,7 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void OrdersStatuses() + public async Task OrdersStatuses() { List ids = new List(); @@ -171,11 +173,11 @@ namespace RetailcrmUnitTest.V3 { "status", statuses[i] } }; - Response createResponse = _client.OrdersCreate(order); + Response createResponse = await _client.OrdersCreate(order); ids.Add(createResponse.GetResponse()["id"].ToString()); } - Response response = _client.OrdersStatuses(ids); + Response response = await _client.OrdersStatuses(ids); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -184,7 +186,7 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void OrdersUpload() + public async Task OrdersUpload() { List orders = new List(); @@ -212,7 +214,7 @@ namespace RetailcrmUnitTest.V3 orders.Add(order); } - Response response = _client.OrdersUpload(orders); + Response response = await _client.OrdersUpload(orders); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 201); @@ -222,38 +224,38 @@ namespace RetailcrmUnitTest.V3 [TestMethod] [ExpectedException(typeof(ArgumentException), "Parameter `order` must contains a data")] - public void OrdersCreateArgumentExeption() + public async Task OrdersCreateArgumentExeption() { Dictionary order = new Dictionary(); - _client.OrdersCreate(order); + await _client.OrdersCreate(order); } [TestMethod] [ExpectedException(typeof(ArgumentException), "Parameter `order` must contains a data")] - public void OrdersUpdateEmptyOrderArgumentExeption() + public async Task OrdersUpdateEmptyOrderArgumentExeption() { Dictionary order = new Dictionary(); - _client.OrdersUpdate(order); + await _client.OrdersUpdate(order); } [TestMethod] [ExpectedException(typeof(ArgumentException), "Parameter `order` must contains an id or externalId")] - public void OrdersUpdateIdArgumentExeption() + public async Task OrdersUpdateIdArgumentExeption() { Dictionary order = new Dictionary {{"status", "cancel-other"}}; - _client.OrdersUpdate(order); + await _client.OrdersUpdate(order); } [TestMethod] [ExpectedException(typeof(ArgumentException), "You must set the array of `ids` or `externalIds`.")] - public void OrdersStatusesArgumentExeption() + public async Task OrdersStatusesArgumentExeption() { - _client.OrdersStatuses(null); + await _client.OrdersStatuses(null); } [TestMethod] [ExpectedException(typeof(ArgumentException), "Too many ids or externalIds. Maximum number of elements is 500")] - public void OrdersStatusesLimitArgumentExeption() + public async Task OrdersStatusesLimitArgumentExeption() { List ids = new List(); @@ -262,20 +264,20 @@ namespace RetailcrmUnitTest.V3 ids.Add(i.ToString()); } - _client.OrdersStatuses(ids); + await _client.OrdersStatuses(ids); } [TestMethod] [ExpectedException(typeof(ArgumentException), "Parameter `orders` must contains a data")] - public void OrdersUploadEmptyOrdersArgumentExeption() + public async Task OrdersUploadEmptyOrdersArgumentExeption() { List orders = new List(); - _client.OrdersUpload(orders); + await _client.OrdersUpload(orders); } [TestMethod] [ExpectedException(typeof(ArgumentException), "Parameter `orders` must contain 50 or less records")] - public void OrdersUploadLimitArgumentExeption() + public async Task OrdersUploadLimitArgumentExeption() { List orders = new List(); @@ -294,7 +296,7 @@ namespace RetailcrmUnitTest.V3 orders.Add(order); } - _client.OrdersUpload(orders); + await _client.OrdersUpload(orders); } } } diff --git a/RetailcrmUnitTest/V3/PacksTest.cs b/RetailcrmUnitTest/V3/PacksTest.cs index ff215f8..56fe676 100644 --- a/RetailcrmUnitTest/V3/PacksTest.cs +++ b/RetailcrmUnitTest/V3/PacksTest.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V3; @@ -24,7 +25,7 @@ namespace RetailcrmUnitTest.V3 [TestMethod] [Ignore] - public void PacksCreateUpdateReadDelete() + public async Task PacksCreateUpdateReadDelete() { string uid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 12); @@ -48,14 +49,14 @@ namespace RetailcrmUnitTest.V3 } }; - Response orderCreateResponse = _client.OrdersCreate(order); + Response orderCreateResponse = await _client.OrdersCreate(order); Assert.IsTrue(orderCreateResponse.IsSuccessfull()); Assert.IsTrue(orderCreateResponse.GetStatusCode() == 201); Assert.IsInstanceOfType(orderCreateResponse, typeof(Response)); Assert.IsTrue(orderCreateResponse.GetResponse().ContainsKey("id")); - Response orderGetResponse = _client.OrdersGet(orderCreateResponse.GetResponse()["id"].ToString(), "id"); + Response orderGetResponse = await _client.OrdersGet(orderCreateResponse.GetResponse()["id"].ToString(), "id"); Assert.IsTrue(orderGetResponse.IsSuccessfull()); Assert.IsTrue(orderGetResponse.GetStatusCode() == 200); @@ -83,7 +84,7 @@ namespace RetailcrmUnitTest.V3 { "itemId", id[0]} }; - Response packsCreateResponse = _client.PacksCreate(pack); + Response packsCreateResponse = await _client.PacksCreate(pack); Debug.WriteLine(packsCreateResponse.GetRawResponse()); Assert.IsTrue(packsCreateResponse.IsSuccessfull()); @@ -99,21 +100,21 @@ namespace RetailcrmUnitTest.V3 { "quantity", 2} }; - Response packsUpdateResponse = _client.PacksUpdate(packEdit); + Response packsUpdateResponse = await _client.PacksUpdate(packEdit); Assert.IsTrue(packsUpdateResponse.IsSuccessfull()); Assert.IsTrue(packsUpdateResponse.GetStatusCode() == 200); Assert.IsInstanceOfType(packsUpdateResponse, typeof(Response)); Assert.IsTrue(packsUpdateResponse.GetResponse().ContainsKey("id")); - Response packsGetResponse = _client.PacksGet(packId); + Response packsGetResponse = await _client.PacksGet(packId); Assert.IsTrue(packsGetResponse.IsSuccessfull()); Assert.IsTrue(packsGetResponse.GetStatusCode() == 200); Assert.IsInstanceOfType(packsGetResponse, typeof(Response)); Assert.IsTrue(packsGetResponse.GetResponse().ContainsKey("pack")); - Response packsDeleteResponse = _client.PacksDelete(packId); + Response packsDeleteResponse = await _client.PacksDelete(packId); Assert.IsTrue(packsDeleteResponse.IsSuccessfull()); Assert.IsTrue(packsDeleteResponse.GetStatusCode() == 200); @@ -122,14 +123,14 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void PacksList() + public async Task PacksList() { Dictionary filter = new Dictionary { { "store", Environment.GetEnvironmentVariable("RETAILCRM_STORE")} }; - Response response = _client.PacksList(filter, 1, 100); + Response response = await _client.PacksList(filter, 1, 100); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -138,14 +139,14 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void PacksHistory() + public async Task PacksHistory() { Dictionary filter = new Dictionary { { "endDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} }; - Response response = _client.PacksHistory(filter, 2, 100); + Response response = await _client.PacksHistory(filter, 2, 100); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -155,30 +156,30 @@ namespace RetailcrmUnitTest.V3 [TestMethod] [ExpectedException(typeof(ArgumentException), "Parameter `pack` must contains a data")] - public void PacksCreateArgumentExeption() + public async Task PacksCreateArgumentExeption() { Dictionary pack = new Dictionary(); - _client.PacksCreate(pack); + await _client.PacksCreate(pack); } [TestMethod] [ExpectedException(typeof(ArgumentException), "Parameter `pack` must contains a data")] - public void PacksUpdateArgumentExeption() + public async Task PacksUpdateArgumentExeption() { Dictionary pack = new Dictionary(); - _client.PacksUpdate(pack); + await _client.PacksUpdate(pack); } [TestMethod] [ExpectedException(typeof(ArgumentException), "Parameter `pack` must contains an id")] - public void PacksUpdateWithoutIdArgumentExeption() + public async Task PacksUpdateWithoutIdArgumentExeption() { Dictionary pack = new Dictionary { { "quantity", 2 } }; - _client.PacksUpdate(pack); + await _client.PacksUpdate(pack); } } } diff --git a/RetailcrmUnitTest/V3/ReferencesTest.cs b/RetailcrmUnitTest/V3/ReferencesTest.cs index 736230e..1d90bf5 100644 --- a/RetailcrmUnitTest/V3/ReferencesTest.cs +++ b/RetailcrmUnitTest/V3/ReferencesTest.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V3; @@ -20,9 +21,9 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void Countries() + public async Task Countries() { - Response response = _client.Countries(); + Response response = await _client.Countries(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -31,9 +32,9 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void DeliveryServices() + public async Task DeliveryServices() { - Response response = _client.DeliveryServices(); + Response response = await _client.DeliveryServices(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -42,9 +43,9 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void DeliveryTypes() + public async Task DeliveryTypes() { - Response response = _client.DeliveryTypes(); + Response response = await _client.DeliveryTypes(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -53,9 +54,9 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void OrderMethods() + public async Task OrderMethods() { - Response response = _client.OrderMethods(); + Response response = await _client.OrderMethods(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -64,9 +65,9 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void OrderTypes() + public async Task OrderTypes() { - Response response = _client.OrderTypes(); + Response response = await _client.OrderTypes(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -75,9 +76,9 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void PaymentStatuses() + public async Task PaymentStatuses() { - Response response = _client.PaymentStatuses(); + Response response = await _client.PaymentStatuses(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -86,9 +87,9 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void PaymentTypes() + public async Task PaymentTypes() { - Response response = _client.PaymentTypes(); + Response response = await _client.PaymentTypes(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -97,9 +98,9 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void ProductStatuses() + public async Task ProductStatuses() { - Response response = _client.ProductStatuses(); + Response response = await _client.ProductStatuses(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -108,9 +109,9 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void Sites() + public async Task Sites() { - Response response = _client.Sites(); + Response response = await _client.Sites(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -119,9 +120,9 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void StatusGroups() + public async Task StatusGroups() { - Response response = _client.StatusGroups(); + Response response = await _client.StatusGroups(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -130,9 +131,9 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void Statuses() + public async Task Statuses() { - Response response = _client.Statuses(); + Response response = await _client.Statuses(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -141,9 +142,9 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void Stores() + public async Task Stores() { - Response response = _client.Stores(); + Response response = await _client.Stores(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -152,11 +153,11 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void DeliveryServicesEdit() + public async Task DeliveryServicesEdit() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response response = _client.DeliveryServicesEdit( + Response response = await _client.DeliveryServicesEdit( new Dictionary { { "code", guid}, @@ -171,11 +172,11 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void DeliveryTypesEdit() + public async Task DeliveryTypesEdit() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response response = _client.DeliveryTypesEdit( + Response response = await _client.DeliveryTypesEdit( new Dictionary { { "code", guid}, @@ -192,11 +193,11 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void OrderMethodsEdit() + public async Task OrderMethodsEdit() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response response = _client.OrderMethodsEdit( + Response response =await _client.OrderMethodsEdit( new Dictionary { { "code", guid}, @@ -211,11 +212,11 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void OrderTypesEdit() + public async Task OrderTypesEdit() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response response = _client.OrderTypesEdit( + Response response = await _client.OrderTypesEdit( new Dictionary { { "code", guid}, @@ -230,11 +231,11 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void PaymentStatusesEdit() + public async Task PaymentStatusesEdit() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response response = _client.PaymentStatusesEdit( + Response response = await _client.PaymentStatusesEdit( new Dictionary { { "code", guid}, @@ -249,11 +250,11 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void PaymentTypesEdit() + public async Task PaymentTypesEdit() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response response = _client.PaymentTypesEdit( + Response response = await _client.PaymentTypesEdit( new Dictionary { { "code", guid}, @@ -268,11 +269,11 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void ProductStatusesEdit() + public async Task ProductStatusesEdit() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response response = _client.ProductStatusesEdit( + Response response = await _client.ProductStatusesEdit( new Dictionary { { "code", guid}, @@ -287,11 +288,11 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void SitesEdit() + public async Task SitesEdit() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response response = _client.SitesEdit( + Response response = await _client.SitesEdit( new Dictionary { { "code", guid}, @@ -306,11 +307,11 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void StatusesEdit() + public async Task StatusesEdit() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response response = _client.StatusesEdit( + Response response = await _client.StatusesEdit( new Dictionary { { "code", guid}, @@ -327,11 +328,11 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void StoresEdit() + public async Task StoresEdit() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response response = _client.StoresEdit( + Response response = await _client.StoresEdit( new Dictionary { { "code", guid}, diff --git a/RetailcrmUnitTest/V3/StoresTest.cs b/RetailcrmUnitTest/V3/StoresTest.cs index ee2f746..ffb4101 100644 --- a/RetailcrmUnitTest/V3/StoresTest.cs +++ b/RetailcrmUnitTest/V3/StoresTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V3; @@ -21,7 +22,7 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void InventoriesUpload() + public async Task InventoriesUpload() { List offers = new List { @@ -69,7 +70,7 @@ namespace RetailcrmUnitTest.V3 } }; - Response response = _client.StoreInventoriesUpload(offers); + Response response = await _client.StoreInventoriesUpload(offers); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -78,7 +79,7 @@ namespace RetailcrmUnitTest.V3 } [TestMethod] - public void Inventories() + public async Task Inventories() { Dictionary filter = new Dictionary { @@ -86,7 +87,7 @@ namespace RetailcrmUnitTest.V3 { "details", 1} }; - Response response = _client.StoreInventoriesGet(filter, 1, 50); + Response response = await _client.StoreInventoriesGet(filter, 1, 50); Debug.WriteLine(response.GetRawResponse()); @@ -98,15 +99,15 @@ namespace RetailcrmUnitTest.V3 [TestMethod] [ExpectedException(typeof(ArgumentException), "Parameter `offers` must contains a data")] - public void StoreInventoriesUploadArgumentExeption() + public async Task StoreInventoriesUploadArgumentExeption() { List offers = new List(); - _client.StoreInventoriesUpload(offers); + await _client.StoreInventoriesUpload(offers); } [TestMethod] [ExpectedException(typeof(ArgumentException), "Parameter `offers` must contain 250 or less records")] - public void StoreInventoriesUploadLimitArgumentExeption() + public async Task StoreInventoriesUploadLimitArgumentExeption() { List offers = new List(); @@ -130,7 +131,7 @@ namespace RetailcrmUnitTest.V3 ); } - _client.StoreInventoriesUpload(offers); + await _client.StoreInventoriesUpload(offers); } } } diff --git a/RetailcrmUnitTest/V3/TelephonyTest.cs b/RetailcrmUnitTest/V3/TelephonyTest.cs index 43b0ea4..69a13b8 100644 --- a/RetailcrmUnitTest/V3/TelephonyTest.cs +++ b/RetailcrmUnitTest/V3/TelephonyTest.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V3; @@ -21,9 +22,9 @@ namespace RetailcrmUnitTest.V3 [TestMethod] [Ignore] - public void TelephonyManagerGet() + public async Task TelephonyManagerGet() { - Response response = _client.TelephonyManagerGet("+79999999999"); + Response response =await _client.TelephonyManagerGet("+79999999999"); Debug.WriteLine(response.GetRawResponse()); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); diff --git a/RetailcrmUnitTest/V4/CustomersTest.cs b/RetailcrmUnitTest/V4/CustomersTest.cs index dd04132..c6bed6b 100644 --- a/RetailcrmUnitTest/V4/CustomersTest.cs +++ b/RetailcrmUnitTest/V4/CustomersTest.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V4; @@ -20,9 +21,9 @@ namespace RetailcrmUnitTest.V4 } [TestMethod] - public void CustomersHistory() + public async Task CustomersHistory() { - Response response = _client.CustomersHistory(); + Response response = await _client.CustomersHistory(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -31,7 +32,7 @@ namespace RetailcrmUnitTest.V4 DateTime datetime = DateTime.Now; - Response responseFiltered = _client.CustomersHistory( + Response responseFiltered = await _client.CustomersHistory( new Dictionary { { "startDate", datetime.AddMonths(-2).ToString("yyyy-MM-dd HH:mm:ss") }, diff --git a/RetailcrmUnitTest/V4/MarketplaceTest.cs b/RetailcrmUnitTest/V4/MarketplaceTest.cs index 01fe650..a4dc601 100644 --- a/RetailcrmUnitTest/V4/MarketplaceTest.cs +++ b/RetailcrmUnitTest/V4/MarketplaceTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V4; @@ -21,11 +22,12 @@ namespace RetailcrmUnitTest.V4 } [TestMethod] - public void MarketplaceSettingsEdit() + [Ignore] + public async Task MarketplaceSettingsEdit() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response response = _client.MarketplaceSettingsEdit( + Response response = await _client.MarketplaceSettingsEdit( new Dictionary() { { "name", $"MarketplaceApp-{guid}" }, diff --git a/RetailcrmUnitTest/V4/OrdersTest.cs b/RetailcrmUnitTest/V4/OrdersTest.cs index a4b1af5..1cee006 100644 --- a/RetailcrmUnitTest/V4/OrdersTest.cs +++ b/RetailcrmUnitTest/V4/OrdersTest.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V4; @@ -20,7 +21,7 @@ namespace RetailcrmUnitTest.V4 } [TestMethod] - public void OrdersHistory() + public async Task OrdersHistory() { DateTime datetime = DateTime.Now; @@ -30,7 +31,7 @@ namespace RetailcrmUnitTest.V4 { "endDate", datetime.AddHours(-1).ToString("yyyy-MM-dd HH:mm:ss")} }; - Response response = _client.OrdersHistory(filter, 1, 50); + Response response = await _client.OrdersHistory(filter, 1, 50); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -39,7 +40,7 @@ namespace RetailcrmUnitTest.V4 } [TestMethod] - public void BigOrderCreateUpdate() + public async Task BigOrderCreateUpdate() { long epochTicks = new DateTime(1970, 1, 1).Ticks; long unixTime = ((DateTime.UtcNow.Ticks - epochTicks) / TimeSpan.TicksPerSecond); @@ -104,7 +105,7 @@ namespace RetailcrmUnitTest.V4 } }; - Response createResponse = _client.OrdersCreate(order); + Response createResponse = await _client.OrdersCreate(order); Assert.IsTrue(createResponse.IsSuccessfull()); Assert.IsInstanceOfType(createResponse, typeof(Response)); @@ -133,7 +134,7 @@ namespace RetailcrmUnitTest.V4 newItems.Add(item); } - Response updateResponse = _client.OrdersUpdate( + Response updateResponse = await _client.OrdersUpdate( new Dictionary { { "id", createResponse.GetResponse()["id"].ToString()}, { "items", newItems } diff --git a/RetailcrmUnitTest/V4/ReferencesTest.cs b/RetailcrmUnitTest/V4/ReferencesTest.cs index 64a96da..0961d3d 100644 --- a/RetailcrmUnitTest/V4/ReferencesTest.cs +++ b/RetailcrmUnitTest/V4/ReferencesTest.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V4; @@ -20,9 +21,9 @@ namespace RetailcrmUnitTest.V4 } [TestMethod] - public void PriceTypes() + public async Task PriceTypes() { - Response response = _client.PriceTypes(); + Response response = await _client.PriceTypes(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); @@ -31,11 +32,11 @@ namespace RetailcrmUnitTest.V4 } [TestMethod] - public void PriceTypesEdit() + public async Task PriceTypesEdit() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response response = _client.PriceTypesEdit( + Response response = await _client.PriceTypesEdit( new Dictionary { { "code", guid}, diff --git a/RetailcrmUnitTest/V4/StoresTest.cs b/RetailcrmUnitTest/V4/StoresTest.cs index 5bddc64..0ee80a6 100644 --- a/RetailcrmUnitTest/V4/StoresTest.cs +++ b/RetailcrmUnitTest/V4/StoresTest.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V4; @@ -19,9 +20,9 @@ namespace RetailcrmUnitTest.V4 } [TestMethod] - public void StoreProducts() + public async Task StoreProducts() { - Response response = _client.StoreProducts(); + Response response = await _client.StoreProducts(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); diff --git a/RetailcrmUnitTest/V4/TelephonyTest.cs b/RetailcrmUnitTest/V4/TelephonyTest.cs index f277856..464fd35 100644 --- a/RetailcrmUnitTest/V4/TelephonyTest.cs +++ b/RetailcrmUnitTest/V4/TelephonyTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V4; @@ -24,33 +25,9 @@ namespace RetailcrmUnitTest.V4 } [TestMethod] - public void TelephonySettingsEdit() + public async Task TelephonySettingsEdit() { - Response response = _client.TelephonySettingsEdit( - new Dictionary - { - - { "code", _telephonyCode}, - { "clientId", "4717" }, - { "makeCallUrl", $"http://{_telephonyCode}.example.com/call"}, - { "name", $"TestTelephony-{_telephonyCode}"}, - { "image", _logoUrl}, - { "inputEventSupported", true}, - { "outputEventSupported", true}, - { "hangupEventSupported", true}, - { - "additionalCodes", - new List - { - new Dictionary - { - { "userId", Environment.GetEnvironmentVariable("RETAILCRM_USER") }, - { "code", _phoneCode } - } - } - } - } - ); + Response response = await _client.TelephonySettingsEdit(new Dictionary { { "code", _telephonyCode }, { "clientId", "4717" }, { "makeCallUrl", $"http://{_telephonyCode}.example.com/call" }, { "name", $"TestTelephony-{_telephonyCode}" }, { "image", _logoUrl }, { "inputEventSupported", true }, { "outputEventSupported", true }, { "hangupEventSupported", true }, { "additionalCodes", new List { new Dictionary { { "userId", Environment.GetEnvironmentVariable("RETAILCRM_USER") }, { "code", _phoneCode } } } } }); Debug.WriteLine(response.GetRawResponse()); Assert.IsTrue(response.IsSuccessfull()); @@ -61,9 +38,9 @@ namespace RetailcrmUnitTest.V4 [TestMethod] [Ignore] - public void TelephonyCallEvent() + public async Task TelephonyCallEvent() { - Response response = _client.TelephonyCallEvent( + Response response = await _client.TelephonyCallEvent( new Dictionary { { "phone", "+79999999999" }, diff --git a/RetailcrmUnitTest/V4/UsersTest.cs b/RetailcrmUnitTest/V4/UsersTest.cs index 84c2aad..41a32a9 100644 --- a/RetailcrmUnitTest/V4/UsersTest.cs +++ b/RetailcrmUnitTest/V4/UsersTest.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V4; @@ -19,9 +20,9 @@ namespace RetailcrmUnitTest.V4 } [TestMethod] - public void UsersGroups() + public async Task UsersGroups() { - Response usersGroups = _client.UsersGroups(); + Response usersGroups = await _client.UsersGroups(); Assert.IsTrue(usersGroups.IsSuccessfull()); Assert.IsTrue(usersGroups.GetStatusCode() == 200); Assert.IsInstanceOfType(usersGroups, typeof(Response)); @@ -29,9 +30,9 @@ namespace RetailcrmUnitTest.V4 } [TestMethod] - public void User() + public async Task User() { - Response usersGroups = _client.User(int.Parse(Environment.GetEnvironmentVariable("RETAILCRM_USER"))); + Response usersGroups =await _client.User(int.Parse(Environment.GetEnvironmentVariable("RETAILCRM_USER"))); Assert.IsTrue(usersGroups.IsSuccessfull()); Assert.IsTrue(usersGroups.GetStatusCode() == 200); Assert.IsInstanceOfType(usersGroups, typeof(Response)); diff --git a/RetailcrmUnitTest/V5/CostsTest.cs b/RetailcrmUnitTest/V5/CostsTest.cs index 2b3bd25..8b3d726 100644 --- a/RetailcrmUnitTest/V5/CostsTest.cs +++ b/RetailcrmUnitTest/V5/CostsTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V5; @@ -21,13 +22,13 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void CostsCreateUpdateReadDelete() + public async Task CostsCreateUpdateReadDelete() { DateTime datetime = DateTime.Now; string groupGuid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response groupResponse = _client.CostGroupsEdit( + Response groupResponse = await _client.CostGroupsEdit( new Dictionary { { "code", groupGuid}, @@ -44,7 +45,7 @@ namespace RetailcrmUnitTest.V5 string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response itemCostResponse = _client.CostItemsEdit( + Response itemCostResponse = await _client.CostItemsEdit( new Dictionary { { "code", guid}, @@ -60,7 +61,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(itemCostResponse, typeof(Response)); Assert.IsTrue(itemCostResponse.GetResponse().ContainsKey("success")); - Response costsCreateResponse = _client.CostsCreate( + Response costsCreateResponse = await _client.CostsCreate( new Dictionary { { "summ", 20000 }, @@ -77,7 +78,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(costsCreateResponse, typeof(Response)); Assert.IsTrue(costsCreateResponse.GetResponse().ContainsKey("success")); - Response costsUpdateResponse = _client.CostsUpdate( + Response costsUpdateResponse = await _client.CostsUpdate( new Dictionary { { "id", costsCreateResponse.GetResponse()["id"].ToString()}, @@ -95,7 +96,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(costsUpdateResponse, typeof(Response)); Assert.IsTrue(costsUpdateResponse.GetResponse().ContainsKey("success")); - Response responseGet = _client.CostsGet(int.Parse(costsCreateResponse.GetResponse()["id"].ToString())); + Response responseGet = await _client.CostsGet(int.Parse(costsCreateResponse.GetResponse()["id"].ToString())); Debug.WriteLine(responseGet.GetRawResponse()); Assert.IsTrue(responseGet.IsSuccessfull()); @@ -103,7 +104,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(responseGet, typeof(Response)); Assert.IsTrue(responseGet.GetResponse().ContainsKey("success")); - Response response = _client.CostsDelete(costsCreateResponse.GetResponse()["id"].ToString()); + Response response = await _client.CostsDelete(costsCreateResponse.GetResponse()["id"].ToString()); Debug.WriteLine(response.GetRawResponse()); Assert.IsTrue(response.IsSuccessfull()); @@ -113,11 +114,11 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void CostsList() + public async Task CostsList() { DateTime datetime = DateTime.Now; - Response responseFiltered = _client.CostsList( + Response responseFiltered = await _client.CostsList( new Dictionary { { "createdAtFrom", datetime.AddDays(-30).ToString("yyyy-MM-dd HH:mm:ss") } @@ -134,13 +135,13 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void CostsUploadDelete() + public async Task CostsUploadDelete() { DateTime datetime = DateTime.Now; string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); string groupGuid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response groupResponse = _client.CostGroupsEdit( + Response groupResponse = await _client.CostGroupsEdit( new Dictionary { { "code", groupGuid}, @@ -155,7 +156,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(groupResponse, typeof(Response)); Assert.IsTrue(groupResponse.GetResponse().ContainsKey("success")); - Response itemCostResponse = _client.CostItemsEdit( + Response itemCostResponse = await _client.CostItemsEdit( new Dictionary { { "code", guid}, @@ -171,7 +172,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(itemCostResponse, typeof(Response)); Assert.IsTrue(itemCostResponse.GetResponse().ContainsKey("success")); - Response costsUploadResponse = _client.CostsUpload( + Response costsUploadResponse = await _client.CostsUpload( new List { new Dictionary @@ -215,7 +216,7 @@ namespace RetailcrmUnitTest.V5 uploadedCosts.Add(uid.ToString()); } - Response costsDeleteResponse = _client.CostsDelete(uploadedCosts); + Response costsDeleteResponse = await _client.CostsDelete(uploadedCosts); Debug.WriteLine(costsDeleteResponse.GetRawResponse()); Assert.IsTrue(costsDeleteResponse.IsSuccessfull()); diff --git a/RetailcrmUnitTest/V5/CustomFieldsTest.cs b/RetailcrmUnitTest/V5/CustomFieldsTest.cs index 31905b1..17577c2 100644 --- a/RetailcrmUnitTest/V5/CustomFieldsTest.cs +++ b/RetailcrmUnitTest/V5/CustomFieldsTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V5; @@ -21,9 +22,9 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void CustomFieldsList() + public async Task CustomFieldsList() { - Response responseFiltered = _client.CustomFieldsList(new Dictionary { { "entity", "order" } }, 2, 50); + Response responseFiltered = await _client.CustomFieldsList(new Dictionary { { "entity", "order" } }, 2, 50); Debug.WriteLine(responseFiltered.GetRawResponse()); Assert.IsTrue(responseFiltered.IsSuccessfull()); @@ -33,11 +34,11 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void CustomFieldsCreateUpdateRead() + public async Task CustomFieldsCreateUpdateRead() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response customFieldsCreateResponse = _client.CustomFieldsCreate( + Response customFieldsCreateResponse = await _client.CustomFieldsCreate( new Dictionary { { "code", $"customfield{guid}" }, @@ -53,7 +54,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(customFieldsCreateResponse, typeof(Response)); Assert.IsTrue(customFieldsCreateResponse.GetResponse().ContainsKey("code")); - Response customFieldGetResponse = _client.CustomFieldsGet($"customfield{guid}", "order"); + Response customFieldGetResponse = await _client.CustomFieldsGet($"customfield{guid}", "order"); Debug.WriteLine(customFieldGetResponse.GetRawResponse()); Assert.IsTrue(customFieldGetResponse.IsSuccessfull()); @@ -61,7 +62,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(customFieldGetResponse, typeof(Response)); Assert.IsTrue(customFieldGetResponse.GetResponse().ContainsKey("customField")); - Response customFieldsUpdateResponse = _client.CustomFieldsUpdate( + Response customFieldsUpdateResponse = await _client.CustomFieldsUpdate( new Dictionary { { "code", $"customfield{guid}" }, @@ -80,9 +81,9 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void CustomDictionaryList() + public async Task CustomDictionaryList() { - Response responseFiltered = _client.CustomDictionaryList(new Dictionary(), 2, 50); + Response responseFiltered = await _client.CustomDictionaryList(new Dictionary(), 2, 50); Debug.WriteLine(responseFiltered.GetRawResponse()); Assert.IsTrue(responseFiltered.IsSuccessfull()); @@ -92,12 +93,12 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void CustomDictionariesCreateUpdateRead() + public async Task CustomDictionariesCreateUpdateRead() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); string fuid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response customDictionaryCreateResponse = _client.CustomDictionaryCreate( + Response customDictionaryCreateResponse = await _client.CustomDictionaryCreate( new Dictionary { { "code", $"customdict{guid}" }, @@ -122,7 +123,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(customDictionaryCreateResponse, typeof(Response)); Assert.IsTrue(customDictionaryCreateResponse.GetResponse().ContainsKey("code")); - Response customDictionaryGetResponse = _client.CustomDictionaryGet(customDictionaryCreateResponse.GetResponse()["code"].ToString()); + Response customDictionaryGetResponse = await _client.CustomDictionaryGet(customDictionaryCreateResponse.GetResponse()["code"].ToString()); Debug.WriteLine(customDictionaryGetResponse.GetRawResponse()); Assert.IsTrue(customDictionaryGetResponse.IsSuccessfull()); @@ -130,7 +131,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(customDictionaryGetResponse, typeof(Response)); Assert.IsTrue(customDictionaryGetResponse.GetResponse().ContainsKey("customDictionary")); - Response customDictionaryEditResponse = _client.CustomDictionaryUpdate( + Response customDictionaryEditResponse = await _client.CustomDictionaryUpdate( new Dictionary { { "code", $"customdict{guid}" }, diff --git a/RetailcrmUnitTest/V5/IntegrationTest.cs b/RetailcrmUnitTest/V5/IntegrationTest.cs index 8b462f0..c608a65 100644 --- a/RetailcrmUnitTest/V5/IntegrationTest.cs +++ b/RetailcrmUnitTest/V5/IntegrationTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V5; @@ -21,11 +22,11 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void IntegrationsSettingsEditSettingsGet() + public async Task IntegrationsSettingsEditSettingsGet() { string uid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response response = _client.IntegrationsSettingsEdit( + Response response = await _client.IntegrationsSettingsEdit( new Dictionary { { "code", uid}, @@ -42,7 +43,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(response, typeof(Response)); Assert.IsTrue(response.GetResponse().ContainsKey("success")); - Response responseGet = _client.IntegrationsSettingGet(uid); + Response responseGet = await _client.IntegrationsSettingGet(uid); Debug.WriteLine(responseGet.GetRawResponse()); Assert.IsTrue(responseGet.IsSuccessfull()); diff --git a/RetailcrmUnitTest/V5/NotesTest.cs b/RetailcrmUnitTest/V5/NotesTest.cs index ad96133..0f5c00b 100644 --- a/RetailcrmUnitTest/V5/NotesTest.cs +++ b/RetailcrmUnitTest/V5/NotesTest.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V5; +using System.Threading.Tasks; namespace RetailcrmUnitTest.V5 { @@ -23,7 +24,7 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void NotesCreateDelete() + public async Task NotesCreateDelete() { Dictionary customer = new Dictionary { @@ -34,7 +35,7 @@ namespace RetailcrmUnitTest.V5 {"phone", "+78888888989"} }; - Response createResponse = _client.CustomersCreate(customer); + Response createResponse = await _client.CustomersCreate(customer); Assert.IsTrue(createResponse.IsSuccessfull()); Assert.IsInstanceOfType(createResponse, typeof(Response)); @@ -43,14 +44,7 @@ namespace RetailcrmUnitTest.V5 string id = createResponse.GetResponse()["id"].ToString(); - Response responseFiltered = _client.NotesCreate( - new Dictionary - { - { "text", "test task" }, - { "customer", new Dictionary { { "id", id } }}, - { "managerId", Environment.GetEnvironmentVariable("RETAILCRM_USER")} - } - ); + Response responseFiltered = await _client.NotesCreate(new Dictionary { { "text", "test task" }, { "customer", new Dictionary { { "id", id } } }, { "managerId", Environment.GetEnvironmentVariable("RETAILCRM_USER") } }); Debug.WriteLine(responseFiltered.GetRawResponse()); Assert.IsTrue(responseFiltered.IsSuccessfull()); @@ -58,7 +52,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(responseFiltered, typeof(Response)); Assert.IsTrue(responseFiltered.GetResponse().ContainsKey("success")); - Response response = _client.NotesDelete(responseFiltered.GetResponse()["id"].ToString()); + Response response = await _client.NotesDelete(responseFiltered.GetResponse()["id"].ToString()); Debug.WriteLine(response.GetRawResponse()); Assert.IsTrue(response.IsSuccessfull()); @@ -68,11 +62,11 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void NotesList() + public async Task NotesList() { DateTime datetime = DateTime.Now; - Response responseFiltered = _client.NotesList( + Response responseFiltered = await _client.NotesList( new Dictionary { { "createdAtFrom", datetime.AddDays(-30).ToString("yyyy-MM-dd HH:mm:ss") } diff --git a/RetailcrmUnitTest/V5/OrdersTest.cs b/RetailcrmUnitTest/V5/OrdersTest.cs index 2e1b2f1..beb320a 100644 --- a/RetailcrmUnitTest/V5/OrdersTest.cs +++ b/RetailcrmUnitTest/V5/OrdersTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V5; @@ -21,7 +22,7 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void OrdersCombine() + public async Task OrdersCombine() { Dictionary firstOrder = new Dictionary { @@ -34,7 +35,7 @@ namespace RetailcrmUnitTest.V5 }; - Response createFirstResponse = _client.OrdersCreate(firstOrder); + Response createFirstResponse = await _client.OrdersCreate(firstOrder); Assert.IsTrue(createFirstResponse.IsSuccessfull()); Assert.IsInstanceOfType(createFirstResponse, typeof(Response)); Assert.IsTrue(createFirstResponse.GetResponse().ContainsKey("id")); @@ -52,7 +53,7 @@ namespace RetailcrmUnitTest.V5 }; - Response createSecondResponse = _client.OrdersCreate(secondOrder); + Response createSecondResponse = await _client.OrdersCreate(secondOrder); Assert.IsTrue(createSecondResponse.IsSuccessfull()); Assert.IsInstanceOfType(createSecondResponse, typeof(Response)); Assert.IsTrue(createSecondResponse.GetResponse().ContainsKey("id")); @@ -69,7 +70,7 @@ namespace RetailcrmUnitTest.V5 {"id", secondId } }; - Response combineResponse = _client.OrdersCombine(firstCombineOrder, secondCombineOrder); + Response combineResponse = await _client.OrdersCombine(firstCombineOrder, secondCombineOrder); Debug.WriteLine(combineResponse.GetRawResponse()); @@ -79,7 +80,7 @@ namespace RetailcrmUnitTest.V5 [TestMethod] [ExpectedException(typeof(ArgumentException), "Parameter `order` must contains a data")] - public void OrdersCombineEmptyOrderArgumentExeption() + public async Task OrdersCombineEmptyOrderArgumentExeption() { Dictionary firstOrder = new Dictionary(); Dictionary secondOrder = new Dictionary @@ -87,12 +88,12 @@ namespace RetailcrmUnitTest.V5 { "id", "111" } }; - _client.OrdersCombine(firstOrder, secondOrder); + await _client.OrdersCombine(firstOrder, secondOrder); } [TestMethod] [ExpectedException(typeof(ArgumentException), "Parameter `resultOrder` must contains a data")] - public void OrdersCombineEmptyResultOrderArgumentExeption() + public async Task OrdersCombineEmptyResultOrderArgumentExeption() { Dictionary secondOrder = new Dictionary(); Dictionary firstOrder = new Dictionary @@ -100,12 +101,12 @@ namespace RetailcrmUnitTest.V5 { "id", "111" } }; - _client.OrdersCombine(firstOrder, secondOrder); + await _client.OrdersCombine(firstOrder, secondOrder); } [TestMethod] [ExpectedException(typeof(ArgumentException), "Parameter `order` must contains `id` key")] - public void OrdersCombineEmptyIdOrderArgumentExeption() + public async Task OrdersCombineEmptyIdOrderArgumentExeption() { Dictionary firstOrder = new Dictionary { @@ -117,12 +118,12 @@ namespace RetailcrmUnitTest.V5 { "id", "111" } }; - _client.OrdersCombine(firstOrder, secondOrder); + await _client.OrdersCombine(firstOrder, secondOrder); } [TestMethod] [ExpectedException(typeof(ArgumentException), "Parameter `resultOrder` must contains `id` key")] - public void OrdersCombineEmptyIdResultOrderArgumentExeption() + public async Task OrdersCombineEmptyIdResultOrderArgumentExeption() { Dictionary secondOrder = new Dictionary { @@ -134,7 +135,7 @@ namespace RetailcrmUnitTest.V5 { "id", "111" } }; - _client.OrdersCombine(firstOrder, secondOrder); + await _client.OrdersCombine(firstOrder, secondOrder); } } } diff --git a/RetailcrmUnitTest/V5/PaymentsTest.cs b/RetailcrmUnitTest/V5/PaymentsTest.cs index 72fe62c..8b9abab 100644 --- a/RetailcrmUnitTest/V5/PaymentsTest.cs +++ b/RetailcrmUnitTest/V5/PaymentsTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V5; @@ -21,12 +22,12 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void PaymentsCreateUpdateDelete() + public async Task PaymentsCreateUpdateDelete() { DateTime datetime = DateTime.Now; string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response createResponse = _client.OrdersCreate(new Dictionary + Response createResponse = await _client.OrdersCreate(new Dictionary { {"externalId", guid}, {"createdAt", datetime.ToString("yyyy-MM-dd HH:mm:ss")}, @@ -41,7 +42,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(createResponse, typeof(Response)); Assert.IsTrue(createResponse.GetResponse().ContainsKey("id")); - Response paymentCreateResponse = _client.PaymentsCreate( + Response paymentCreateResponse = await _client.PaymentsCreate( new Dictionary { { "externalId", guid }, @@ -57,7 +58,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(paymentCreateResponse, typeof(Response)); Assert.IsTrue(paymentCreateResponse.GetResponse().ContainsKey("success")); - Response paymentUpdateResponse = _client.PaymentsUpdate( + Response paymentUpdateResponse = await _client.PaymentsUpdate( new Dictionary { { "id", paymentCreateResponse.GetResponse()["id"].ToString()}, @@ -72,7 +73,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(paymentUpdateResponse, typeof(Response)); Assert.IsTrue(paymentUpdateResponse.GetResponse().ContainsKey("success")); - Response response = _client.PaymentsDelete(paymentCreateResponse.GetResponse()["id"].ToString()); + Response response = await _client.PaymentsDelete(paymentCreateResponse.GetResponse()["id"].ToString()); Debug.WriteLine(response.GetRawResponse()); Assert.IsTrue(response.IsSuccessfull()); diff --git a/RetailcrmUnitTest/V5/ReferencesTest.cs b/RetailcrmUnitTest/V5/ReferencesTest.cs index 96e17c5..cab05f3 100644 --- a/RetailcrmUnitTest/V5/ReferencesTest.cs +++ b/RetailcrmUnitTest/V5/ReferencesTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V5; @@ -21,9 +22,9 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void CostGroups() + public async Task CostGroups() { - Response response = _client.CostGroups(); + Response response = await _client.CostGroups(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); Assert.IsInstanceOfType(response, typeof(Response)); @@ -31,9 +32,9 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void CostItems() + public async Task CostItems() { - Response response = _client.CostItems(); + Response response = await _client.CostItems(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); Assert.IsInstanceOfType(response, typeof(Response)); @@ -41,9 +42,9 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void LegalEntities() + public async Task LegalEntities() { - Response response = _client.LegalEntities(); + Response response = await _client.LegalEntities(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); Assert.IsInstanceOfType(response, typeof(Response)); @@ -51,16 +52,15 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void CostGroupsEdit() + public async Task CostGroupsEdit() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - - Response response = _client.CostGroupsEdit( + Response response = await _client.CostGroupsEdit( new Dictionary { { "code", guid}, { "name", $"TestCostGroup-{guid}" }, - { "color", "#da5c98" } + { "color", "#dd4040" } } ); @@ -71,11 +71,11 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void CostItemsEdit() + public async Task CostItemsEdit() { string groupGuid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response groupResponse = _client.CostGroupsEdit( + Response groupResponse = await _client.CostGroupsEdit( new Dictionary { { "code", groupGuid}, @@ -91,7 +91,7 @@ namespace RetailcrmUnitTest.V5 string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response response = _client.CostItemsEdit( + Response response = await _client.CostItemsEdit( new Dictionary { { "code", guid}, @@ -108,11 +108,11 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void LegalEntitiesEdit() + public async Task LegalEntitiesEdit() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6); - Response response = _client.LegalEntitiesEdit( + Response response = await _client.LegalEntitiesEdit( new Dictionary { { "code", guid}, @@ -131,9 +131,9 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void Couriers() + public async Task Couriers() { - Response response = _client.Couriers(); + Response response = await _client.Couriers(); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); Assert.IsInstanceOfType(response, typeof(Response)); @@ -141,11 +141,11 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void CouriersCreate() + public async Task CouriersCreate() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 3); - Response response = _client.CouriersCreate( + Response response = await _client.CouriersCreate( new Dictionary { { "firstName", $"CourierFirstName-{guid}"}, @@ -164,11 +164,11 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void CouriersEdit() + public async Task CouriersEdit() { string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 3); - Response response = _client.CouriersCreate( + Response response = await _client.CouriersCreate( new Dictionary { { "firstName", $"CourierFirstName-{guid}"}, @@ -187,7 +187,7 @@ namespace RetailcrmUnitTest.V5 string id = response.GetResponse()["id"].ToString(); - Response responseEdit = _client.CouriersEdit( + Response responseEdit = await _client.CouriersEdit( new Dictionary { { "id", id}, diff --git a/RetailcrmUnitTest/V5/SegmentsTest.cs b/RetailcrmUnitTest/V5/SegmentsTest.cs index 62000b0..3f3343a 100644 --- a/RetailcrmUnitTest/V5/SegmentsTest.cs +++ b/RetailcrmUnitTest/V5/SegmentsTest.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V5; @@ -20,9 +21,9 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void Segments() + public async Task Segments() { - Response responseFiltered = _client.Segments( + Response responseFiltered = await _client.Segments( new Dictionary { { "active", "1" } diff --git a/RetailcrmUnitTest/V5/TasksTest.cs b/RetailcrmUnitTest/V5/TasksTest.cs index 4c4dbcb..f1f9cd0 100644 --- a/RetailcrmUnitTest/V5/TasksTest.cs +++ b/RetailcrmUnitTest/V5/TasksTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V5; @@ -22,11 +23,11 @@ namespace RetailcrmUnitTest.V5 [TestMethod] [Ignore] - public void TasksCreateUpdateGet() + public async Task TasksCreateUpdateGet() { DateTime datetime = DateTime.Now; - Response responseFiltered = _client.TasksCreate( + Response responseFiltered = await _client.TasksCreate( new Dictionary { { "text", "test task" }, @@ -42,7 +43,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(responseFiltered, typeof(Response)); Assert.IsTrue(responseFiltered.GetResponse().ContainsKey("success")); - Response response = _client.TasksUpdate( + Response response = await _client.TasksUpdate( new Dictionary { { "id", responseFiltered.GetResponse()["id"].ToString()}, @@ -59,7 +60,7 @@ namespace RetailcrmUnitTest.V5 Assert.IsInstanceOfType(response, typeof(Response)); Assert.IsTrue(response.GetResponse().ContainsKey("success")); - Response responseGet = _client.TasksGet(responseFiltered.GetResponse()["id"].ToString()); + Response responseGet = await _client.TasksGet(responseFiltered.GetResponse()["id"].ToString()); Debug.WriteLine(responseGet.GetRawResponse()); Assert.IsTrue(responseGet.IsSuccessfull()); @@ -69,9 +70,9 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void TasksList() + public async Task TasksList() { - Response responseFiltered = _client.TasksList( + Response responseFiltered = await _client.TasksList( new Dictionary { { "performers", new List { Environment.GetEnvironmentVariable("RETAILCRM_USER") } }, diff --git a/RetailcrmUnitTest/V5/TelephonyTest.cs b/RetailcrmUnitTest/V5/TelephonyTest.cs index 2d0bab8..91decda 100644 --- a/RetailcrmUnitTest/V5/TelephonyTest.cs +++ b/RetailcrmUnitTest/V5/TelephonyTest.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm.Versions.V5; @@ -20,16 +21,16 @@ namespace RetailcrmUnitTest.V5 [TestMethod] [ExpectedException(typeof(ArgumentException), "This method is unavailable in API V5")] - public void TelephonySettingsGetArgumentExeption() + public async Task TelephonySettingsGetArgumentExeption() { - _client.TelephonySettingsGet("anycode"); + await _client.TelephonySettingsGet("anycode"); } [TestMethod] [ExpectedException(typeof(ArgumentException), "This method is unavailable in API V5")] - public void TelephonySettingsGetTelephonySettingsEditArgumentExeption() + public async Task TelephonySettingsGetTelephonySettingsEditArgumentExeption() { - _client.TelephonySettingsEdit(new Dictionary()); + await _client.TelephonySettingsEdit(new Dictionary()); } } } diff --git a/RetailcrmUnitTest/V5/UsersTest.cs b/RetailcrmUnitTest/V5/UsersTest.cs index 2f42b43..e1933ed 100644 --- a/RetailcrmUnitTest/V5/UsersTest.cs +++ b/RetailcrmUnitTest/V5/UsersTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V5; @@ -21,9 +22,9 @@ namespace RetailcrmUnitTest.V5 } [TestMethod] - public void UsersStatus() + public async Task UsersStatus() { - Response users = _client.Users(); + Response users = await _client.Users(); Assert.IsTrue(users.IsSuccessfull()); Assert.IsTrue(users.GetStatusCode() == 200); Assert.IsInstanceOfType(users, typeof(Response)); @@ -34,7 +35,7 @@ namespace RetailcrmUnitTest.V5 Debug.Assert(user != null, nameof(user) + " != null"); int uid = int.Parse(user["id"].ToString()); - Response status = _client.UsersStatus(uid, "break"); + Response status = await _client.UsersStatus(uid, "break"); Assert.IsTrue(status.IsSuccessfull()); Assert.IsTrue(status.GetStatusCode() == 200); Assert.IsInstanceOfType(status, typeof(Response)); diff --git a/RetailcrmUnitTest/packages.config b/RetailcrmUnitTest/packages.config index e399961..aeec859 100644 --- a/RetailcrmUnitTest/packages.config +++ b/RetailcrmUnitTest/packages.config @@ -1,5 +1,20 @@  - - + + + + + + + + + + + + + + + + + \ No newline at end of file