Update telephony methods;

More test coverage;
Minor fixes in api methods;
This commit is contained in:
Alex Lushpai 2017-10-30 13:26:07 +03:00
parent 981754196d
commit 9b5db342c1
46 changed files with 2034 additions and 125 deletions

View file

@ -58,6 +58,7 @@
<Compile Include="Versions\V3\Customers.cs" />
<Compile Include="Versions\V3\Packs.cs" />
<Compile Include="Versions\V3\Stores.cs" />
<Compile Include="Versions\V3\Telephony.cs" />
<Compile Include="Versions\V4\Client.cs" />
<Compile Include="Versions\V4\Customers.cs" />
<Compile Include="Versions\V4\Delivery.cs" />
@ -65,6 +66,7 @@
<Compile Include="Versions\V4\Orders.cs" />
<Compile Include="Versions\V4\References.cs" />
<Compile Include="Versions\V4\Stores.cs" />
<Compile Include="Versions\V4\Telephony.cs" />
<Compile Include="Versions\V4\Users.cs" />
<Compile Include="Versions\V5\Client.cs" />
<Compile Include="Versions\V5\Costs.cs" />
@ -78,6 +80,7 @@
<Compile Include="Versions\V5\Segments.cs" />
<Compile Include="Versions\V5\Stores.cs" />
<Compile Include="Versions\V5\Tasks.cs" />
<Compile Include="Versions\V5\Telephony.cs" />
<Compile Include="Versions\V5\Users.cs" />
</ItemGroup>
<ItemGroup>

View file

@ -102,7 +102,7 @@ namespace Retailcrm.Versions.V3
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
public Response CustomersList(Dictionary<string, object> filter = null, int page = 0, int limit = 0)
public Response CustomersList(Dictionary<string, object> filter = null, int page = 1, int limit = 20)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();

View file

@ -13,7 +13,7 @@ namespace Retailcrm.Versions.V3
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
public Response PacksList(Dictionary<string, object> filter = null, int page = 0, int limit = 0)
public Response PacksList(Dictionary<string, object> filter = null, int page = 1, int limit = 20)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();

View file

@ -0,0 +1,150 @@
using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;
namespace Retailcrm.Versions.V3
{
public partial class Client
{
/// <summary>
/// Get manager
/// </summary>
/// <param name="phone"></param>
/// <param name="details"></param>
/// <returns></returns>
public Response TelephonyManagerGet(string phone, string details = "1")
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
if (string.IsNullOrEmpty(phone))
{
throw new ArgumentException("Parameter `phone` must contains a data");
}
parameters.Add("details", details);
parameters.Add("phone", phone);
return Request.MakeRequest("/telephony/manager", Request.MethodGet, parameters);
}
/// <summary>
/// Send call event
/// </summary>
/// <param name="phone"></param>
/// <param name="type"></param>
/// <param name="status"></param>
/// <param name="code"></param>
/// <returns></returns>
public Response TelephonyCallEvent(string phone, string type, string status, string code)
{
if (string.IsNullOrEmpty(phone))
{
throw new ArgumentException("Parameter `phone` must contains a data");
}
if (string.IsNullOrEmpty(code))
{
throw new ArgumentException("Parameter `phone` must contains a data");
}
List<string> statuses = new List<string> { "answered", "busy", "cancel", "failed", "no answered" };
List<string> types = new List<string> { "hangup", "in", "out" };
if (!statuses.Contains(status))
{
throw new ArgumentException("Parameter `status` must be equal one of `answered|busy|cancel|failed|no answered`");
}
if (!types.Contains(type))
{
throw new ArgumentException("Parameter `type` must be equal one of `hangup|in|out`");
}
return Request.MakeRequest(
"/telephony/call/event",
Request.MethodPost,
new Dictionary<string, object>
{
{ "phone", phone },
{ "type", type },
{ "hangupStatus", status},
{ "code", code }
}
);
}
/// <summary>
/// Upload calls
/// </summary>
/// <param name="calls"></param>
/// <returns></returns>
public Response TelephonyCallsUpload(List<object> calls)
{
if (calls.Count < 1)
{
throw new ArgumentException("Parameter `calls` must contains a data");
}
if (calls.Count > 50)
{
throw new ArgumentException("Parameter `calls` must contain 50 or less records");
}
return Request.MakeRequest(
"/telephony/calls/upload",
Request.MethodPost,
new Dictionary<string, object>
{
{ "calls", new JavaScriptSerializer().Serialize(calls) }
}
);
}
/// <summary>
/// Edit telephony settings
/// </summary>
/// <param name="code"></param>
/// <param name="clientId"></param>
/// <param name="url"></param>
/// <param name="name"></param>
/// <param name="logo"></param>
/// <param name="active"></param>
/// <returns></returns>
public Response TelephonySettingsEdit(string code, string clientId, string url, string name, string logo, string active = "true")
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentException("Parameter `name` must contains a data");
}
if (string.IsNullOrEmpty(code))
{
throw new ArgumentException("Parameter `phone` must contains a data");
}
if (string.IsNullOrEmpty(url))
{
throw new ArgumentException("Parameter `url` must contains a data");
}
if (string.IsNullOrEmpty(clientId))
{
throw new ArgumentException("Parameter `clientId` must contains a data");
}
return Request.MakeRequest(
$"/telephony/setting/{code}",
Request.MethodPost,
new Dictionary<string, object>
{
{ "code", code },
{ "name", name },
{ "clientId", clientId},
{ "makeCallUrl", url },
{ "image", logo },
{ "active", active }
}
);
}
}
}

View file

@ -11,7 +11,7 @@ namespace Retailcrm.Versions.V4
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
public Response CustomersHistory(Dictionary<string, object> filter = null, int page = 0, int limit = 0)
public Response CustomersHistory(Dictionary<string, object> filter = null, int page = 1, int limit = 20)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();

View file

@ -11,7 +11,7 @@ namespace Retailcrm.Versions.V4
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
public Response OrdersHistory(Dictionary<string, object> filter = null, int page = 0, int limit = 0)
public Response OrdersHistory(Dictionary<string, object> filter = null, int page = 1, int limit = 20)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();

View file

@ -13,7 +13,7 @@ namespace Retailcrm.Versions.V4
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
public Response StoreProducts(Dictionary<string, object> filter = null, int page = 0, int limit = 0)
public Response StoreProducts(Dictionary<string, object> filter = null, int page = 1, int limit = 20)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();

View file

