mirror of
https://github.com/retailcrm/api-client-dotnet.git
synced 2024-11-21 20:36:02 +03:00
commit
4b4960b244
@ -1,6 +1,5 @@
|
|||||||
[![Visual Studio Team services](https://img.shields.io/vso/build/gwinn/f01d2ec1-f511-4908-8c02-d48757d71370/3.svg?style=flat-square)](https://visualstudio.com)
|
[![Visual Studio Team services](https://img.shields.io/vso/build/gwinn/f01d2ec1-f511-4908-8c02-d48757d71370/3.svg?style=flat-square)](https://visualstudio.com)
|
||||||
[![NuGet](https://img.shields.io/nuget/v/Retailcrm.SDK.svg?style=flat-square)](https://www.nuget.org/packages/Retailcrm.SDK/)
|
[![NuGet](https://img.shields.io/nuget/v/Retailcrm.SDK.svg)](https://www.nuget.org/packages/Retailcrm.SDK/)
|
||||||
|
|
||||||
|
|
||||||
# retailCRM API C# client
|
# retailCRM API C# client
|
||||||
|
|
||||||
|
@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
|
|||||||
// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
|
// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
|
||||||
// связанные со сборкой.
|
// связанные со сборкой.
|
||||||
[assembly: AssemblyTitle("Retailcrm.SDK")]
|
[assembly: AssemblyTitle("Retailcrm.SDK")]
|
||||||
[assembly: AssemblyDescription("Multiversion API client for RetailCRM")]
|
[assembly: AssemblyDescription("Multiversion API client for retailCRM")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("RetailDriver LLC")]
|
[assembly: AssemblyCompany("RetailDriver LLC")]
|
||||||
[assembly: AssemblyProduct("Retailcrm.SDK")]
|
[assembly: AssemblyProduct("Retailcrm.SDK")]
|
||||||
[assembly: AssemblyCopyright("Copyright © RetailDriver LLC 2017")]
|
[assembly: AssemblyCopyright("Copyright © RetailDriver LLC 2019")]
|
||||||
[assembly: AssemblyTrademark("RetailDriver LLC")]
|
[assembly: AssemblyTrademark("RetailDriver LLC")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
namespace Retailcrm
|
namespace Retailcrm
|
||||||
{
|
{
|
||||||
@ -37,8 +38,8 @@ namespace Retailcrm
|
|||||||
return String.Join(argSeperator,
|
return String.Join(argSeperator,
|
||||||
_keyValuePairs.Select(kvp =>
|
_keyValuePairs.Select(kvp =>
|
||||||
{
|
{
|
||||||
var key = Uri.EscapeDataString(kvp.Key);
|
var key = HttpUtility.UrlEncode(kvp.Key);
|
||||||
var value = Uri.EscapeDataString(kvp.Value.ToString());
|
var value = HttpUtility.UrlEncode(kvp.Value.ToString());
|
||||||
return $"{key}={value}";
|
return $"{key}={value}";
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,6 @@ namespace Retailcrm
|
|||||||
}
|
}
|
||||||
|
|
||||||
Exception exception = null;
|
Exception exception = null;
|
||||||
|
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(path);
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(path);
|
||||||
request.Method = method;
|
request.Method = method;
|
||||||
|
|
||||||
@ -112,7 +111,6 @@ namespace Retailcrm
|
|||||||
throw new WebException(exception.ToString(), exception);
|
throw new WebException(exception.ToString(), exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReSharper disable once AssignNullToNotNullAttribute
|
|
||||||
StreamReader reader = new StreamReader(response.GetResponseStream());
|
StreamReader reader = new StreamReader(response.GetResponseStream());
|
||||||
string responseBody = reader.ReadToEnd();
|
string responseBody = reader.ReadToEnd();
|
||||||
int statusCode = (int)response.StatusCode;
|
int statusCode = (int)response.StatusCode;
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Runtime.Serialization" />
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
|
<Reference Include="System.Web" />
|
||||||
<Reference Include="System.Web.Extensions" />
|
<Reference Include="System.Web.Extensions" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
|
@ -2,17 +2,17 @@
|
|||||||
<package >
|
<package >
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>Retailcrm.SDK</id>
|
<id>Retailcrm.SDK</id>
|
||||||
<version>5.1.1</version>
|
<version>5.1.2</version>
|
||||||
<title>$title$</title>
|
<title>$title$</title>
|
||||||
<authors>Retailcrm</authors>
|
<authors>retailCRM</authors>
|
||||||
<owners>Retailcrm</owners>
|
<owners>retailCRM</owners>
|
||||||
<licenseUrl>https://opensource.org/licenses/MIT</licenseUrl>
|
<license type="expression">MIT</license>
|
||||||
<projectUrl>http://retailcrm.ru</projectUrl>
|
<projectUrl>https://retailcrm.ru</projectUrl>
|
||||||
<iconUrl>http://www.retailcrm.ru/favicon.ico</iconUrl>
|
<iconUrl>https://help.retailcrm.ru/favicon.ico</iconUrl>
|
||||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||||
<description>Multiversion API client for RetailCRM</description>
|
<description>Multiversion API client for retailCRM</description>
|
||||||
<releaseNotes>Update tests, setup auto builds</releaseNotes>
|
<releaseNotes>Fix POST request for big data</releaseNotes>
|
||||||
<copyright>Copyright 2017-2018</copyright>
|
<copyright>Copyright 2017-2019</copyright>
|
||||||
<tags>crm ecommerce retailcrm sdk</tags>
|
<tags>crm ecommerce retailcrm sdk</tags>
|
||||||
</metadata>
|
</metadata>
|
||||||
</package>
|
</package>
|
@ -1,6 +1,4 @@
|
|||||||
using System.Collections.Specialized;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using System.Configuration;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using Retailcrm;
|
using Retailcrm;
|
||||||
|
|
||||||
namespace RetailcrmUnitTest
|
namespace RetailcrmUnitTest
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" />
|
<Import Project="..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.props')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
@ -39,10 +39,10 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
|
<HintPath>..\packages\MSTest.TestFramework.1.4.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\MSTest.TestFramework.1.2.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
<HintPath>..\packages\MSTest.TestFramework.1.4.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
@ -95,8 +95,8 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ErrorText>Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}.</ErrorText>
|
<ErrorText>Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}.</ErrorText>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props'))" />
|
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.props'))" />
|
||||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets'))" />
|
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.targets'))" />
|
||||||
</Target>
|
</Target>
|
||||||
<Import Project="..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.targets')" />
|
<Import Project="..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.targets')" />
|
||||||
</Project>
|
</Project>
|
@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
|
||||||
using System.Configuration;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Retailcrm;
|
using Retailcrm;
|
||||||
using Retailcrm.Versions.V3;
|
using Retailcrm.Versions.V3;
|
||||||
|
@ -37,5 +37,113 @@ namespace RetailcrmUnitTest.V4
|
|||||||
Assert.IsInstanceOfType(response, typeof(Response));
|
Assert.IsInstanceOfType(response, typeof(Response));
|
||||||
Assert.IsTrue(response.GetResponse().ContainsKey("history"));
|
Assert.IsTrue(response.GetResponse().ContainsKey("history"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void BigOrderCreateUpdate()
|
||||||
|
{
|
||||||
|
long epochTicks = new DateTime(1970, 1, 1).Ticks;
|
||||||
|
long unixTime = ((DateTime.UtcNow.Ticks - epochTicks) / TimeSpan.TicksPerSecond);
|
||||||
|
|
||||||
|
List<Dictionary<string, object>> items = new List<Dictionary<string, object>>();
|
||||||
|
Dictionary<string, object> properties = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
for (int j = 0; j < 10; j++)
|
||||||
|
{
|
||||||
|
properties.Add(
|
||||||
|
$"property_{j}",
|
||||||
|
new Dictionary<string, object> {
|
||||||
|
{ "name", $"Property_{j}" },
|
||||||
|
{ "code", $"property_{j}" },
|
||||||
|
{ "value", $"{Guid.NewGuid().ToString()}" },
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
Dictionary<string, object> item = new Dictionary<string, object> {
|
||||||
|
{ "initialPrice", i + 100 },
|
||||||
|
{ "purchasePrice", i + 90 },
|
||||||
|
{ "productName", $"Product_{i}" },
|
||||||
|
{ "quantity", 2 },
|
||||||
|
{
|
||||||
|
"offer",
|
||||||
|
new Dictionary<string, object> {
|
||||||
|
{ "name", $"Product_{i}" },
|
||||||
|
{ "xmlId", $"{Guid.NewGuid().ToString()}" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ "properties", properties }
|
||||||
|
};
|
||||||
|
|
||||||
|
items.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, object> order = new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{"number", unixTime},
|
||||||
|
{"createdAt", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
|
||||||
|
{"lastName", "Doe"},
|
||||||
|
{"firstName", "John"},
|
||||||
|
{"email", "john@example.com"},
|
||||||
|
{"phone", "+79999999999"},
|
||||||
|
{"items", items},
|
||||||
|
{
|
||||||
|
"delivery",
|
||||||
|
new Dictionary<string, object> {
|
||||||
|
{ "code", "self-delivery" },
|
||||||
|
{ "cost", "300" },
|
||||||
|
{
|
||||||
|
"address", new Dictionary<string, object> {
|
||||||
|
{ "city", "Москва" },
|
||||||
|
{ "street", "Ярославская" },
|
||||||
|
{ "building", "10" },
|
||||||
|
{ "flat", "2" },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Response createResponse = _client.OrdersCreate(order);
|
||||||
|
|
||||||
|
Assert.IsTrue(createResponse.IsSuccessfull());
|
||||||
|
Assert.IsInstanceOfType(createResponse, typeof(Response));
|
||||||
|
Assert.AreEqual(createResponse.GetStatusCode(), 201);
|
||||||
|
Assert.IsTrue(createResponse.GetResponse().ContainsKey("id"));
|
||||||
|
|
||||||
|
List<Dictionary<string, object>> newItems = new List<Dictionary<string, object>>();
|
||||||
|
|
||||||
|
for (int i = 0; i < 120; i++)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> item = new Dictionary<string, object> {
|
||||||
|
{ "initialPrice", i + 100 },
|
||||||
|
{ "purchasePrice", i + 90 },
|
||||||
|
{ "productName", $"Product_{i}" },
|
||||||
|
{ "quantity", 2 },
|
||||||
|
{
|
||||||
|
"offer",
|
||||||
|
new Dictionary<string, object> {
|
||||||
|
{ "name", $"Product_{i}" },
|
||||||
|
{ "xmlId", $"{Guid.NewGuid().ToString()}" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ "properties", properties }
|
||||||
|
};
|
||||||
|
|
||||||
|
newItems.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
Response updateResponse = _client.OrdersUpdate(
|
||||||
|
new Dictionary<string, object> {
|
||||||
|
{ "id", createResponse.GetResponse()["id"].ToString()},
|
||||||
|
{ "items", newItems }
|
||||||
|
},
|
||||||
|
"id"
|
||||||
|
);
|
||||||
|
|
||||||
|
Assert.IsTrue(updateResponse.IsSuccessfull());
|
||||||
|
Assert.IsInstanceOfType(updateResponse, typeof(Response));
|
||||||
|
Assert.AreEqual(updateResponse.GetStatusCode(), 200);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="MSTest.TestAdapter" version="1.2.0" targetFramework="net45" />
|
<package id="MSTest.TestAdapter" version="1.4.0" targetFramework="net45" />
|
||||||
<package id="MSTest.TestFramework" version="1.2.0" targetFramework="net45" />
|
<package id="MSTest.TestFramework" version="1.4.0" targetFramework="net45" />
|
||||||
</packages>
|
</packages>
|
Loading…
Reference in New Issue
Block a user