mirror of
https://github.com/retailcrm/api-client-dotnet.git
synced 2025-04-17 07:50:57 +00:00
add V4 & V5 order methods & tests
This commit is contained in:
parent
defcfac794
commit
b39d295f3a
19 changed files with 358 additions and 49 deletions
|
@ -5,14 +5,14 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public class QueryStringBuilder
|
||||
public class QueryBuilder
|
||||
{
|
||||
private readonly List<KeyValuePair<string, object>> _keyValuePairs
|
||||
= new List<KeyValuePair<string, object>>();
|
||||
|
||||
public static string BuildQueryString(object queryData, string argSeperator = "&")
|
||||
{
|
||||
var encoder = new QueryStringBuilder();
|
||||
var encoder = new QueryBuilder();
|
||||
encoder.AddEntry(null, queryData, allowObjects: true);
|
||||
|
||||
return encoder.GetUriString(argSeperator);
|
|
@ -45,7 +45,7 @@
|
|||
parameters = _defaultParameters.Union(parameters).ToDictionary(k => k.Key, v => v.Value);
|
||||
path = _url + path;
|
||||
|
||||
string httpQuery = QueryStringBuilder.BuildQueryString(parameters);
|
||||
string httpQuery = QueryBuilder.BuildQueryString(parameters);
|
||||
|
||||
if (method.Equals(MethodGet) && parameters.Count > 0)
|
||||
{
|
||||
|
|
|
@ -44,19 +44,21 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="Connection.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="QueryStringBuilder.cs" />
|
||||
<Compile Include="QueryBuilder.cs" />
|
||||
<Compile Include="Request.cs" />
|
||||
<Compile Include="Response.cs" />
|
||||
<Compile Include="Versions\V3\References.cs" />
|
||||
<Compile Include="Versions\V3\Statistic.cs" />
|
||||
<Compile Include="Versions\V3\Client.cs" />
|
||||
<Compile Include="Versions\V3\Orders.cs" />
|
||||
<Compile Include="Versions\V3\Customer.cs" />
|
||||
<Compile Include="Versions\V3\Customers.cs" />
|
||||
<Compile Include="Versions\V3\Packs.cs" />
|
||||
<Compile Include="Versions\V3\Store.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Versions\V4\" />
|
||||
<Folder Include="Versions\V5\" />
|
||||
<Compile Include="Versions\V3\Stores.cs" />
|
||||
<Compile Include="Versions\V4\Client.cs" />
|
||||
<Compile Include="Versions\V4\Orders.cs" />
|
||||
<Compile Include="Versions\V5\Client.cs" />
|
||||
<Compile Include="Versions\V5\Orders.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
public partial class Client
|
||||
{
|
||||
private readonly Request _request;
|
||||
private string _siteCode;
|
||||
protected Request Request;
|
||||
protected string SiteCode;
|
||||
|
||||
public Client(string url, string key, string site = "")
|
||||
{
|
||||
|
@ -18,8 +18,8 @@
|
|||
|
||||
url += "api/v3";
|
||||
|
||||
_request = new Request(url, new Dictionary<string, object> { { "apiKey", key } });
|
||||
_siteCode = site;
|
||||
Request = new Request(url, new Dictionary<string, object> { { "apiKey", key } });
|
||||
SiteCode = site;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -28,7 +28,7 @@
|
|||
/// <returns>string</returns>
|
||||
public string GetSite()
|
||||
{
|
||||
return _siteCode;
|
||||
return SiteCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -36,14 +36,14 @@
|
|||
/// </summary>
|
||||
public void SetSite(string site)
|
||||
{
|
||||
_siteCode = site;
|
||||
SiteCode = site;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check ID parameter
|
||||
/// </summary>
|
||||
/// <param name="by"></param>
|
||||
private static void CheckIdParameter(string by)
|
||||
protected static void CheckIdParameter(string by)
|
||||
{
|
||||
string[] allowedForBy = { "externalId", "id" };
|
||||
if (allowedForBy.Contains(by) == false)
|
||||
|
@ -58,15 +58,15 @@
|
|||
/// <param name="site"></param>
|
||||
/// <param name="param"></param>
|
||||
/// <returns>Dictionary</returns>
|
||||
private Dictionary<string, object> FillSite(string site, Dictionary<string, object> param)
|
||||
protected Dictionary<string, object> FillSite(string site, Dictionary<string, object> param)
|
||||
{
|
||||
if (site.Length > 1)
|
||||
{
|
||||
param.Add("site", site);
|
||||
}
|
||||
else if (_siteCode.Length > 1)
|
||||
else if (SiteCode.Length > 1)
|
||||
{
|
||||
param.Add("site", _siteCode);
|
||||
param.Add("site", SiteCode);
|
||||
}
|
||||
|
||||
return param;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
throw new ArgumentException("Parameter `customer` must contains a data");
|
||||
}
|
||||
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
"/customers/create",
|
||||
Request.MethodPost,
|
||||
FillSite(
|
||||
|
@ -42,7 +42,7 @@
|
|||
|
||||
string uid = by == "externalId" ? customer["externalId"].ToString() : customer["id"].ToString();
|
||||
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
$"/customers/{uid}/edit",
|
||||
Request.MethodPost,
|
||||
FillSite(
|
||||
|
@ -60,7 +60,7 @@
|
|||
{
|
||||
CheckIdParameter(by);
|
||||
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
$"/customers/{id}",
|
||||
Request.MethodGet,
|
||||
FillSite(
|
||||
|
@ -91,12 +91,12 @@
|
|||
parameters.Add("limit", limit);
|
||||
}
|
||||
|
||||
return _request.MakeRequest("/customers", Request.MethodGet, parameters);
|
||||
return Request.MakeRequest("/customers", Request.MethodGet, parameters);
|
||||
}
|
||||
|
||||
public Response CustomersFixExternalIds(Dictionary<string, object>[] ids)
|
||||
{
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
"/customers/fix-external-ids",
|
||||
Request.MethodPost,
|
||||
new Dictionary<string, object>
|
||||
|
@ -118,7 +118,7 @@
|
|||
throw new ArgumentException("Parameter `customers` must contain 50 or less records");
|
||||
}
|
||||
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
"/customers/upload",
|
||||
Request.MethodPost,
|
||||
FillSite(
|
|
@ -13,7 +13,7 @@
|
|||
throw new ArgumentException("Parameter `order` must contains a data");
|
||||
}
|
||||
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
"/orders/create",
|
||||
Request.MethodPost,
|
||||
FillSite(
|
||||
|
@ -42,7 +42,7 @@
|
|||
|
||||
string uid = by == "externalId" ? order["externalId"].ToString() : order["id"].ToString();
|
||||
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
$"/orders/{uid}/edit",
|
||||
Request.MethodPost,
|
||||
FillSite(
|
||||
|
@ -60,7 +60,7 @@
|
|||
{
|
||||
CheckIdParameter(by);
|
||||
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
$"/orders/{id}",
|
||||
Request.MethodGet,
|
||||
FillSite(
|
||||
|
@ -91,12 +91,12 @@
|
|||
parameters.Add("limit", limit);
|
||||
}
|
||||
|
||||
return _request.MakeRequest("/orders", Request.MethodGet, parameters);
|
||||
return Request.MakeRequest("/orders", Request.MethodGet, parameters);
|
||||
}
|
||||
|
||||
public Response OrdersFixExternalIds(Dictionary<string, object>[] ids)
|
||||
{
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
"/orders/fix-external-ids",
|
||||
Request.MethodPost,
|
||||
new Dictionary<string, object>
|
||||
|
@ -132,7 +132,7 @@
|
|||
|
||||
parameters.Add("skipMyChanges", skipMyChanges);
|
||||
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
"/orders/history",
|
||||
Request.MethodGet,
|
||||
parameters
|
||||
|
@ -167,7 +167,7 @@
|
|||
parameters.Add("externalIds", externalIds);
|
||||
}
|
||||
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
"/orders/statuses",
|
||||
Request.MethodGet,
|
||||
parameters
|
||||
|
@ -186,7 +186,7 @@
|
|||
throw new ArgumentException("Parameter `orders` must contain 50 or less records");
|
||||
}
|
||||
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
"/orders/upload",
|
||||
Request.MethodPost,
|
||||
FillSite(
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
parameters.Add("limit", limit);
|
||||
}
|
||||
|
||||
return _request.MakeRequest("/orders/packs", Request.MethodGet, parameters);
|
||||
return Request.MakeRequest("/orders/packs", Request.MethodGet, parameters);
|
||||
}
|
||||
|
||||
public Response PacksCreate(Dictionary<string, object> pack)
|
||||
|
@ -35,7 +35,7 @@
|
|||
throw new ArgumentException("Parameter `pack` must contains a data");
|
||||
}
|
||||
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
"/orders/packs/create",
|
||||
Request.MethodPost,
|
||||
new Dictionary<string, object>
|
||||
|
@ -57,7 +57,7 @@
|
|||
throw new ArgumentException("Parameter `pack` must contains an id");
|
||||
}
|
||||
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
$"/orders/packs/{pack["id"].ToString()}/edit",
|
||||
Request.MethodPost,
|
||||
new Dictionary<string, object>
|
||||
|
@ -74,7 +74,7 @@
|
|||
throw new ArgumentException("Parameter `id` must contains a data");
|
||||
}
|
||||
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
$"/orders/packs/{id}/delete",
|
||||
Request.MethodPost
|
||||
);
|
||||
|
@ -82,7 +82,7 @@
|
|||
|
||||
public Response PacksGet(string id)
|
||||
{
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
$"/orders/packs/{id}",
|
||||
Request.MethodGet
|
||||
);
|
||||
|
@ -107,7 +107,7 @@
|
|||
parameters.Add("limit", limit);
|
||||
}
|
||||
|
||||
return _request.MakeRequest("/orders/packs/history", Request.MethodGet, parameters);
|
||||
return Request.MakeRequest("/orders/packs/history", Request.MethodGet, parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
12
Retailcrm/Versions/V3/References.cs
Normal file
12
Retailcrm/Versions/V3/References.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Retailcrm.Versions.V3
|
||||
{
|
||||
class References
|
||||
{
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
{
|
||||
public Response StatisticUpdate()
|
||||
{
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
"/statistic/update",
|
||||
Request.MethodGet
|
||||
);
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
parameters.Add("limit", limit);
|
||||
}
|
||||
|
||||
return _request.MakeRequest("/store/inventories", Request.MethodGet, parameters);
|
||||
return Request.MakeRequest("/store/inventories", Request.MethodGet, parameters);
|
||||
}
|
||||
|
||||
public Response StoreInventoriesUpload(List<object> offers, string site = "")
|
||||
|
@ -40,7 +40,7 @@
|
|||
throw new ArgumentException("Parameter `offers` must contain 250 or less records");
|
||||
}
|
||||
|
||||
return _request.MakeRequest(
|
||||
return Request.MakeRequest(
|
||||
"/store/inventories/upload",
|
||||
Request.MethodPost,
|
||||
FillSite(
|
21
Retailcrm/Versions/V4/Client.cs
Normal file
21
Retailcrm/Versions/V4/Client.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
namespace Retailcrm.Versions.V4
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using ParentClass = V3.Client;
|
||||
|
||||
public partial class Client : ParentClass
|
||||
{
|
||||
public Client(string url, string key, string site = "") : base(url, key, site)
|
||||
{
|
||||
if ("/" != url.Substring(url.Length - 1, 1))
|
||||
{
|
||||
url += "/";
|
||||
}
|
||||
|
||||
url += "api/v4";
|
||||
|
||||
Request = new Request(url, new Dictionary<string, object> { { "apiKey", key } });
|
||||
SiteCode = site;
|
||||
}
|
||||
}
|
||||
}
|
29
Retailcrm/Versions/V4/Orders.cs
Normal file
29
Retailcrm/Versions/V4/Orders.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
namespace Retailcrm.Versions.V4
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class Client
|
||||
{
|
||||
public Response OrdersHistory(Dictionary<string, object> filter = null, int page = 0, int limit = 0)
|
||||
{
|
||||
Dictionary<string, object> parameters = new Dictionary<string, object>();
|
||||
|
||||
if (filter != null && filter.Count > 0)
|
||||
{
|
||||
parameters.Add("filter", filter);
|
||||
}
|
||||
|
||||
if (page > 0)
|
||||
{
|
||||
parameters.Add("page", page);
|
||||
}
|
||||
|
||||
if (limit > 0)
|
||||
{
|
||||
parameters.Add("limit", limit);
|
||||
}
|
||||
|
||||
return Request.MakeRequest("/orders/history", Request.MethodGet, parameters);
|
||||
}
|
||||
}
|
||||
}
|
21
Retailcrm/Versions/V5/Client.cs
Normal file
21
Retailcrm/Versions/V5/Client.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
namespace Retailcrm.Versions.V5
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using ParentClass = V4.Client;
|
||||
|
||||
public partial class Client : ParentClass
|
||||
{
|
||||
public Client(string url, string key, string site = "") : base(url, key, site)
|
||||
{
|
||||
if ("/" != url.Substring(url.Length - 1, 1))
|
||||
{
|
||||
url += "/";
|
||||
}
|
||||
|
||||
url += "api/v5";
|
||||
|
||||
Request = new Request(url, new Dictionary<string, object> { { "apiKey", key } });
|
||||
SiteCode = site;
|
||||
}
|
||||
}
|
||||
}
|
43
Retailcrm/Versions/V5/Orders.cs
Normal file
43
Retailcrm/Versions/V5/Orders.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
namespace Retailcrm.Versions.V5
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Script.Serialization;
|
||||
|
||||
public partial class Client
|
||||
{
|
||||
public Response OrdersCombine(Dictionary<string, object> order, Dictionary<string, object> resultOrder, string technique = "ours")
|
||||
{
|
||||
if (order.Count <= 0)
|
||||
{
|
||||
throw new ArgumentException("Parameter `order` must contains a data");
|
||||
}
|
||||
|
||||
if (!order.ContainsKey("id"))
|
||||
{
|
||||
throw new ArgumentException("Parameter `order` must contains `id` key");
|
||||
}
|
||||
|
||||
if (resultOrder.Count <= 0)
|
||||
{
|
||||
throw new ArgumentException("Parameter `resultOrder` must contains a data");
|
||||
}
|
||||
|
||||
if (!resultOrder.ContainsKey("id"))
|
||||
{
|
||||
throw new ArgumentException("Parameter `resultOrder` must contains `id` key");
|
||||
}
|
||||
|
||||
return Request.MakeRequest(
|
||||
"/orders/combine",
|
||||
Request.MethodPost,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "technique", technique },
|
||||
{ "order", new JavaScriptSerializer().Serialize(order) },
|
||||
{ "resultOrder", new JavaScriptSerializer().Serialize(resultOrder) }
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -58,7 +58,9 @@
|
|||
<Compile Include="V3\OrdersTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="V3\PacksTest.cs" />
|
||||
<Compile Include="V3\StoreTest.cs" />
|
||||
<Compile Include="V3\StoresTest.cs" />
|
||||
<Compile Include="V4\OrdersTest.cs" />
|
||||
<Compile Include="V5\OrdersTest.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
|
|
|
@ -108,12 +108,10 @@
|
|||
Assert.IsInstanceOfType(response, typeof(Response));
|
||||
Assert.IsTrue(response.GetResponse().ContainsKey("orders"));
|
||||
|
||||
|
||||
Dictionary<string, object> filter = new Dictionary<string, object>
|
||||
{
|
||||
{ "extendedStatus", "new" },
|
||||
{ "createdAtTo", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}
|
||||
|
||||
};
|
||||
|
||||
Response responseFiltered = _client.OrdersList(filter, 2, 100);
|
||||
|
|
|
@ -6,18 +6,17 @@ namespace RetailcrmUnitTest.V3
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Retailcrm;
|
||||
using Retailcrm.Versions.V3;
|
||||
|
||||
[TestClass]
|
||||
public class StoreTest
|
||||
public class StoresTest
|
||||
{
|
||||
private readonly Client _client;
|
||||
private readonly NameValueCollection _appSettings;
|
||||
|
||||
public StoreTest()
|
||||
public StoresTest()
|
||||
{
|
||||
_appSettings = ConfigurationManager.AppSettings;
|
||||
_client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"], _appSettings["site"]);
|
41
RetailcrmUnitTest/V4/OrdersTest.cs
Normal file
41
RetailcrmUnitTest/V4/OrdersTest.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
namespace RetailcrmUnitTest.V4
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Retailcrm;
|
||||
using Retailcrm.Versions.V4;
|
||||
|
||||
[TestClass]
|
||||
public class OrdersTest
|
||||
{
|
||||
private readonly Client _client;
|
||||
|
||||
public OrdersTest()
|
||||
{
|
||||
NameValueCollection appSettings = ConfigurationManager.AppSettings;
|
||||
_client = new Client(appSettings["apiUrl"], appSettings["apiKey"]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OrdersHistory()
|
||||
{
|
||||
DateTime datetime = DateTime.Now;
|
||||
|
||||
Dictionary<string, object> filter = new Dictionary<string, object>
|
||||
{
|
||||
{ "startDate", datetime.AddHours(-24).ToString("yyyy-MM-dd HH:mm:ss") },
|
||||
{ "endDate", datetime.AddHours(-1).ToString("yyyy-MM-dd HH:mm:ss")}
|
||||
};
|
||||
|
||||
Response response = _client.OrdersHistory(filter, 1, 50);
|
||||
|
||||
Assert.IsTrue(response.IsSuccessfull());
|
||||
Assert.IsTrue(response.GetStatusCode() == 200);
|
||||
Assert.IsInstanceOfType(response, typeof(Response));
|
||||
Assert.IsTrue(response.GetResponse().ContainsKey("history"));
|
||||
}
|
||||
}
|
||||
}
|
141
RetailcrmUnitTest/V5/OrdersTest.cs
Normal file
141
RetailcrmUnitTest/V5/OrdersTest.cs
Normal file
|
@ -0,0 +1,141 @@
|
|||
using System.Diagnostics;
|
||||
|
||||
namespace RetailcrmUnitTest.V5
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Retailcrm;
|
||||
using Retailcrm.Versions.V5;
|
||||
|
||||
[TestClass]
|
||||
public class OrdersTest
|
||||
{
|
||||
private readonly Client _client;
|
||||
|
||||
public OrdersTest()
|
||||
{
|
||||
NameValueCollection appSettings = ConfigurationManager.AppSettings;
|
||||
_client = new Client(appSettings["apiUrl"], appSettings["apiKey"]);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OrdersCombine()
|
||||
{
|
||||
Dictionary<string, object> firstOrder = new Dictionary<string, object>
|
||||
{
|
||||
{"number", Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 12)},
|
||||
{"createdAt", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
|
||||
{"lastName", "Doe"},
|
||||
{"firstName", "John"},
|
||||
{"email", $"{Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 12)}@example.com"},
|
||||
{"phone", "+79999999999"}
|
||||
};
|
||||
|
||||
|
||||
Response createFirstResponse = _client.OrdersCreate(firstOrder);
|
||||
Assert.IsTrue(createFirstResponse.IsSuccessfull());
|
||||
Assert.IsInstanceOfType(createFirstResponse, typeof(Response));
|
||||
Assert.IsTrue(createFirstResponse.GetResponse().ContainsKey("id"));
|
||||
|
||||
string firstId = createFirstResponse.GetResponse()["id"].ToString();
|
||||
|
||||
Dictionary<string, object> secondOrder = new Dictionary<string, object>
|
||||
{
|
||||
{"number", Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 12)},
|
||||
{"createdAt", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
|
||||
{"lastName", "Doe"},
|
||||
{"firstName", "John"},
|
||||
{"email", $"{Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 12)}@example.com"},
|
||||
{"phone", "+79999999999"}
|
||||
};
|
||||
|
||||
|
||||
Response createSecondResponse = _client.OrdersCreate(secondOrder);
|
||||
Assert.IsTrue(createSecondResponse.IsSuccessfull());
|
||||
Assert.IsInstanceOfType(createSecondResponse, typeof(Response));
|
||||
Assert.IsTrue(createSecondResponse.GetResponse().ContainsKey("id"));
|
||||
|
||||
string secondId = createSecondResponse.GetResponse()["id"].ToString();
|
||||
|
||||
Dictionary<string, object> firstCombineOrder = new Dictionary<string, object>
|
||||
{
|
||||
{"id", firstId }
|
||||
};
|
||||
|
||||
Dictionary<string, object> secondCombineOrder = new Dictionary<string, object>
|
||||
{
|
||||
{"id", secondId }
|
||||
};
|
||||
|
||||
Response combineResponse = _client.OrdersCombine(firstCombineOrder, secondCombineOrder);
|
||||
|
||||
Debug.WriteLine(combineResponse.GetRawResponse());
|
||||
|
||||
Assert.IsTrue(combineResponse.IsSuccessfull());
|
||||
Assert.IsInstanceOfType(combineResponse, typeof(Response));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException), "Parameter `order` must contains a data")]
|
||||
public void OrdersCombineEmptyOrderArgumentExeption()
|
||||
{
|
||||
Dictionary<string, object> firstOrder = new Dictionary<string, object>();
|
||||
Dictionary<string, object> secondOrder = new Dictionary<string, object>
|
||||
{
|
||||
{ "id", "111" }
|
||||
};
|
||||
|
||||
_client.OrdersCombine(firstOrder, secondOrder);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException), "Parameter `resultOrder` must contains a data")]
|
||||
public void OrdersCombineEmptyResultOrderArgumentExeption()
|
||||
{
|
||||
Dictionary<string, object> secondOrder = new Dictionary<string, object>();
|
||||
Dictionary<string, object> firstOrder = new Dictionary<string, object>
|
||||
{
|
||||
{ "id", "111" }
|
||||
};
|
||||
|
||||
_client.OrdersCombine(firstOrder, secondOrder);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException), "Parameter `order` must contains `id` key")]
|
||||
public void OrdersCombineEmptyIdOrderArgumentExeption()
|
||||
{
|
||||
Dictionary<string, object> firstOrder = new Dictionary<string, object>
|
||||
{
|
||||
{ "number", Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 12) }
|
||||
};
|
||||
|
||||
Dictionary<string, object> secondOrder = new Dictionary<string, object>
|
||||
{
|
||||
{ "id", "111" }
|
||||
};
|
||||
|
||||
_client.OrdersCombine(firstOrder, secondOrder);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException), "Parameter `resultOrder` must contains `id` key")]
|
||||
public void OrdersCombineEmptyIdResultOrderArgumentExeption()
|
||||
{
|
||||
Dictionary<string, object> secondOrder = new Dictionary<string, object>
|
||||
{
|
||||
{ "number", Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 12) }
|
||||
};
|
||||
|
||||
Dictionary<string, object> firstOrder = new Dictionary<string, object>
|
||||
{
|
||||
{ "id", "111" }
|
||||
};
|
||||
|
||||
_client.OrdersCombine(firstOrder, secondOrder);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue