mirror of
https://github.com/retailcrm/api-client-dotnet.git
synced 2024-11-21 20:36:02 +03:00
fix big data urlencode
This commit is contained in:
parent
2bfeac24e8
commit
c6b1050d04
@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
|
||||
// набора атрибутов. Измените значения этих атрибутов, чтобы изменить сведения,
|
||||
// связанные со сборкой.
|
||||
[assembly: AssemblyTitle("Retailcrm.SDK")]
|
||||
[assembly: AssemblyDescription("Multiversion API client for RetailCRM")]
|
||||
[assembly: AssemblyDescription("Multiversion API client for retailCRM")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("RetailDriver LLC")]
|
||||
[assembly: AssemblyProduct("Retailcrm.SDK")]
|
||||
[assembly: AssemblyCopyright("Copyright © RetailDriver LLC 2017")]
|
||||
[assembly: AssemblyCopyright("Copyright © RetailDriver LLC 2019")]
|
||||
[assembly: AssemblyTrademark("RetailDriver LLC")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Retailcrm
|
||||
{
|
||||
@ -37,8 +38,8 @@ namespace Retailcrm
|
||||
return String.Join(argSeperator,
|
||||
_keyValuePairs.Select(kvp =>
|
||||
{
|
||||
var key = Uri.EscapeDataString(kvp.Key);
|
||||
var value = Uri.EscapeDataString(kvp.Value.ToString());
|
||||
var key = HttpUtility.UrlEncode(kvp.Key);
|
||||
var value = HttpUtility.UrlEncode(kvp.Value.ToString());
|
||||
return $"{key}={value}";
|
||||
}));
|
||||
}
|
||||
|
@ -77,7 +77,6 @@ namespace Retailcrm
|
||||
}
|
||||
|
||||
Exception exception = null;
|
||||
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(path);
|
||||
request.Method = method;
|
||||
|
||||
@ -112,7 +111,6 @@ namespace Retailcrm
|
||||
throw new WebException(exception.ToString(), exception);
|
||||
}
|
||||
|
||||
// ReSharper disable once AssignNullToNotNullAttribute
|
||||
StreamReader reader = new StreamReader(response.GetResponseStream());
|
||||
string responseBody = reader.ReadToEnd();
|
||||
int statusCode = (int)response.StatusCode;
|
||||
|
@ -34,6 +34,7 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
|
@ -2,17 +2,17 @@
|
||||
<package >
|
||||
<metadata>
|
||||
<id>Retailcrm.SDK</id>
|
||||
<version>5.1.1</version>
|
||||
<version>5.1.2</version>
|
||||
<title>$title$</title>
|
||||
<authors>Retailcrm</authors>
|
||||
<owners>Retailcrm</owners>
|
||||
<licenseUrl>https://opensource.org/licenses/MIT</licenseUrl>
|
||||
<projectUrl>http://retailcrm.ru</projectUrl>
|
||||
<iconUrl>http://www.retailcrm.ru/favicon.ico</iconUrl>
|
||||
<authors>retailCRM</authors>
|
||||
<owners>retailCRM</owners>
|
||||
<license type="expression">MIT</license>
|
||||
<projectUrl>https://retailcrm.ru</projectUrl>
|
||||
<iconUrl>https://help.retailcrm.ru/favicon.ico</iconUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<description>Multiversion API client for RetailCRM</description>
|
||||
<releaseNotes>Update tests, setup auto builds</releaseNotes>
|
||||
<copyright>Copyright 2017-2018</copyright>
|
||||
<description>Multiversion API client for retailCRM</description>
|
||||
<releaseNotes>Fix POST request for big data</releaseNotes>
|
||||
<copyright>Copyright 2017-2019</copyright>
|
||||
<tags>crm ecommerce retailcrm sdk</tags>
|
||||
</metadata>
|
||||
</package>
|
@ -1,6 +1,4 @@
|
||||
using System.Collections.Specialized;
|
||||
using System.Configuration;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Retailcrm;
|
||||
|
||||
namespace RetailcrmUnitTest
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
@ -39,10 +39,10 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<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 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 Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
@ -95,8 +95,8 @@
|
||||
<PropertyGroup>
|
||||
<ErrorText>Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их. Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}.</ErrorText>
|
||||
</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.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.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.props'))" />
|
||||
<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>
|
||||
<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>
|
@ -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;
|
||||
|
@ -37,5 +37,113 @@ namespace RetailcrmUnitTest.V4
|
||||
Assert.IsInstanceOfType(response, typeof(Response));
|
||||
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"?>
|
||||
<packages>
|
||||
<package id="MSTest.TestAdapter" version="1.2.0" targetFramework="net45" />
|
||||
<package id="MSTest.TestFramework" version="1.2.0" targetFramework="net45" />
|
||||
<package id="MSTest.TestAdapter" version="1.4.0" targetFramework="net45" />
|
||||
<package id="MSTest.TestFramework" version="1.4.0" targetFramework="net45" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user