diff --git a/.gitignore b/.gitignore index 286685f..65cd9e2 100644 --- a/.gitignore +++ b/.gitignore @@ -261,5 +261,4 @@ paket-files/ # Python Tools for Visual Studio (PTVS) __pycache__/ *.pyc -*.nuspec *.nupkg \ No newline at end of file diff --git a/LICENSE b/LICENSE index 05c7df6..dce51a1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015-2017 RetailDriver LLC +Copyright (c) 2015-2018 RetailDriver LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index c36cc55..f115734 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ -.NET-клиент RetailCRM API -========================= +[![NuGet](https://img.shields.io/nuget/v/Retailcrm.SDK.svg)](https://www.nuget.org/packages/Retailcrm.SDK/) -.NET-клиент для работы с [RetailCRM API](http://www.retailcrm.ru/docs/Developers/Index). Клиент поддерживает все доступные на текущий момент версии API (v3-v5). -Установка через NuGet ---------------------- +# retailCRM API C# client + +This is C# retailCRM API client. This library allows to use all available API versions. + +## Install ``` bash PM> Install-Package Retailcrm.SDK ``` -Примеры использования ---------------------- +## Usage -### Получение информации о заказе +### Get order ``` csharp using System.Diagnostics; @@ -31,7 +31,7 @@ if (response.isSuccessful()) { } ``` -### Создание заказа +### Create order ``` csharp using System.Diagnostics; @@ -71,3 +71,7 @@ if (response.isSuccessful()) { } ``` +### Documentation + +* [English](http://www.retailcrm.pro/docs/Developers/Index) +* [Russian](http://www.retailcrm.ru/docs/Developers/Index) diff --git a/Retailcrm/Retailcrm.nuspec b/Retailcrm/Retailcrm.nuspec new file mode 100644 index 0000000..68d6bef --- /dev/null +++ b/Retailcrm/Retailcrm.nuspec @@ -0,0 +1,18 @@ + + + + Retailcrm.SDK + 5.1.1 + $title$ + Retailcrm + Retailcrm + https://opensource.org/licenses/MIT + http://retailcrm.ru + http://www.retailcrm.ru/favicon.ico + false + Multiversion API client for RetailCRM + Update tests, setup auto builds + Copyright 2017-2018 + crm ecommerce retailcrm sdk + + \ No newline at end of file diff --git a/RetailcrmUnitTest/ApiTest.cs b/RetailcrmUnitTest/ApiTest.cs index 00dc6ef..d59c744 100644 --- a/RetailcrmUnitTest/ApiTest.cs +++ b/RetailcrmUnitTest/ApiTest.cs @@ -12,8 +12,10 @@ namespace RetailcrmUnitTest public ApiTest() { - NameValueCollection appSettings = ConfigurationManager.AppSettings; - _connection = new Connection(appSettings["apiUrl"], appSettings["apiKey"]); + _connection = new Connection( + System.Environment.GetEnvironmentVariable("RETAILCRM_URL"), + System.Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] diff --git a/RetailcrmUnitTest/App.config.dist b/RetailcrmUnitTest/App.config.dist deleted file mode 100644 index 1e318f9..0000000 --- a/RetailcrmUnitTest/App.config.dist +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/RetailcrmUnitTest/RetailcrmUnitTest.csproj b/RetailcrmUnitTest/RetailcrmUnitTest.csproj index 4e311fc..d6132f2 100644 --- a/RetailcrmUnitTest/RetailcrmUnitTest.csproj +++ b/RetailcrmUnitTest/RetailcrmUnitTest.csproj @@ -81,8 +81,6 @@ - - Designer diff --git a/RetailcrmUnitTest/V3/ClientTest.cs b/RetailcrmUnitTest/V3/ClientTest.cs index acbb2b1..ab2a986 100644 --- a/RetailcrmUnitTest/V3/ClientTest.cs +++ b/RetailcrmUnitTest/V3/ClientTest.cs @@ -1,6 +1,4 @@ -using System.Collections.Specialized; -using System.Configuration; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V3; @@ -13,8 +11,10 @@ namespace RetailcrmUnitTest.V3 public ClientTest() { - NameValueCollection appSettings = ConfigurationManager.AppSettings; - _client = new Client(appSettings["apiUrl"], appSettings["apiKey"], appSettings["site"]); + _client = new Client( + System.Environment.GetEnvironmentVariable("RETAILCRM_URL"), + System.Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] diff --git a/RetailcrmUnitTest/V3/CustomersTest.cs b/RetailcrmUnitTest/V3/CustomersTest.cs index f2487c1..8ede393 100644 --- a/RetailcrmUnitTest/V3/CustomersTest.cs +++ b/RetailcrmUnitTest/V3/CustomersTest.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.Specialized; -using System.Configuration; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V3; @@ -12,12 +10,13 @@ namespace RetailcrmUnitTest.V3 public class CustomersTest { private readonly Client _client; - private readonly NameValueCollection _appSettings; public CustomersTest() { - _appSettings = ConfigurationManager.AppSettings; - _client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] @@ -102,7 +101,7 @@ namespace RetailcrmUnitTest.V3 [TestMethod] public void CustomersList() { - _client.SetSite(_appSettings["site"]); + _client.SetSite(Environment.GetEnvironmentVariable("RETAILCRM_SITE")); Response response = _client.CustomersList(); diff --git a/RetailcrmUnitTest/V3/OrdersTest.cs b/RetailcrmUnitTest/V3/OrdersTest.cs index 0da1443..bbc307c 100644 --- a/RetailcrmUnitTest/V3/OrdersTest.cs +++ b/RetailcrmUnitTest/V3/OrdersTest.cs @@ -15,8 +15,10 @@ namespace RetailcrmUnitTest.V3 public OrdersTest() { - NameValueCollection appSettings = ConfigurationManager.AppSettings; - _client = new Client(appSettings["apiUrl"], appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] diff --git a/RetailcrmUnitTest/V3/PacksTest.cs b/RetailcrmUnitTest/V3/PacksTest.cs index 454c7ee..5efc88e 100644 --- a/RetailcrmUnitTest/V3/PacksTest.cs +++ b/RetailcrmUnitTest/V3/PacksTest.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.Specialized; -using System.Configuration; using System.Globalization; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -14,12 +12,13 @@ namespace RetailcrmUnitTest.V3 public class PacksTest { private readonly Client _client; - private readonly NameValueCollection _appSettings; public PacksTest() { - _appSettings = ConfigurationManager.AppSettings; - _client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"], _appSettings["site"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] @@ -79,7 +78,7 @@ namespace RetailcrmUnitTest.V3 { { "purchasePrice", 100 }, { "quantity", 1}, - { "store", _appSettings["store"]}, + { "store", Environment.GetEnvironmentVariable("RETAILCRM_STORE")}, { "itemId", id[0]} }; @@ -125,7 +124,7 @@ namespace RetailcrmUnitTest.V3 { Dictionary filter = new Dictionary { - { "store", _appSettings["store"]} + { "store", Environment.GetEnvironmentVariable("RETAILCRM_STORE")} }; Response response = _client.PacksList(filter, 1, 100); diff --git a/RetailcrmUnitTest/V3/ReferencesTest.cs b/RetailcrmUnitTest/V3/ReferencesTest.cs index 667d310..736230e 100644 --- a/RetailcrmUnitTest/V3/ReferencesTest.cs +++ b/RetailcrmUnitTest/V3/ReferencesTest.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.Specialized; -using System.Configuration; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V3; @@ -15,8 +13,10 @@ namespace RetailcrmUnitTest.V3 public ReferencesTest() { - NameValueCollection appSettings = ConfigurationManager.AppSettings; - _client = new Client(appSettings["apiUrl"], appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] diff --git a/RetailcrmUnitTest/V3/StoresTest.cs b/RetailcrmUnitTest/V3/StoresTest.cs index f1ae7c3..ee2f746 100644 --- a/RetailcrmUnitTest/V3/StoresTest.cs +++ b/RetailcrmUnitTest/V3/StoresTest.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.Specialized; -using System.Configuration; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; @@ -13,12 +11,13 @@ namespace RetailcrmUnitTest.V3 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"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] @@ -33,7 +32,7 @@ namespace RetailcrmUnitTest.V3 { new Dictionary { - { "code", _appSettings["store"] }, + { "code", Environment.GetEnvironmentVariable("RETAILCRM_STORE") }, { "available", 500 }, { "purchasePrice", 300} } @@ -47,7 +46,7 @@ namespace RetailcrmUnitTest.V3 { new Dictionary { - { "code", _appSettings["store"] }, + { "code", Environment.GetEnvironmentVariable("RETAILCRM_STORE") }, { "available", 600 }, { "purchasePrice", 350} } @@ -61,7 +60,7 @@ namespace RetailcrmUnitTest.V3 { new Dictionary { - { "code", _appSettings["store"] }, + { "code", Environment.GetEnvironmentVariable("RETAILCRM_STORE") }, { "available", 700 }, { "purchasePrice", 400} } @@ -83,7 +82,7 @@ namespace RetailcrmUnitTest.V3 { Dictionary filter = new Dictionary { - { "site", _appSettings["site"]}, + { "site", Environment.GetEnvironmentVariable("RETAILCRM_SITE")}, { "details", 1} }; @@ -121,7 +120,7 @@ namespace RetailcrmUnitTest.V3 { new Dictionary { - { "code", _appSettings["store"] }, + { "code", Environment.GetEnvironmentVariable("RETAILCRM_STORE") }, { "available", 700 }, { "purchasePrice", 400} } diff --git a/RetailcrmUnitTest/V3/TelephonyTest.cs b/RetailcrmUnitTest/V3/TelephonyTest.cs index 22ab2e9..066dc32 100644 --- a/RetailcrmUnitTest/V3/TelephonyTest.cs +++ b/RetailcrmUnitTest/V3/TelephonyTest.cs @@ -1,5 +1,4 @@ -using System.Collections.Specialized; -using System.Configuration; +using System; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; @@ -11,18 +10,19 @@ namespace RetailcrmUnitTest.V3 public class TelephonyTest { private readonly Client _client; - private readonly NameValueCollection _appSettings; - + public TelephonyTest() { - _appSettings = ConfigurationManager.AppSettings; - _client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] public void TelephonyManagerGet() { - Response response = _client.TelephonyManagerGet(_appSettings["phone"]); + Response response = _client.TelephonyManagerGet("+79999999999"); Debug.WriteLine(response.GetRawResponse()); Assert.IsTrue(response.IsSuccessfull()); Assert.IsTrue(response.GetStatusCode() == 200); diff --git a/RetailcrmUnitTest/V4/CustomersTest.cs b/RetailcrmUnitTest/V4/CustomersTest.cs index 38f6b3c..dd04132 100644 --- a/RetailcrmUnitTest/V4/CustomersTest.cs +++ b/RetailcrmUnitTest/V4/CustomersTest.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.Specialized; -using System.Configuration; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V4; @@ -15,8 +13,10 @@ namespace RetailcrmUnitTest.V4 public CustomersTest() { - NameValueCollection appSettings = ConfigurationManager.AppSettings; - _client = new Client(appSettings["apiUrl"], appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] diff --git a/RetailcrmUnitTest/V4/MarketplaceTest.cs b/RetailcrmUnitTest/V4/MarketplaceTest.cs index c18875f..01fe650 100644 --- a/RetailcrmUnitTest/V4/MarketplaceTest.cs +++ b/RetailcrmUnitTest/V4/MarketplaceTest.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Configuration; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; @@ -15,8 +14,10 @@ namespace RetailcrmUnitTest.V4 public MarketplaceTest() { - var appSettings = ConfigurationManager.AppSettings; - _client = new Client(appSettings["apiUrl"], appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] diff --git a/RetailcrmUnitTest/V4/OrdersTest.cs b/RetailcrmUnitTest/V4/OrdersTest.cs index 91e4989..b28ce04 100644 --- a/RetailcrmUnitTest/V4/OrdersTest.cs +++ b/RetailcrmUnitTest/V4/OrdersTest.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Specialized; -using System.Configuration; using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; @@ -15,8 +13,10 @@ namespace RetailcrmUnitTest.V4 public OrdersTest() { - NameValueCollection appSettings = ConfigurationManager.AppSettings; - _client = new Client(appSettings["apiUrl"], appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] diff --git a/RetailcrmUnitTest/V4/ReferencesTest.cs b/RetailcrmUnitTest/V4/ReferencesTest.cs index 00aa3e1..64a96da 100644 --- a/RetailcrmUnitTest/V4/ReferencesTest.cs +++ b/RetailcrmUnitTest/V4/ReferencesTest.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.Specialized; -using System.Configuration; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V4; @@ -15,8 +13,10 @@ namespace RetailcrmUnitTest.V4 public ReferencesTest() { - NameValueCollection appSettings = ConfigurationManager.AppSettings; - _client = new Client(appSettings["apiUrl"], appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] diff --git a/RetailcrmUnitTest/V4/StoresTest.cs b/RetailcrmUnitTest/V4/StoresTest.cs index ee1598d..fd98a7f 100644 --- a/RetailcrmUnitTest/V4/StoresTest.cs +++ b/RetailcrmUnitTest/V4/StoresTest.cs @@ -1,8 +1,5 @@ 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; @@ -17,8 +14,10 @@ namespace RetailcrmUnitTest.V4 public StoresTest() { - _appSettings = ConfigurationManager.AppSettings; - _client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"], _appSettings["site"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] diff --git a/RetailcrmUnitTest/V4/TelephonyTest.cs b/RetailcrmUnitTest/V4/TelephonyTest.cs index 9b30814..ec1ffbe 100644 --- a/RetailcrmUnitTest/V4/TelephonyTest.cs +++ b/RetailcrmUnitTest/V4/TelephonyTest.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.Specialized; -using System.Configuration; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; @@ -13,15 +11,16 @@ namespace RetailcrmUnitTest.V4 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"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] @@ -32,7 +31,7 @@ namespace RetailcrmUnitTest.V4 { { "code", _telephonyCode}, - { "clientId", _appSettings["customer"] }, + { "clientId", "4717" }, { "makeCallUrl", $"http://{_telephonyCode}.example.com/call"}, { "name", $"TestTelephony-{_telephonyCode}"}, { "image", _logoUrl}, @@ -45,7 +44,7 @@ namespace RetailcrmUnitTest.V4 { new Dictionary { - { "userId", _appSettings["manager"] }, + { "userId", Environment.GetEnvironmentVariable("RETAILCRM_USER") }, { "code", _phoneCode } } } @@ -66,11 +65,11 @@ namespace RetailcrmUnitTest.V4 Response response = _client.TelephonyCallEvent( new Dictionary { - { "phone", _appSettings["phone"] }, + { "phone", "+79999999999" }, { "type", "in" }, { "hangupStatus", "failed"}, { "codes", new List { _phoneCode }}, - { "userIds", new List { int.Parse(_appSettings["customer"]) }} + { "userIds", new List { int.Parse(Environment.GetEnvironmentVariable("RETAILCRM_USER")) }} } ); diff --git a/RetailcrmUnitTest/V4/UsersTest.cs b/RetailcrmUnitTest/V4/UsersTest.cs index 5a8a441..84c2aad 100644 --- a/RetailcrmUnitTest/V4/UsersTest.cs +++ b/RetailcrmUnitTest/V4/UsersTest.cs @@ -1,5 +1,4 @@ -using System.Collections.Specialized; -using System.Configuration; +using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; using Retailcrm.Versions.V4; @@ -10,12 +9,13 @@ namespace RetailcrmUnitTest.V4 public class UsersTest { private readonly Client _client; - private readonly NameValueCollection _appSettings; public UsersTest() { - _appSettings = ConfigurationManager.AppSettings; - _client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] @@ -31,7 +31,7 @@ namespace RetailcrmUnitTest.V4 [TestMethod] public void User() { - Response usersGroups = _client.User(int.Parse(_appSettings["manager"])); + Response usersGroups = _client.User(int.Parse(Environment.GetEnvironmentVariable("RETAILCRM_USER"))); Assert.IsTrue(usersGroups.IsSuccessfull()); Assert.IsTrue(usersGroups.GetStatusCode() == 200); Assert.IsInstanceOfType(usersGroups, typeof(Response)); diff --git a/RetailcrmUnitTest/V5/CostsTest.cs b/RetailcrmUnitTest/V5/CostsTest.cs index 77012dc..2b3bd25 100644 --- a/RetailcrmUnitTest/V5/CostsTest.cs +++ b/RetailcrmUnitTest/V5/CostsTest.cs @@ -1,5 +1,4 @@ using System; -using System.Configuration; using System.Collections.Generic; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -15,8 +14,10 @@ namespace RetailcrmUnitTest.V5 public CostsTest() { - var appSettings = ConfigurationManager.AppSettings; - _client = new Client(appSettings["apiUrl"], appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] diff --git a/RetailcrmUnitTest/V5/CustomFieldsTest.cs b/RetailcrmUnitTest/V5/CustomFieldsTest.cs index ab42b21..31905b1 100644 --- a/RetailcrmUnitTest/V5/CustomFieldsTest.cs +++ b/RetailcrmUnitTest/V5/CustomFieldsTest.cs @@ -1,5 +1,4 @@ using System; -using System.Configuration; using System.Collections.Generic; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -15,8 +14,10 @@ namespace RetailcrmUnitTest.V5 public CustomFieldsTest() { - var appSettings = ConfigurationManager.AppSettings; - _client = new Client(appSettings["apiUrl"], appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] diff --git a/RetailcrmUnitTest/V5/IntegrationTest.cs b/RetailcrmUnitTest/V5/IntegrationTest.cs index c53ca08..8b462f0 100644 --- a/RetailcrmUnitTest/V5/IntegrationTest.cs +++ b/RetailcrmUnitTest/V5/IntegrationTest.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Configuration; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; @@ -15,8 +14,10 @@ namespace RetailcrmUnitTest.V5 public IntegrationTest() { - var appSettings = ConfigurationManager.AppSettings; - _client = new Client(appSettings["apiUrl"], appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] @@ -29,6 +30,7 @@ namespace RetailcrmUnitTest.V5 { { "code", uid}, { "name", $"TestIntegration-{uid}"}, + { "clientId", uid}, { "active", true}, { "accountUrl", $"http://{uid}.example.com"}, { "logo", "https://www.ibm.com/cloud-computing/images/cloud/products/cloud-integration/api-economy-icon.svg"}, diff --git a/RetailcrmUnitTest/V5/NotesTest.cs b/RetailcrmUnitTest/V5/NotesTest.cs index a3711be..845a8be 100644 --- a/RetailcrmUnitTest/V5/NotesTest.cs +++ b/RetailcrmUnitTest/V5/NotesTest.cs @@ -13,12 +13,13 @@ namespace RetailcrmUnitTest.V5 public class NotesTest { private readonly Client _client; - private readonly NameValueCollection _appSettings; public NotesTest() { - _appSettings = ConfigurationManager.AppSettings; - _client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] @@ -28,8 +29,8 @@ namespace RetailcrmUnitTest.V5 new Dictionary { { "text", "test task" }, - { "customer", new Dictionary { { "id", "2015" } }}, - { "managerId", _appSettings["manager"]} + { "customer", new Dictionary { { "id", "4717" } }}, + { "managerId", Environment.GetEnvironmentVariable("RETAILCRM_USER")} } ); diff --git a/RetailcrmUnitTest/V5/OrdersTest.cs b/RetailcrmUnitTest/V5/OrdersTest.cs index cfd3fd5..2e1b2f1 100644 --- a/RetailcrmUnitTest/V5/OrdersTest.cs +++ b/RetailcrmUnitTest/V5/OrdersTest.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Specialized; -using System.Configuration; using System.Collections.Generic; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -16,8 +14,10 @@ namespace RetailcrmUnitTest.V5 public OrdersTest() { - NameValueCollection appSettings = ConfigurationManager.AppSettings; - _client = new Client(appSettings["apiUrl"], appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] diff --git a/RetailcrmUnitTest/V5/PaymentsTest.cs b/RetailcrmUnitTest/V5/PaymentsTest.cs index ed931b8..72fe62c 100644 --- a/RetailcrmUnitTest/V5/PaymentsTest.cs +++ b/RetailcrmUnitTest/V5/PaymentsTest.cs @@ -1,5 +1,4 @@ using System; -using System.Configuration; using System.Collections.Generic; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -15,8 +14,10 @@ namespace RetailcrmUnitTest.V5 public PaymentsTest() { - var appSettings = ConfigurationManager.AppSettings; - _client = new Client(appSettings["apiUrl"], appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] diff --git a/RetailcrmUnitTest/V5/ReferencesTest.cs b/RetailcrmUnitTest/V5/ReferencesTest.cs index 1a9ba72..96e17c5 100644 --- a/RetailcrmUnitTest/V5/ReferencesTest.cs +++ b/RetailcrmUnitTest/V5/ReferencesTest.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.Specialized; -using System.Configuration; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; @@ -16,8 +14,10 @@ namespace RetailcrmUnitTest.V5 public ReferencesTest() { - NameValueCollection appSettings = ConfigurationManager.AppSettings; - _client = new Client(appSettings["apiUrl"], appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] diff --git a/RetailcrmUnitTest/V5/SegmentsTest.cs b/RetailcrmUnitTest/V5/SegmentsTest.cs index 713b009..62000b0 100644 --- a/RetailcrmUnitTest/V5/SegmentsTest.cs +++ b/RetailcrmUnitTest/V5/SegmentsTest.cs @@ -1,5 +1,4 @@ -using System.Collections.Specialized; -using System.Configuration; +using System; using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm; @@ -14,8 +13,10 @@ namespace RetailcrmUnitTest.V5 public SegmentsTest() { - NameValueCollection appSettings = ConfigurationManager.AppSettings; - _client = new Client(appSettings["apiUrl"], appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] diff --git a/RetailcrmUnitTest/V5/TasksTest.cs b/RetailcrmUnitTest/V5/TasksTest.cs index f13e78d..2f7b20b 100644 --- a/RetailcrmUnitTest/V5/TasksTest.cs +++ b/RetailcrmUnitTest/V5/TasksTest.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Specialized; -using System.Configuration; using System.Collections.Generic; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -13,12 +11,13 @@ namespace RetailcrmUnitTest.V5 public class TasksTest { private readonly Client _client; - private readonly NameValueCollection _appSettings; public TasksTest() { - _appSettings = ConfigurationManager.AppSettings; - _client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] @@ -32,7 +31,7 @@ namespace RetailcrmUnitTest.V5 { "text", "test task" }, { "commentary", "test commentary"}, { "datetime", datetime.AddHours(+3).ToString("yyyy-MM-dd HH:mm")}, - { "performerId", _appSettings["manager"]} + { "performerId", Environment.GetEnvironmentVariable("RETAILCRM_USER")} } ); @@ -49,7 +48,7 @@ namespace RetailcrmUnitTest.V5 { "text", "test task edited" }, { "commentary", "test commentary"}, { "datetime", datetime.AddHours(+4).ToString("yyyy-MM-dd HH:mm")}, - { "performerId", _appSettings["manager"]} + { "performerId", Environment.GetEnvironmentVariable("RETAILCRM_USER")} } ); @@ -74,7 +73,7 @@ namespace RetailcrmUnitTest.V5 Response responseFiltered = _client.TasksList( new Dictionary { - { "performers", new List { _appSettings["manager"] } }, + { "performers", new List { Environment.GetEnvironmentVariable("RETAILCRM_USER") } }, { "status", "performing" } }, 2, diff --git a/RetailcrmUnitTest/V5/TelephonyTest.cs b/RetailcrmUnitTest/V5/TelephonyTest.cs index 9a962da..2d0bab8 100644 --- a/RetailcrmUnitTest/V5/TelephonyTest.cs +++ b/RetailcrmUnitTest/V5/TelephonyTest.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.Specialized; -using System.Configuration; using Microsoft.VisualStudio.TestTools.UnitTesting; using Retailcrm.Versions.V5; @@ -11,12 +9,13 @@ namespace RetailcrmUnitTest.V5 public class TelephonyTest { private readonly Client _client; - private readonly NameValueCollection _appSettings; public TelephonyTest() { - _appSettings = ConfigurationManager.AppSettings; - _client = new Client(_appSettings["apiUrl"], _appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod] diff --git a/RetailcrmUnitTest/V5/UsersTest.cs b/RetailcrmUnitTest/V5/UsersTest.cs index 18fc7ce..2f42b43 100644 --- a/RetailcrmUnitTest/V5/UsersTest.cs +++ b/RetailcrmUnitTest/V5/UsersTest.cs @@ -1,5 +1,4 @@ -using System.Collections.Specialized; -using System.Configuration; +using System; using System.Collections.Generic; using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -15,8 +14,10 @@ namespace RetailcrmUnitTest.V5 public UsersTest() { - NameValueCollection appSettings = ConfigurationManager.AppSettings; - _client = new Client(appSettings["apiUrl"], appSettings["apiKey"]); + _client = new Client( + Environment.GetEnvironmentVariable("RETAILCRM_URL"), + Environment.GetEnvironmentVariable("RETAILCRM_KEY") + ); } [TestMethod]