Compare commits

..

14 commits

Author SHA1 Message Date
Alex Lushpai
0c784f003c
Update product name, cleanup annotations (#15) 2020-12-15 13:29:48 +03:00
Alex Lushpai
b8794e57ed
Update README.md 2020-02-20 00:46:47 +03:00
Alex Lushpai
3b9a6c5f4d
Merge pull request #14 from gwinn/master
CI configuration
2020-02-20 00:43:57 +03:00
Alex Lushpai
f7fb252310 badge for upstream 2020-02-20 00:35:09 +03:00
Alex Lushpai
f1aaf3c3d0 update readme, tmp ignore for ci setup 2020-02-20 00:12:18 +03:00
Alex Lushpai
e45abd6629 update build configuration 2020-02-20 00:04:49 +03:00
Alex Lushpai
4079e735a8
Rename appveyour.yml to appveyor.yml 2020-02-19 23:55:58 +03:00
Alex Lushpai
a82885e85f
Update appveyour.yml 2020-02-19 23:52:36 +03:00
Alex Lushpai
eec1a09137
Create appveyour.yml 2020-02-19 23:42:52 +03:00
Alex Lushpai
e87d93e3a6 update tests 2020-02-19 23:27:44 +03:00
Alex Lushpai
572a559422
Merge pull request #13 from Konard/patch-1
Typos fix.
2019-10-21 13:07:35 +03:00
Konstantin Dyachenko
3e2a958639
Typos fix. 2019-07-27 22:18:09 +03:00
Alex Lushpai
b5cbd87afe
Merge pull request #12 from gwinn/master
Master
2019-01-28 22:29:51 +03:00
Alex Lushpai
49a05e744a update Readme 2019-01-28 22:27:53 +03:00
14 changed files with 89 additions and 46 deletions

View file

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2015-2018 RetailDriver LLC
Copyright (c) 2015-2020 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

View file

@ -1,9 +1,10 @@
[![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)](https://www.nuget.org/packages/Retailcrm.SDK/)
[![AppVeyor](https://img.shields.io/appveyor/build/gwinn/api-client-dotnet?logo=appveyor&logoColor=white)](https://ci.appveyor.com/project/gwinn/api-client-dotnet)
[![NuGet](https://img.shields.io/nuget/v/Retailcrm.SDK.svg?logo=nuget&logoColor=white)](https://www.nuget.org/packages/Retailcrm.SDK/)
# retailCRM API C# client
This is C# retailCRM API client. This library allows to use all available API versions.
# RetailCRM API C# client
This is C# RetailCRM API client. This library allows to use all available API versions.
## Install
@ -21,11 +22,11 @@ using Retailcrm;
using Retailcrm.Versions.V5;
...
Client api = new Client("https://demo.retailcrm.ru", "T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH");
Client api = new Client("https://demo.retailcrm.pro", "T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH");
Response response = api.OrdersGet("12345", "externalId");
if (response.isSuccessful()) {
Debug.WriteLine(Response.GetRawResponse());
if (response.IsSuccessful()) {
Debug.WriteLine(response.GetRawResponse());
} else {
Debug.WriteLine($"Ошибка: [Статус HTTP-ответа {response.GetStatusCode().ToString()}]");
}
@ -39,7 +40,7 @@ using Retailcrm;
using Retailcrm.Versions.V4;
...
Client api = new Client("https://demo.retailcrm.ru", "T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH");
Client api = new Client("https://demo.retailcrm.pro", "T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH");
Response response = api.OrdersCreate(new Dictionary<string, object>
{
{"externalId", "12345"},
@ -64,14 +65,10 @@ Response response = api.OrdersCreate(new Dictionary<string, object>
}}
});
if (response.isSuccessful()) {
Debug.WriteLine(Response.GetResponse()["externalId"].ToString());
if (response.IsSuccessful()) {
Debug.WriteLine(response.GetResponse()["externalId"].ToString());
} else {
Debug.WriteLine($"Ошибка: [Статус HTTP-ответа {response.GetStatusCode().ToString()}]");
Debug.WriteLine($"Error: [HTTP status code {response.GetStatusCode().ToString()}]");
}
```
### Documentation
* [English](http://www.retailcrm.pro/docs/Developers/Index)
* [Russian](http://www.retailcrm.ru/docs/Developers/Index)

View file

@ -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 2019")]
[assembly: AssemblyCopyright("Copyright © RetailDriver LLC 2020")]
[assembly: AssemblyTrademark("RetailDriver LLC")]
[assembly: AssemblyCulture("")]

View file

@ -52,10 +52,9 @@ namespace Retailcrm
/// <param name="allowObjects"></param>
private void AddEntry(string prefix, object instance, bool allowObjects)
{
var dictionary = instance as IDictionary;
var collection = instance as ICollection;
if (dictionary != null)
if (instance is IDictionary dictionary)
{
Add(prefix, GetDictionaryAdapter(dictionary));
}
@ -104,7 +103,7 @@ namespace Retailcrm
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
private IEnumerable<Entry> GetObjectAdapter(object data)
private static IEnumerable<Entry> GetObjectAdapter(object data)
{
var properties = data.GetType().GetProperties();
@ -123,7 +122,7 @@ namespace Retailcrm
/// </summary>
/// <param name="collection"></param>
/// <returns></returns>
private IEnumerable<Entry> GetArrayAdapter(ICollection collection)
private static IEnumerable<Entry> GetArrayAdapter(ICollection collection)
{
int i = 0;
foreach (var item in collection)
@ -142,7 +141,7 @@ namespace Retailcrm
/// </summary>
/// <param name="collection"></param>
/// <returns></returns>
private IEnumerable<Entry> GetDictionaryAdapter(IDictionary collection)
private static IEnumerable<Entry> GetDictionaryAdapter(IDictionary collection)
{
foreach (DictionaryEntry item in collection)
{

View file

@ -2,17 +2,17 @@
<package >
<metadata>
<id>Retailcrm.SDK</id>
<version>5.1.2</version>
<version>5.1.3</version>
<title>$title$</title>
<authors>retailCRM</authors>
<owners>retailCRM</owners>
<authors>RetailCRM</authors>
<owners>RetailCRM</owners>
<license type="expression">MIT</license>
<projectUrl>https://retailcrm.ru</projectUrl>
<iconUrl>https://help.retailcrm.ru/favicon.ico</iconUrl>
<projectUrl>https://github.com/retailcrmapi-client-dotnet</projectUrl>
<iconUrl>https://s3-s1.retailcrm.tech/eu-central-1/retailcrm-static/branding/retailcrm/favicon/favicon.ico</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Multiversion API client for retailCRM</description>
<releaseNotes>Fix POST request for big data</releaseNotes>
<copyright>Copyright 2017-2019</copyright>
<description>Multiversion API client for RetailCRM</description>
<releaseNotes>Rebranding</releaseNotes>
<copyright>Copyright 2017-2020</copyright>
<tags>crm ecommerce retailcrm sdk</tags>
</metadata>
</package>

View file

@ -2,12 +2,12 @@ using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("RetailcrmUnitTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("Tests for RetailCRM SDK")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("RetailDriver LLC")]
[assembly: AssemblyProduct("RetailcrmUnitTest")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright © RetailDriver LLC 2020")]
[assembly: AssemblyTrademark("RetailDriver LLC")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -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.4.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.4.0\build\net45\MSTest.TestAdapter.props')" />
<Import Project="..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.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.4.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
<HintPath>..\packages\MSTest.TestFramework.2.1.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.4.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
<HintPath>..\packages\MSTest.TestFramework.2.1.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.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'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.targets'))" />
</Target>
<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')" />
<Import Project="..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.0\build\net45\MSTest.TestAdapter.targets')" />
</Project>

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@ -22,6 +23,7 @@ namespace RetailcrmUnitTest.V3
}
[TestMethod]
[Ignore]
public void PacksCreateUpdateReadDelete()
{
string uid = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 12);
@ -69,8 +71,7 @@ namespace RetailcrmUnitTest.V3
foreach (Dictionary<string, object> s in arr.OfType<Dictionary<string, object>>())
{
int itemId;
int.TryParse(s["id"].ToString(), NumberStyles.Any, null, out itemId);
int.TryParse(s["id"].ToString(), NumberStyles.Any, null, out int itemId);
id[0] = itemId;
}
@ -84,6 +85,7 @@ namespace RetailcrmUnitTest.V3
Response packsCreateResponse = _client.PacksCreate(pack);
Debug.WriteLine(packsCreateResponse.GetRawResponse());
Assert.IsTrue(packsCreateResponse.IsSuccessfull());
Assert.IsTrue(packsCreateResponse.GetStatusCode() == 201);
Assert.IsInstanceOfType(packsCreateResponse, typeof(Response));

View file

@ -20,6 +20,7 @@ namespace RetailcrmUnitTest.V3
}
[TestMethod]
[Ignore]
public void TelephonyManagerGet()
{
Response response = _client.TelephonyManagerGet("+79999999999");

View file

@ -60,6 +60,7 @@ namespace RetailcrmUnitTest.V4
}
[TestMethod]
[Ignore]
public void TelephonyCallEvent()
{
Response response = _client.TelephonyCallEvent(

View file

@ -25,11 +25,29 @@ namespace RetailcrmUnitTest.V5
[TestMethod]
public void NotesCreateDelete()
{
Dictionary<string, object> customer = new Dictionary<string, object>
{
{"externalId", Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 12)},
{"lastName", "Took"},
{"firstName", "Peregrin"},
{"email", "took@example.com"},
{"phone", "+78888888989"}
};
Response createResponse = _client.CustomersCreate(customer);
Assert.IsTrue(createResponse.IsSuccessfull());
Assert.IsInstanceOfType(createResponse, typeof(Response));
Assert.IsTrue(createResponse.GetStatusCode() == 201);
Assert.IsTrue(createResponse.GetResponse().ContainsKey("id"));
string id = createResponse.GetResponse()["id"].ToString();
Response responseFiltered = _client.NotesCreate(
new Dictionary<string, object>
{
{ "text", "test task" },
{ "customer", new Dictionary<string, object> { { "id", "4717" } }},
{ "customer", new Dictionary<string, object> { { "id", id } }},
{ "managerId", Environment.GetEnvironmentVariable("RETAILCRM_USER")}
}
);

View file

@ -21,6 +21,7 @@ namespace RetailcrmUnitTest.V5
}
[TestMethod]
[Ignore]
public void TasksCreateUpdateGet()
{
DateTime datetime = DateTime.Now;

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MSTest.TestAdapter" version="1.4.0" targetFramework="net45" />
<package id="MSTest.TestFramework" version="1.4.0" targetFramework="net45" />
<package id="MSTest.TestAdapter" version="2.1.0" targetFramework="net45" />
<package id="MSTest.TestFramework" version="2.1.0" targetFramework="net45" />
</packages>

24
appveyor.yml Normal file
View file

@ -0,0 +1,24 @@
version: 5.1.{build}
pull_requests:
do_not_increment_build_number: true
branches:
only:
- master
skip_tags: true
image: Visual Studio 2019
configuration: Release
environment:
RETAILCRM_URL:
secure: +XvDVl4qowEEYYTdURDytjGjtBPeyehSzCqQs4XcavM=
RETAILCRM_KEY:
secure: xRC/iy3F1W4PCS1V1eiruJv4Sdj4A9Ln2s36fp0MtgiiIdGDHeK+Qmlm+eHAZgjh
RETAILCRM_SITE:
secure: 2w6OVirZRJLlkzME0kpXzQ==
RETAILCRM_STORE:
secure: UCnYSIgosQyIqtVwDrVv4w==
RETAILCRM_USER:
secure: tClF7XYbv+nGE5WpZIF7ng==
before_build:
- ps: nuget restore
build:
verbosity: minimal