@ -0,0 +1,116 @@
using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;
namespace Retailcrm.Versions.V4
{
public partial class Client
{
/// <summary>
/// Send call event
/// </summary>
/// <param name="ievent"></param>
/// <returns></returns>
public Response TelephonyCallEvent(Dictionary<string, object> ievent)
{
if (ievent.Count < 1)
{
throw new ArgumentException("Parameter `event` must contain data");
}
if (!ievent.ContainsKey("phone"))
{
throw new ArgumentException("Parameter `phone` must contains a data");
}
if (!ievent.ContainsKey("type"))
{
throw new ArgumentException("Parameter `type` must contains a data");
}
if (!ievent.ContainsKey("hangupStatus"))
{
throw new ArgumentException("Parameter `hangupStatus` must contains a data");
}
List<string> statuses = new List<string> { "answered", "busy", "cancel", "failed", "no answered" };
List<string> types = new List<string> { "hangup", "in", "out" };
if (!statuses.Contains(ievent["hangupStatus"].ToString()))
{
throw new ArgumentException("Parameter `status` must be equal one of `answered|busy|cancel|failed|no answered`");
}
if (!types.Contains(ievent["type"].ToString()))
{
throw new ArgumentException("Parameter `type` must be equal one of `hangup|in|out`");
}
return Request.MakeRequest(
"/telephony/call/event",
Request.MethodPost,
new Dictionary<string, object>
{
{ "event", new JavaScriptSerializer().Serialize(ievent) }
}
);
}
/// <summary>
/// Get telephony settings
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public Response TelephonySettingsGet(string code)
{
if (string.IsNullOrEmpty(code))
{
throw new ArgumentException("Parameter `code` should contain data");
}
return Request.MakeRequest($"/telephony/setting/{code}", Request.MethodGet);
}
/// <summary>
/// Edit telephony settings
/// </summary>
/// <param name="configuration"></param>
/// <returns></returns>
public Response TelephonySettingsEdit(Dictionary<string, object> configuration)
{
if (configuration.Count < 1)
{
throw new ArgumentException("Parameter `configuration` must contain data");
}
if (!configuration.ContainsKey("code"))
{
throw new ArgumentException("Parameter `configuration` should contain `code`");
}
if (!configuration.ContainsKey("name"))
{
throw new ArgumentException("Parameter `configuration` should contain `name`");
}
if (!configuration.ContainsKey("makeCallUrl"))
{
throw new ArgumentException("Parameter `configuration` should contain `makeCallUrl`");
}
if (!configuration.ContainsKey("clientId"))
{
throw new ArgumentException("Parameter `configuration` should contain `clientId`");
}
return Request.MakeRequest(
$"/telephony/setting/{configuration["code"].ToString()}/edit",
Request.MethodPost,
new Dictionary<string, object>
{
{ "configuration", new JavaScriptSerializer().Serialize(configuration) }
}
);
}
}
}

View file

@ -39,7 +39,7 @@ namespace Retailcrm.Versions.V4
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
public Response UsersGroups(int page = 0, int limit = 0)
public Response UsersGroups(int page = 1, int limit = 20)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();

View file

@ -13,7 +13,7 @@ namespace Retailcrm.Versions.V5
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
public Response CostsList(Dictionary<string, object> filter = null, int page = 0, int limit = 0)
public Response CostsList(Dictionary<string, object> filter = null, int page = 1, int limit = 20)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
@ -48,6 +48,26 @@ namespace Retailcrm.Versions.V5
throw new ArgumentException("Parameter `cost` must contains a data");
}
if (!cost.ContainsKey("costItem"))
{
throw new ArgumentException("Parameter `costItem` must be set");
}
if (!cost.ContainsKey("summ"))
{
throw new ArgumentException("Parameter `summ` must be set");
}
if (!cost.ContainsKey("dateFrom"))
{
throw new ArgumentException("`dateFrom`: Time interval lower bound must not be blank");
}
if (!cost.ContainsKey("dateTo"))
{
throw new ArgumentException("`dateTo`: Time interval upper bound must not be blank");
}
return Request.MakeRequest(
"/costs/create",
Request.MethodPost,
@ -95,6 +115,11 @@ namespace Retailcrm.Versions.V5
throw new ArgumentException("Parameter `costs` must contains a data");
}
if (costs.Count > 50)
{
throw new ArgumentException("Parameter `costs` must contain 50 or less records");
}
return Request.MakeRequest(
"/costs/upload",
Request.MethodPost,

View file

@ -13,7 +13,7 @@ namespace Retailcrm.Versions.V5
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
public Response CustomFieldsList(Dictionary<string, object> filter = null, int page = 0, int limit = 0)
public Response CustomFieldsList(Dictionary<string, object> filter = null, int page = 1, int limit = 20)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
@ -39,9 +39,8 @@ namespace Retailcrm.Versions.V5
/// Create custom field
/// </summary>
/// <param name="customField"></param>
/// <param name="entity"></param>
/// <returns></returns>
public Response CustomFieldsCreate(Dictionary<string, object> customField, string entity = "")
public Response CustomFieldsCreate(Dictionary<string, object> customField)
{
List<string> types = new List<string>
{
@ -68,6 +67,11 @@ namespace Retailcrm.Versions.V5
throw new ArgumentException("Parameter `customField` should contain `type`");
}
if (!customField.ContainsKey("entity"))
{
throw new ArgumentException("Parameter `customField` should contain `entity`");
}
if (!types.Contains(customField["type"].ToString()))
{
throw new ArgumentException(
@ -76,7 +80,7 @@ namespace Retailcrm.Versions.V5
}
return Request.MakeRequest(
$"/custom-fields/{entity}/create",
$"/custom-fields/{customField["entity"].ToString()}/create",
Request.MethodPost,
new Dictionary<string, object>
{
@ -103,9 +107,8 @@ namespace Retailcrm.Versions.V5
/// Update custom field
/// </summary>
/// <param name="customField"></param>
/// <param name="entity"></param>
/// <returns></returns>
public Response CustomFieldsUpdate(Dictionary<string, object> customField, string entity = "")
public Response CustomFieldsUpdate(Dictionary<string, object> customField)
{
if (customField.Count < 1)
{
@ -123,7 +126,7 @@ namespace Retailcrm.Versions.V5
}
return Request.MakeRequest(
$"/custom-fields/{entity}/{customField["code"].ToString()}/edit",
$"/custom-fields/{customField["entity"].ToString()}/{customField["code"].ToString()}/edit",
Request.MethodPost,
new Dictionary<string, object>
{
@ -139,7 +142,7 @@ namespace Retailcrm.Versions.V5
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
public Response CustomDictionaryList(Dictionary<string, object> filter = null, int page = 0, int limit = 0)
public Response CustomDictionaryList(Dictionary<string, object> filter = null, int page = 1, int limit = 20)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();

View file

@ -52,7 +52,7 @@ namespace Retailcrm.Versions.V5
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
public Response NotesList(Dictionary<string, object> filter = null, int page = 0, int limit = 0)
public Response NotesList(Dictionary<string, object> filter = null, int page = 1, int limit = 20)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();

View file

@ -19,6 +19,16 @@ namespace Retailcrm.Versions.V5
throw new ArgumentException("Parameter `payment` must contains a data");
}
if (!payment.ContainsKey("type"))
{
throw new ArgumentException("Parameter `type` must be set");
}
if (!payment.ContainsKey("order"))
{
throw new ArgumentException("Parameter `order` must be set");
}
return Request.MakeRequest(
"/orders/payments/create",
Request.MethodPost,

View file

@ -91,6 +91,11 @@ namespace Retailcrm.Versions.V5
throw new ArgumentException("Parameter `name` is missing");
}
if (!item.ContainsKey("group"))
{
throw new ArgumentException("Parameter `group` is missing");
}
List<string> types = new List<string>
{
"const",
@ -129,6 +134,16 @@ namespace Retailcrm.Versions.V5
throw new ArgumentException("Parameter `legalName` is missing");
}
if (!entity.ContainsKey("countryIso"))
{
throw new ArgumentException("Parameter `countryIso` is missing");
}
if (!entity.ContainsKey("contragentType"))
{
throw new ArgumentException("Parameter `contragentType` is missing");
}
return Request.MakeRequest(
$"/reference/legal-entities/{entity["code"].ToString()}/edit",
Request.MethodPost,

View file

@ -11,7 +11,7 @@ namespace Retailcrm.Versions.V5
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
public Response Segments(Dictionary<string, object> filter = null, int page = 0, int limit = 0)
public Response Segments(Dictionary<string, object> filter = null, int page = 1, int limit = 20)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();

View file

@ -32,7 +32,7 @@ namespace Retailcrm.Versions.V5
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
public Response StoreProductsGroups(Dictionary<string, object> filter = null, int page = 0, int limit = 0)
public Response StoreProductsGroups(Dictionary<string, object> filter = null, int page = 1, int limit = 20)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
@ -61,7 +61,7 @@ namespace Retailcrm.Versions.V5
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
public Response StoreProductsProperties(Dictionary<string, object> filter = null, int page = 0, int limit = 0)
public Response StoreProductsProperties(Dictionary<string, object> filter = null, int page = 1, int limit = 20)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();

View file

@ -83,7 +83,7 @@ namespace Retailcrm.Versions.V5
/// <param name="page"></param>
/// <param name="limit"></param>
/// <returns></returns>
public Response TasksList(Dictionary<string, object> filter = null, int page = 0, int limit = 0)
public Response TasksList(Dictionary<string, object> filter = null, int page = 1, int limit = 20)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();

View file

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
namespace Retailcrm.Versions.V5
{
public partial class Client
{
/// <summary>
/// Get telephony settings
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public new Response TelephonySettingsGet(string code)
{
throw new ArgumentException("This method is unavailable in API V5", code);
}
/// <summary>
/// Edit telephony settings
/// </summary>
/// <param name="configuration"></param>
/// <returns></returns>
public new Response TelephonySettingsEdit(Dictionary<string, object> configuration)
{
throw new ArgumentException("This method is unavailable in API V5", configuration.ToString());
}
}
}

View file

@ -1,10 +1,10 @@
namespace RetailcrmUnitTest
{
using System.Collections.Specialized;
using System.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using System.Collections.Specialized;
using System.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
namespace RetailcrmUnitTest
{
[TestClass]
public class ApiTest
{

View file

@ -4,5 +4,9 @@
<add key="apiUrl" value="https://example.retailcrm.ru"/>
<add key="apiKey" value="BBBBBBBBBBBBBBBBBBBBBBBBBBBB"/>
<add key="site" value="default"/>
<add key="store" value="test-store"/>
<add key="manager" value="1"/>
<add key="customer" value="1" />
<add key="phone" value="+79999999999"/>
</appSettings>
</configuration>

View file

@ -58,11 +58,27 @@
<Compile Include="V3\OrdersTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="V3\PacksTest.cs" />
<Compile Include="V3\ReferencesTest.cs" />
<Compile Include="V3\StoresTest.cs" />
<Compile Include="V3\TelephonyTest.cs" />
<Compile Include="V4\CustomersTest.cs" />
<Compile Include="V4\MarketplaceTest.cs" />
<Compile Include="V4\OrdersTest.cs" />
<Compile Include="V4\ReferencesTest.cs" />
<Compile Include="V4\StoresTest.cs" />
<Compile Include="V4\TelephonyTest.cs" />
<Compile Include="V4\UsersTest.cs" />
<Compile Include="V5\CostsTest.cs" />
<Compile Include="V5\CustomFieldsTest.cs" />
<Compile Include="V5\IntegrationTest.cs" />
<Compile Include="V5\NotesTest.cs" />
<Compile Include="V5\PaymentsTest.cs" />
<Compile Include="V5\TasksTest.cs" />
<Compile Include="V5\TelephonyTest.cs" />
<Compile Include="V5\UsersTest.cs" />
<Compile Include="V5\OrdersTest.cs" />
<Compile Include="V5\ReferencesTest.cs" />
<Compile Include="V5\SegmentsTest.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />

View file

@ -1,11 +1,11 @@
namespace RetailcrmUnitTest.V3
{
using System.Collections.Specialized;
using System.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V3;
using System.Collections.Specialized;
using System.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V3;
namespace RetailcrmUnitTest.V3
{
[TestClass]
public class ClientTest
{

View file

@ -1,13 +1,13 @@
namespace RetailcrmUnitTest.V3
{
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V3;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V3;
namespace RetailcrmUnitTest.V3
{
[TestClass]
public class CustomersTest
{

View file

@ -1,13 +1,13 @@
namespace RetailcrmUnitTest.V3
{
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V3;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V3;
namespace RetailcrmUnitTest.V3
{
[TestClass]
public class OrdersTest
{

View file

@ -1,16 +1,15 @@
using System.Globalization;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Globalization;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V3;
namespace RetailcrmUnitTest.V3
{
using System;
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 PacksTest
{
@ -23,28 +22,6 @@ namespace RetailcrmUnitTest.V3
_client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"], _appSettings["site"]);
}
#region Дополнительные атрибуты тестирования
//
// При написании тестов можно использовать следующие дополнительные атрибуты:
//
// ClassInitialize используется для выполнения кода до запуска первого теста в классе
// [ClassInitialize()]
// public static void MyClassInitialize(TestContext testContext) { }
//
// ClassCleanup используется для выполнения кода после завершения работы всех тестов в классе
// [ClassCleanup()]
// public static void MyClassCleanup() { }
//
// TestInitialize используется для выполнения кода перед запуском каждого теста
// [TestInitialize()]
// public void MyTestInitialize() { }
//
// TestCleanup используется для выполнения кода после завершения каждого теста
// [TestCleanup()]
// public void MyTestCleanup() { }
//
#endregion
[TestMethod]
public void PacksCreateUpdateReadDelete()
{

View file

@ -0,0 +1,349 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V3;
namespace RetailcrmUnitTest.V3
{
[TestClass]
public class ReferencesTest
{
private readonly Client _client;
public ReferencesTest()
{
NameValueCollection appSettings = ConfigurationManager.AppSettings;
_client = new Client(appSettings["apiUrl"], appSettings["apiKey"]);
}
[TestMethod]
public void Countries()
{
Response response = _client.Countries();
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void DeliveryServices()
{
Response response = _client.DeliveryServices();
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void DeliveryTypes()
{
Response response = _client.DeliveryTypes();
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void OrderMethods()
{
Response response = _client.OrderMethods();
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void OrderTypes()
{
Response response = _client.OrderTypes();
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void PaymentStatuses()
{
Response response = _client.PaymentStatuses();
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void PaymentTypes()
{
Response response = _client.PaymentTypes();
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void ProductStatuses()
{
Response response = _client.ProductStatuses();
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void Sites()
{
Response response = _client.Sites();
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void StatusGroups()
{
Response response = _client.StatusGroups();
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void Statuses()
{
Response response = _client.Statuses();
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void Stores()
{
Response response = _client.Stores();
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void DeliveryServicesEdit()
{
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response response = _client.DeliveryServicesEdit(
new Dictionary<string, object>
{
{ "code", guid},
{ "name", $"TestDeliveryService-{guid}" }
}
);
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void DeliveryTypesEdit()
{
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response response = _client.DeliveryTypesEdit(
new Dictionary<string, object>
{
{ "code", guid},
{ "name", $"TestDeliveryType-{guid}" },
{ "defaultCost", 300 },
{ "defaultNetCost", 250}
}
);
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void OrderMethodsEdit()
{
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response response = _client.OrderMethodsEdit(
new Dictionary<string, object>
{
{ "code", guid},
{ "name", $"TestOrderMethod-{guid}" }
}
);
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void OrderTypesEdit()
{
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response response = _client.OrderTypesEdit(
new Dictionary<string, object>
{
{ "code", guid},
{ "name", $"TestOrderType-{guid}" }
}
);
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void PaymentStatusesEdit()
{
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response response = _client.PaymentStatusesEdit(
new Dictionary<string, object>
{
{ "code", guid},
{ "name", $"TestPaymentStatus-{guid}" }
}
);
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void PaymentTypesEdit()
{
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response response = _client.PaymentTypesEdit(
new Dictionary<string, object>
{
{ "code", guid},
{ "name", $"TestPaymentType-{guid}" }
}
);
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void ProductStatusesEdit()
{
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response response = _client.ProductStatusesEdit(
new Dictionary<string, object>
{
{ "code", guid},
{ "name", $"TestProductStatus-{guid}" }
}
);
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void SitesEdit()
{
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response response = _client.SitesEdit(
new Dictionary<string, object>
{
{ "code", guid},
{ "name", $"TestProductStatus-{guid}" },
{ "url", $"http://{guid}.example.org" }
}
);
Assert.IsFalse(response.IsSuccessfull());
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void StatusesEdit()
{
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response response = _client.StatusesEdit(
new Dictionary<string, object>
{
{ "code", guid},
{ "name", $"TestProductStatus-{guid}" },
{ "ordering", 40},
{ "group", "cancel"}
}
);
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void StoresEdit()
{
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response response = _client.StoresEdit(
new Dictionary<string, object>
{
{ "code", guid},
{ "name", $"TestProductStatus-{guid}" },
{ "type", "store-type-warehouse"}
}
);
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
}
}

View file

@ -1,14 +1,14 @@
namespace RetailcrmUnitTest.V3
{
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V3;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V3;
namespace RetailcrmUnitTest.V3
{
[TestClass]
public class StoresTest
{

View file

@ -0,0 +1,33 @@
using System.Collections.Specialized;
using System.Configuration;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V3;
namespace RetailcrmUnitTest.V3
{
[TestClass]
public class TelephonyTest
{
private readonly Client _client;
private readonly NameValueCollection _appSettings;
public TelephonyTest()
{
_appSettings = ConfigurationManager.AppSettings;
_client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"]);
}
[TestMethod]
public void TelephonyManagerGet()
{
Response response = _client.TelephonyManagerGet(_appSettings["phone"]);
Debug.WriteLine(response.GetRawResponse());
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
}
}

View file

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V4;
namespace RetailcrmUnitTest.V4
{
[TestClass]
public class CustomersTest
{
private readonly Client _client;
public CustomersTest()
{
NameValueCollection appSettings = ConfigurationManager.AppSettings;
_client = new Client(appSettings["apiUrl"], appSettings["apiKey"]);
}
[TestMethod]
public void CustomersHistory()
{
Response response = _client.CustomersHistory();
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("history"));
DateTime datetime = DateTime.Now;
Response responseFiltered = _client.CustomersHistory(
new Dictionary<string, object>
{
{ "startDate", datetime.AddMonths(-2).ToString("yyyy-MM-dd HH:mm:ss") },
{ "endDate", datetime.AddHours(-1).ToString("yyyy-MM-dd HH:mm:ss")}
}
);
Assert.IsTrue(responseFiltered.IsSuccessfull());
Assert.IsTrue(responseFiltered.GetStatusCode() == 200);
Assert.IsInstanceOfType(responseFiltered, typeof(Response));
Assert.IsTrue(responseFiltered.GetResponse().ContainsKey("history"));
}
}
}

View file

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V4;
namespace RetailcrmUnitTest.V4
{
[TestClass]
public class MarketplaceTest
{
private readonly Client _client;
public MarketplaceTest()
{
var appSettings = ConfigurationManager.AppSettings;
_client = new Client(appSettings["apiUrl"], appSettings["apiKey"]);
}
[TestMethod]
public void MarketplaceSettingsEdit()
{
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response response = _client.MarketplaceSettingsEdit(
new Dictionary<string, object>()
{
{ "name", $"MarketplaceApp-{guid}" },
{ "code", guid},
{ "configurationUrl", $"http://{guid}.example.com"},
{ "active", false}
}
);
Debug.WriteLine(response.GetRawResponse());
Assert.IsTrue(response.IsSuccessfull());
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
}
}

View file

@ -1,13 +1,13 @@
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;
using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V4;
namespace RetailcrmUnitTest.V4
{
[TestClass]
public class OrdersTest
{

View file

@ -1,11 +1,13 @@
namespace RetailcrmUnitTest.V4
{
using System.Collections.Specialized;
using System.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V4;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V4;
namespace RetailcrmUnitTest.V4
{
[TestClass]
public class ReferencesTest
{
@ -27,5 +29,24 @@
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("priceTypes"));
}
[TestMethod]
public void PriceTypesEdit()
{
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response response = _client.PriceTypesEdit(
new Dictionary<string, object>
{
{ "code", guid},
{ "name", $"TestPriceType-{guid}" }
}
);
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
}
}

View file

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V4;
namespace RetailcrmUnitTest.V4
{
[TestClass]
public class StoresTest
{
private readonly Client _client;
private readonly NameValueCollection _appSettings;
public StoresTest()
{
_appSettings = ConfigurationManager.AppSettings;
_client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"], _appSettings["site"]);
}
[TestMethod]
public void StoreProducts()
{
Response response = _client.StoreProducts();
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("products"));
}
}
}

View file

@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V4;
namespace RetailcrmUnitTest.V4
{
[TestClass]
public class TelephonyTest
{
private readonly Client _client;
private readonly NameValueCollection _appSettings;
private readonly string _phoneCode = "100";
private readonly string _logoUrl = "http://www.onsitemaintenance.com/img/voip.svg";
private readonly string _telephonyCode = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
public TelephonyTest()
{
_appSettings = ConfigurationManager.AppSettings;
_client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"]);
}
[TestMethod]
public void TelephonySettingsEdit()
{
Response response = _client.TelephonySettingsEdit(
new Dictionary<string, object>
{
{ "code", _telephonyCode},
{ "clientId", _appSettings["customer"] },
{ "makeCallUrl", $"http://{_telephonyCode}.example.com/call"},
{ "name", $"TestTelephony-{_telephonyCode}"},
{ "image", _logoUrl},
{ "inputEventSupported", true},
{ "outputEventSupported", true},
{ "hangupEventSupported", true},
{
"additionalCodes",
new List<object>
{
new Dictionary<string, object>
{
{ "userId", _appSettings["manager"] },
{ "code", _phoneCode }
}
}
}
}
);
Debug.WriteLine(response.GetRawResponse());
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void TelephonyCallEvent()
{
Response response = _client.TelephonyCallEvent(
new Dictionary<string, object>
{
{ "phone", _appSettings["phone"] },
{ "type", "in" },
{ "hangupStatus", "failed"},
{ "codes", new List<string> { _phoneCode }},
{ "userIds", new List<int> { int.Parse(_appSettings["customer"]) }}
}
);
Debug.WriteLine(response.GetRawResponse());
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
}
}

View file

@ -0,0 +1,41 @@
using System.Collections.Specialized;
using System.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V4;
namespace RetailcrmUnitTest.V4
{
[TestClass]
public class UsersTest
{
private readonly Client _client;
private readonly NameValueCollection _appSettings;
public UsersTest()
{
_appSettings = ConfigurationManager.AppSettings;
_client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"]);
}
[TestMethod]
public void UsersGroups()
{
Response usersGroups = _client.UsersGroups();
Assert.IsTrue(usersGroups.IsSuccessfull());
Assert.IsTrue(usersGroups.GetStatusCode() == 200);
Assert.IsInstanceOfType(usersGroups, typeof(Response));
Assert.IsTrue(usersGroups.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void User()
{
Response usersGroups = _client.User(int.Parse(_appSettings["manager"]));
Assert.IsTrue(usersGroups.IsSuccessfull());
Assert.IsTrue(usersGroups.GetStatusCode() == 200);
Assert.IsInstanceOfType(usersGroups, typeof(Response));
Assert.IsTrue(usersGroups.GetResponse().ContainsKey("success"));
}
}
}

View file

@ -0,0 +1,226 @@
using System;
using System.Configuration;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V5;
namespace RetailcrmUnitTest.V5
{
[TestClass]
public class CostsTest
{
private readonly Client _client;
public CostsTest()
{
var appSettings = ConfigurationManager.AppSettings;
_client = new Client(appSettings["apiUrl"], appSettings["apiKey"]);
}
[TestMethod]
public void CostsCreateUpdateReadDelete()
{
DateTime datetime = DateTime.Now;
string groupGuid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response groupResponse = _client.CostGroupsEdit(
new Dictionary<string, object>
{
{ "code", groupGuid},
{ "name", $"TestCostGroup-{groupGuid}" },
{ "color", "#60b29a" }
}
);
Debug.WriteLine(groupResponse.GetRawResponse());
Assert.IsTrue(groupResponse.IsSuccessfull());
Assert.IsTrue(groupResponse.GetStatusCode() == 200 || groupResponse.GetStatusCode() == 201);
Assert.IsInstanceOfType(groupResponse, typeof(Response));
Assert.IsTrue(groupResponse.GetResponse().ContainsKey("success"));
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response itemCostResponse = _client.CostItemsEdit(
new Dictionary<string, object>
{
{ "code", guid},
{ "group", groupGuid },
{ "name", $"TestCostItem-{guid}" },
{ "type", "const" }
}
);
Debug.WriteLine(itemCostResponse.GetRawResponse());
Assert.IsTrue(itemCostResponse.IsSuccessfull());
Assert.IsTrue(itemCostResponse.GetStatusCode() == 200 || itemCostResponse.GetStatusCode() == 201);
Assert.IsInstanceOfType(itemCostResponse, typeof(Response));
Assert.IsTrue(itemCostResponse.GetResponse().ContainsKey("success"));
Response costsCreateResponse = _client.CostsCreate(
new Dictionary<string, object>
{
{ "summ", 20000 },
{ "comment", "test cost" },
{ "costItem", guid },
{ "dateFrom", datetime.AddDays(-3).ToString("yyyy-MM-dd")},
{ "dateTo", datetime.AddDays(+3).ToString("yyyy-MM-dd")},
}
);
Debug.WriteLine(costsCreateResponse.GetRawResponse());
Assert.IsTrue(costsCreateResponse.IsSuccessfull());
Assert.IsTrue(costsCreateResponse.GetStatusCode() == 201);
Assert.IsInstanceOfType(costsCreateResponse, typeof(Response));
Assert.IsTrue(costsCreateResponse.GetResponse().ContainsKey("success"));
Response costsUpdateResponse = _client.CostsUpdate(
new Dictionary<string, object>
{
{ "id", costsCreateResponse.GetResponse()["id"].ToString()},
{ "summ", 30000 },
{ "comment", "test cost update" },
{ "costItem", guid },
{ "dateFrom", datetime.AddDays(-3).ToString("yyyy-MM-dd")},
{ "dateTo", datetime.AddDays(+3).ToString("yyyy-MM-dd")},
}
);
Debug.WriteLine(costsUpdateResponse.GetRawResponse());
Assert.IsTrue(costsUpdateResponse.IsSuccessfull());
Assert.IsTrue(costsUpdateResponse.GetStatusCode() == 200 || costsUpdateResponse.GetStatusCode() == 201);
Assert.IsInstanceOfType(costsUpdateResponse, typeof(Response));
Assert.IsTrue(costsUpdateResponse.GetResponse().ContainsKey("success"));
Response responseGet = _client.CostsGet(int.Parse(costsCreateResponse.GetResponse()["id"].ToString()));
Debug.WriteLine(responseGet.GetRawResponse());
Assert.IsTrue(responseGet.IsSuccessfull());
Assert.IsTrue(responseGet.GetStatusCode() == 200);
Assert.IsInstanceOfType(responseGet, typeof(Response));
Assert.IsTrue(responseGet.GetResponse().ContainsKey("success"));
Response response = _client.CostsDelete(costsCreateResponse.GetResponse()["id"].ToString());
Debug.WriteLine(response.GetRawResponse());
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void CostsList()
{
DateTime datetime = DateTime.Now;
Response responseFiltered = _client.CostsList(
new Dictionary<string, object>
{
{ "createdAtFrom", datetime.AddDays(-30).ToString("yyyy-MM-dd HH:mm:ss") }
},
2,
50
);
Debug.WriteLine(responseFiltered.GetRawResponse());
Assert.IsTrue(responseFiltered.IsSuccessfull());
Assert.IsTrue(responseFiltered.GetStatusCode() == 200);
Assert.IsInstanceOfType(responseFiltered, typeof(Response));
Assert.IsTrue(responseFiltered.GetResponse().ContainsKey("costs"));
}
[TestMethod]
public void 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(
new Dictionary<string, object>
{
{ "code", groupGuid},
{ "name", $"TestCostGroup-{groupGuid}" },
{ "color", "#60b29a" }
}
);
Debug.WriteLine(groupResponse.GetRawResponse());
Assert.IsTrue(groupResponse.IsSuccessfull());
Assert.IsTrue(groupResponse.GetStatusCode() == 200 || groupResponse.GetStatusCode() == 201);
Assert.IsInstanceOfType(groupResponse, typeof(Response));
Assert.IsTrue(groupResponse.GetResponse().ContainsKey("success"));
Response itemCostResponse = _client.CostItemsEdit(
new Dictionary<string, object>
{
{ "code", guid},
{ "group", groupGuid },
{ "name", $"TestCostItem-{guid}" },
{ "type", "const" }
}
);
Debug.WriteLine(itemCostResponse.GetRawResponse());
Assert.IsTrue(itemCostResponse.IsSuccessfull());
Assert.IsTrue(itemCostResponse.GetStatusCode() == 200 || itemCostResponse.GetStatusCode() == 201);
Assert.IsInstanceOfType(itemCostResponse, typeof(Response));
Assert.IsTrue(itemCostResponse.GetResponse().ContainsKey("success"));
Response costsUploadResponse = _client.CostsUpload(
new List<object>
{
new Dictionary<string, object>
{
{ "summ", 10000 },
{ "comment", "test cost 1" },
{ "costItem", guid },
{ "dateFrom", datetime.AddDays(-3).ToString("yyyy-MM-dd")},
{ "dateTo", datetime.AddDays(+3).ToString("yyyy-MM-dd")},
},
new Dictionary<string, object>
{
{ "summ", 20000 },
{ "comment", "test cost 2" },
{ "costItem", guid },
{ "dateFrom", datetime.AddDays(-3).ToString("yyyy-MM-dd")},
{ "dateTo", datetime.AddDays(+3).ToString("yyyy-MM-dd")},
},
new Dictionary<string, object>
{
{ "summ", 30000 },
{ "comment", "test cost 3" },
{ "costItem", guid },
{ "dateFrom", datetime.AddDays(-3).ToString("yyyy-MM-dd")},
{ "dateTo", datetime.AddDays(+3).ToString("yyyy-MM-dd")},
},
}
);
Debug.WriteLine(costsUploadResponse.GetRawResponse());
Assert.IsTrue(costsUploadResponse.IsSuccessfull());
Assert.IsTrue(costsUploadResponse.GetStatusCode() == 201);
Assert.IsInstanceOfType(costsUploadResponse, typeof(Response));
Assert.IsTrue(costsUploadResponse.GetResponse().ContainsKey("success"));
List<string> uploadedCosts = new List<string>();
object[] uids = (object[]) costsUploadResponse.GetResponse()["uploadedCosts"];
foreach (var uid in uids)
{
uploadedCosts.Add(uid.ToString());
}
Response costsDeleteResponse = _client.CostsDelete(uploadedCosts);
Debug.WriteLine(costsDeleteResponse.GetRawResponse());
Assert.IsTrue(costsDeleteResponse.IsSuccessfull());
Assert.IsTrue(costsDeleteResponse.GetStatusCode() == 200);
Assert.IsInstanceOfType(costsUploadResponse, typeof(Response));
Assert.IsTrue(costsUploadResponse.GetResponse().ContainsKey("success"));
}
}
}

View file

@ -0,0 +1,163 @@
using System;
using System.Configuration;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V5;
namespace RetailcrmUnitTest.V5
{
[TestClass]
public class CustomFieldsTest
{
private readonly Client _client;
public CustomFieldsTest()
{
var appSettings = ConfigurationManager.AppSettings;
_client = new Client(appSettings["apiUrl"], appSettings["apiKey"]);
}
[TestMethod]
public void CustomFieldsList()
{
Response responseFiltered = _client.CustomFieldsList(new Dictionary<string, object> { { "entity", "order" } }, 2, 50);
Debug.WriteLine(responseFiltered.GetRawResponse());
Assert.IsTrue(responseFiltered.IsSuccessfull());
Assert.IsTrue(responseFiltered.GetStatusCode() == 200);
Assert.IsInstanceOfType(responseFiltered, typeof(Response));
Assert.IsTrue(responseFiltered.GetResponse().ContainsKey("customFields"));
}
[TestMethod]
public void CustomFieldsCreateUpdateRead()
{
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response customFieldsCreateResponse = _client.CustomFieldsCreate(
new Dictionary<string, object>
{
{ "code", $"customfield{guid}" },
{ "name", $"CustomField-{guid}"},
{ "type", "string"},
{ "entity", "order"}
}
);
Debug.WriteLine(customFieldsCreateResponse.GetRawResponse());
Assert.IsTrue(customFieldsCreateResponse.IsSuccessfull());
Assert.IsTrue(customFieldsCreateResponse.GetStatusCode() == 201);
Assert.IsInstanceOfType(customFieldsCreateResponse, typeof(Response));
Assert.IsTrue(customFieldsCreateResponse.GetResponse().ContainsKey("code"));
Response customFieldGetResponse = _client.CustomFieldsGet($"customfield{guid}", "order");
Debug.WriteLine(customFieldGetResponse.GetRawResponse());
Assert.IsTrue(customFieldGetResponse.IsSuccessfull());
Assert.IsTrue(customFieldGetResponse.GetStatusCode() == 200);
Assert.IsInstanceOfType(customFieldGetResponse, typeof(Response));
Assert.IsTrue(customFieldGetResponse.GetResponse().ContainsKey("customField"));
Response customFieldsUpdateResponse = _client.CustomFieldsUpdate(
new Dictionary<string, object>
{
{ "code", $"customfield{guid}" },
{ "name", $"CustomField-{guid}"},
{ "type", "string"},
{ "entity", "order"},
{ "inList", false}
}
);
Debug.WriteLine(customFieldsUpdateResponse.GetRawResponse());
Assert.IsTrue(customFieldsUpdateResponse.IsSuccessfull());
Assert.IsTrue(customFieldsUpdateResponse.GetStatusCode() == 200);
Assert.IsInstanceOfType(customFieldsUpdateResponse, typeof(Response));
Assert.IsTrue(customFieldsUpdateResponse.GetResponse().ContainsKey("code"));
}
[TestMethod]
public void CustomDictionaryList()
{
Response responseFiltered = _client.CustomDictionaryList(new Dictionary<string, object>(), 2, 50);
Debug.WriteLine(responseFiltered.GetRawResponse());
Assert.IsTrue(responseFiltered.IsSuccessfull());
Assert.IsTrue(responseFiltered.GetStatusCode() == 200);
Assert.IsInstanceOfType(responseFiltered, typeof(Response));
Assert.IsTrue(responseFiltered.GetResponse().ContainsKey("customDictionaries"));
}
[TestMethod]
public void 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(
new Dictionary<string, object>
{
{ "code", $"customdict{guid}" },
{ "name", $"CustomDict-{guid}"},
{
"elements",
new List<object>
{
new Dictionary<string, object>
{
{ "code", $"customdictelement-{fuid}" },
{ "name", $"CustomDictElement-{fuid}" }
}
}
}
}
);
Debug.WriteLine(customDictionaryCreateResponse.GetRawResponse());
Assert.IsTrue(customDictionaryCreateResponse.IsSuccessfull());
Assert.IsTrue(customDictionaryCreateResponse.GetStatusCode() == 201);
Assert.IsInstanceOfType(customDictionaryCreateResponse, typeof(Response));
Assert.IsTrue(customDictionaryCreateResponse.GetResponse().ContainsKey("code"));
Response customDictionaryGetResponse = _client.CustomDictionaryGet(customDictionaryCreateResponse.GetResponse()["code"].ToString());
Debug.WriteLine(customDictionaryGetResponse.GetRawResponse());
Assert.IsTrue(customDictionaryGetResponse.IsSuccessfull());
Assert.IsTrue(customDictionaryGetResponse.GetStatusCode() == 200);
Assert.IsInstanceOfType(customDictionaryGetResponse, typeof(Response));
Assert.IsTrue(customDictionaryGetResponse.GetResponse().ContainsKey("customDictionary"));
Response customDictionaryEditResponse = _client.CustomDictionaryUpdate(
new Dictionary<string, object>
{
{ "code", $"customdict{guid}" },
{ "name", $"CustomDict-{guid}Edited"},
{
"elements",
new List<object>
{
new Dictionary<string, object>
{
{ "code", $"customdictelement-{fuid}" },
{ "name", $"CustomDictElement-{fuid}" }
},
new Dictionary<string, object>
{
{ "code", $"customdictelement-{fuid}1" },
{ "name", $"CustomDictElement-{fuid}1" }
}
}
}
}
);
Debug.WriteLine(customDictionaryEditResponse.GetRawResponse());
Assert.IsTrue(customDictionaryEditResponse.IsSuccessfull());
Assert.IsTrue(customDictionaryEditResponse.GetStatusCode() == 200);
Assert.IsInstanceOfType(customDictionaryEditResponse, typeof(Response));
Assert.IsTrue(customDictionaryEditResponse.GetResponse().ContainsKey("code"));
}
}
}

View file

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V5;
namespace RetailcrmUnitTest.V5
{
[TestClass]
public class IntegrationTest
{
private readonly Client _client;
public IntegrationTest()
{
var appSettings = ConfigurationManager.AppSettings;
_client = new Client(appSettings["apiUrl"], appSettings["apiKey"]);
}
[TestMethod]
public void IntegrationsSettingsEditSettingsGet()
{
string uid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response response = _client.IntegrationsSettingsEdit(
new Dictionary<string, object>
{
{ "code", uid},
{ "name", $"TestIntegration-{uid}"},
{ "active", true},
{ "accountUrl", $"http://{uid}.example.com"},
{ "logo", "https://www.ibm.com/cloud-computing/images/cloud/products/cloud-integration/api-economy-icon.svg"},
}
);
Debug.WriteLine(response.GetRawResponse());
Assert.IsTrue(response.IsSuccessfull());
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
Response responseGet = _client.IntegrationsSettingGet(uid);
Debug.WriteLine(responseGet.GetRawResponse());
Assert.IsTrue(responseGet.IsSuccessfull());
Assert.IsInstanceOfType(responseGet, typeof(Response));
Assert.IsTrue(responseGet.GetResponse().ContainsKey("success"));
}
}
}

View file

@ -0,0 +1,72 @@
using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V5;
namespace RetailcrmUnitTest.V5
{
[TestClass]
public class NotesTest
{
private readonly Client _client;
private readonly NameValueCollection _appSettings;
public NotesTest()
{
_appSettings = ConfigurationManager.AppSettings;
_client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"]);
}
[TestMethod]
public void NotesCreateDelete()
{
Response responseFiltered = _client.NotesCreate(
new Dictionary<string, object>
{
{ "text", "test task" },
{ "customer", new Dictionary<string, object> { { "id", "2015" } }},
{ "managerId", _appSettings["manager"]}
}
);
Debug.WriteLine(responseFiltered.GetRawResponse());
Assert.IsTrue(responseFiltered.IsSuccessfull());
Assert.IsTrue(responseFiltered.GetStatusCode() == 201);
Assert.IsInstanceOfType(responseFiltered, typeof(Response));
Assert.IsTrue(responseFiltered.GetResponse().ContainsKey("success"));
Response response = _client.NotesDelete(responseFiltered.GetResponse()["id"].ToString());
Debug.WriteLine(response.GetRawResponse());
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void NotesList()
{
DateTime datetime = DateTime.Now;
Response responseFiltered = _client.NotesList(
new Dictionary<string, object>
{
{ "createdAtFrom", datetime.AddDays(-30).ToString("yyyy-MM-dd HH:mm:ss") }
},
2,
50
);
Debug.WriteLine(responseFiltered.GetRawResponse());
Assert.IsTrue(responseFiltered.IsSuccessfull());
Assert.IsTrue(responseFiltered.GetStatusCode() == 200);
Assert.IsInstanceOfType(responseFiltered, typeof(Response));
Assert.IsTrue(responseFiltered.GetResponse().ContainsKey("notes"));
}
}
}

View file

@ -1,15 +1,14 @@
using System.Diagnostics;
using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V5;
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
{

View file

@ -0,0 +1,83 @@
using System;
using System.Configuration;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V5;
namespace RetailcrmUnitTest.V5
{
[TestClass]
public class PaymentsTest
{
private readonly Client _client;
public PaymentsTest()
{
var appSettings = ConfigurationManager.AppSettings;
_client = new Client(appSettings["apiUrl"], appSettings["apiKey"]);
}
[TestMethod]
public void PaymentsCreateUpdateDelete()
{
DateTime datetime = DateTime.Now;
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response createResponse = _client.OrdersCreate(new Dictionary<string, object>
{
{"externalId", guid},
{"createdAt", datetime.ToString("yyyy-MM-dd HH:mm:ss")},
{"lastName", "Doe"},
{"firstName", "John"},
{"email", "john@example.com"},
{"phone", "+79999999999"}
});
Debug.WriteLine(createResponse.GetRawResponse());
Assert.IsTrue(createResponse.IsSuccessfull());
Assert.IsInstanceOfType(createResponse, typeof(Response));
Assert.IsTrue(createResponse.GetResponse().ContainsKey("id"));
Response paymentCreateResponse = _client.PaymentsCreate(
new Dictionary<string, object>
{
{ "externalId", guid },
{ "type", "cash" },
{ "comment", "test payment" },
{ "order", new Dictionary<string, object> { { "id", createResponse.GetResponse()["id"].ToString() } } },
}
);
Debug.WriteLine(paymentCreateResponse.GetRawResponse());
Assert.IsTrue(paymentCreateResponse.IsSuccessfull());
Assert.IsTrue(paymentCreateResponse.GetStatusCode() == 201);
Assert.IsInstanceOfType(paymentCreateResponse, typeof(Response));
Assert.IsTrue(paymentCreateResponse.GetResponse().ContainsKey("success"));
Response paymentUpdateResponse = _client.PaymentsUpdate(
new Dictionary<string, object>
{
{ "id", paymentCreateResponse.GetResponse()["id"].ToString()},
{ "status", "paid"},
{ "paidAt", datetime.ToString("yyyy-MM-dd HH:mm:ss")},
{ "amount", 4000 }
}
);
Debug.WriteLine(paymentUpdateResponse.GetRawResponse());
Assert.IsTrue(paymentUpdateResponse.IsSuccessfull());
Assert.IsInstanceOfType(paymentUpdateResponse, typeof(Response));
Assert.IsTrue(paymentUpdateResponse.GetResponse().ContainsKey("success"));
Response response = _client.PaymentsDelete(paymentCreateResponse.GetResponse()["id"].ToString());
Debug.WriteLine(response.GetRawResponse());
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
}
}

View file

@ -1,11 +1,14 @@
namespace RetailcrmUnitTest.V5
{
using System.Collections.Specialized;
using System.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V5;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V5;
namespace RetailcrmUnitTest.V5
{
[TestClass]
public class ReferencesTest
{
@ -26,5 +29,105 @@
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("costGroups"));
}
[TestMethod]
public void CostItems()
{
Response response = _client.CostItems();
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("costItems"));
}
[TestMethod]
public void LegalEntities()
{
Response response = _client.LegalEntities();
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("legalEntities"));
}
[TestMethod]
public void CostGroupsEdit()
{
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response response = _client.CostGroupsEdit(
new Dictionary<string, object>
{
{ "code", guid},
{ "name", $"TestCostGroup-{guid}" },
{ "color", "#da5c98" }
}
);
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void CostItemsEdit()
{
string groupGuid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response groupResponse = _client.CostGroupsEdit(
new Dictionary<string, object>
{
{ "code", groupGuid},
{ "name", $"TestCostGroup-{groupGuid}" },
{ "color", "#60b29a" }
}
);
Assert.IsTrue(groupResponse.IsSuccessfull());
Assert.IsTrue(groupResponse.GetStatusCode() == 200 || groupResponse.GetStatusCode() == 201);
Assert.IsInstanceOfType(groupResponse, typeof(Response));
Assert.IsTrue(groupResponse.GetResponse().ContainsKey("success"));
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response response = _client.CostItemsEdit(
new Dictionary<string, object>
{
{ "code", guid},
{ "group", groupGuid },
{ "name", $"TestCostItem-{guid}" },
{ "type", "const" }
}
);
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void LegalEntitiesEdit()
{
string guid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 6);
Response response = _client.LegalEntitiesEdit(
new Dictionary<string, object>
{
{ "code", guid},
{ "legalName", $"Test LegalEntity-{guid}" },
{ "contragentType", "legal-entity"},
{ "countryIso", "RU"}
}
);
Debug.WriteLine(response.GetRawResponse());
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200 || response.GetStatusCode() == 201);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
}
}

View file

@ -0,0 +1,39 @@
using System.Collections.Specialized;
using System.Configuration;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V5;
namespace RetailcrmUnitTest.V5
{
[TestClass]
public class SegmentsTest
{
private readonly Client _client;
public SegmentsTest()
{
NameValueCollection appSettings = ConfigurationManager.AppSettings;
_client = new Client(appSettings["apiUrl"], appSettings["apiKey"]);
}
[TestMethod]
public void Segments()
{
Response responseFiltered = _client.Segments(
new Dictionary<string, object>
{
{ "active", "1" }
},
2,
50
);
Assert.IsTrue(responseFiltered.IsSuccessfull());
Assert.IsTrue(responseFiltered.GetStatusCode() == 200);
Assert.IsInstanceOfType(responseFiltered, typeof(Response));
Assert.IsTrue(responseFiltered.GetResponse().ContainsKey("segments"));
}
}
}

View file

@ -0,0 +1,91 @@
using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V5;
namespace RetailcrmUnitTest.V5
{
[TestClass]
public class TasksTest
{
private readonly Client _client;
private readonly NameValueCollection _appSettings;
public TasksTest()
{
_appSettings = ConfigurationManager.AppSettings;
_client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"]);
}
[TestMethod]
public void TasksCreateUpdateGet()
{
DateTime datetime = DateTime.Now;
Response responseFiltered = _client.TasksCreate(
new Dictionary<string, object>
{
{ "text", "test task" },
{ "commentary", "test commentary"},
{ "datetime", datetime.AddHours(+3).ToString("yyyy-MM-dd HH:mm")},
{ "performerId", _appSettings["manager"]}
}
);
Debug.WriteLine(responseFiltered.GetRawResponse());
Assert.IsTrue(responseFiltered.IsSuccessfull());
Assert.IsTrue(responseFiltered.GetStatusCode() == 201);
Assert.IsInstanceOfType(responseFiltered, typeof(Response));
Assert.IsTrue(responseFiltered.GetResponse().ContainsKey("success"));
Response response = _client.TasksUpdate(
new Dictionary<string, object>
{
{ "id", responseFiltered.GetResponse()["id"].ToString()},
{ "text", "test task edited" },
{ "commentary", "test commentary"},
{ "datetime", datetime.AddHours(+4).ToString("yyyy-MM-dd HH:mm")},
{ "performerId", _appSettings["manager"]}
}
);
Debug.WriteLine(response.GetRawResponse());
Assert.IsTrue(response.IsSuccessfull());
Assert.IsTrue(response.GetStatusCode() == 200);
Assert.IsInstanceOfType(response, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
Response responseGet = _client.TasksGet(responseFiltered.GetResponse()["id"].ToString());
Debug.WriteLine(responseGet.GetRawResponse());
Assert.IsTrue(responseGet.IsSuccessfull());
Assert.IsTrue(responseGet.GetStatusCode() == 200);
Assert.IsInstanceOfType(responseGet, typeof(Response));
Assert.IsTrue(response.GetResponse().ContainsKey("success"));
}
[TestMethod]
public void TasksList()
{
Response responseFiltered = _client.TasksList(
new Dictionary<string, object>
{
{ "performers", new List<string> { _appSettings["manager"] } },
{ "status", "performing" }
},
2,
50
);
Debug.WriteLine(responseFiltered.GetRawResponse());
Assert.IsTrue(responseFiltered.IsSuccessfull());
Assert.IsTrue(responseFiltered.GetStatusCode() == 200);
Assert.IsInstanceOfType(responseFiltered, typeof(Response));
Assert.IsTrue(responseFiltered.GetResponse().ContainsKey("tasks"));
}
}
}

View file

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm.Versions.V5;
namespace RetailcrmUnitTest.V5
{
[TestClass]
public class TelephonyTest
{
private readonly Client _client;
private readonly NameValueCollection _appSettings;
public TelephonyTest()
{
_appSettings = ConfigurationManager.AppSettings;
_client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"]);
}
[TestMethod]
[ExpectedException(typeof(ArgumentException), "This method is unavailable in API V5")]
public void TelephonySettingsGetArgumentExeption()
{
_client.TelephonySettingsGet("anycode");
}
[TestMethod]
[ExpectedException(typeof(ArgumentException), "This method is unavailable in API V5")]
public void TelephonySettingsGetTelephonySettingsEditArgumentExeption()
{
_client.TelephonySettingsEdit(new Dictionary<string, object>());
}
}
}

View file

@ -0,0 +1,43 @@
using System.Collections.Specialized;
using System.Configuration;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Retailcrm;
using Retailcrm.Versions.V5;
namespace RetailcrmUnitTest.V5
{
[TestClass]
public class UsersTest
{
private readonly Client _client;
public UsersTest()
{
NameValueCollection appSettings = ConfigurationManager.AppSettings;
_client = new Client(appSettings["apiUrl"], appSettings["apiKey"]);
}
[TestMethod]
public void UsersStatus()
{
Response users = _client.Users();
Assert.IsTrue(users.IsSuccessfull());
Assert.IsTrue(users.GetStatusCode() == 200);
Assert.IsInstanceOfType(users, typeof(Response));
Assert.IsTrue(users.GetResponse().ContainsKey("success"));
object[] list = (object[])users.GetResponse()["users"];
var user = list[0] as Dictionary<string, object>;
Debug.Assert(user != null, nameof(user) + " != null");
int uid = int.Parse(user["id"].ToString());
Response status = _client.UsersStatus(uid, "break");
Assert.IsTrue(status.IsSuccessfull());
Assert.IsTrue(status.GetStatusCode() == 200);
Assert.IsInstanceOfType(status, typeof(Response));
Assert.IsTrue(status.GetResponse().ContainsKey("success"));
}
}
}