2020-02-20 00:12:18 +03:00
|
|
|
[![AppVeyor](https://img.shields.io/appveyor/build/gwinn/api-client-dotnet?style=flat-square)](https://ci.appveyor.com/project/gwinn/api-client-dotnet)
|
|
|
|
[![NuGet](https://img.shields.io/nuget/v/Retailcrm.SDK.svg?style=flat-square)](https://www.nuget.org/packages/Retailcrm.SDK/)
|
|
|
|
|
2014-11-03 13:50:28 +03:00
|
|
|
|
2018-03-21 15:56:36 +03:00
|
|
|
# retailCRM API C# client
|
|
|
|
|
|
|
|
This is C# retailCRM API client. This library allows to use all available API versions.
|
|
|
|
|
|
|
|
## Install
|
2015-07-23 13:37:17 +03:00
|
|
|
|
|
|
|
``` bash
|
2017-10-30 13:51:45 +03:00
|
|
|
PM> Install-Package Retailcrm.SDK
|
2015-07-23 13:37:17 +03:00
|
|
|
```
|
|
|
|
|
2018-03-21 15:56:36 +03:00
|
|
|
## Usage
|
2014-11-03 13:50:28 +03:00
|
|
|
|
2018-03-21 15:56:36 +03:00
|
|
|
### Get order
|
2014-11-03 13:50:28 +03:00
|
|
|
|
2014-11-03 13:52:08 +03:00
|
|
|
``` csharp
|
2017-10-30 13:51:45 +03:00
|
|
|
using System.Diagnostics;
|
|
|
|
using Retailcrm;
|
|
|
|
using Retailcrm.Versions.V5;
|
2014-11-03 13:50:28 +03:00
|
|
|
...
|
|
|
|
|
2017-10-30 13:51:45 +03:00
|
|
|
Client api = new Client("https://demo.retailcrm.ru", "T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH");
|
|
|
|
Response response = api.OrdersGet("12345", "externalId");
|
2014-11-03 13:50:28 +03:00
|
|
|
|
2019-07-27 22:18:09 +03:00
|
|
|
if (response.IsSuccessful()) {
|
|
|
|
Debug.WriteLine(response.GetRawResponse());
|
2015-02-02 14:46:14 +03:00
|
|
|
} else {
|
2017-10-30 13:51:45 +03:00
|
|
|
Debug.WriteLine($"Ошибка: [Статус HTTP-ответа {response.GetStatusCode().ToString()}]");
|
2015-02-02 14:46:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
```
|
2018-03-21 15:56:36 +03:00
|
|
|
### Create order
|
2014-11-03 13:50:28 +03:00
|
|
|
|
2014-11-03 13:52:08 +03:00
|
|
|
``` csharp
|
2017-10-30 13:51:45 +03:00
|
|
|
using System.Diagnostics;
|
|
|
|
using Retailcrm;
|
|
|
|
using Retailcrm.Versions.V4;
|
2015-02-02 14:39:46 +03:00
|
|
|
...
|
2015-02-02 14:36:40 +03:00
|
|
|
|
2017-10-30 13:51:45 +03:00
|
|
|
Client api = new Client("https://demo.retailcrm.ru", "T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH");
|
|
|
|
Response response = api.OrdersCreate(new Dictionary<string, object>
|
2015-02-02 14:36:40 +03:00
|
|
|
{
|
2017-10-30 13:51:45 +03:00
|
|
|
{"externalId", "12345"},
|
|
|
|
{"createdAt", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
|
|
|
|
{"lastName", "Doe"},
|
|
|
|
{"firstName", "John"},
|
|
|
|
{"email", "john@example.com"},
|
|
|
|
{"phone", "+79999999999"},
|
|
|
|
{"items", new List<object> {
|
|
|
|
new Dictionary<string, object> {
|
|
|
|
{"initialPrice", 100},
|
|
|
|
{"quantity", 1},
|
|
|
|
{"productId", 55},
|
|
|
|
{"productName", "example"}
|
|
|
|
},
|
|
|
|
new Dictionary<string, object> {
|
|
|
|
{"initialPrice", 200},
|
|
|
|
{"quantity", 2},
|
|
|
|
{"productId", 14},
|
|
|
|
{"productName", "example too"}
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
});
|
2015-02-02 14:36:40 +03:00
|
|
|
|
2019-07-27 22:18:09 +03:00
|
|
|
if (response.IsSuccessful()) {
|
|
|
|
Debug.WriteLine(response.GetResponse()["externalId"].ToString());
|
2015-02-02 14:36:40 +03:00
|
|
|
} else {
|
2017-10-30 13:51:45 +03:00
|
|
|
Debug.WriteLine($"Ошибка: [Статус HTTP-ответа {response.GetStatusCode().ToString()}]");
|
2014-11-03 13:50:28 +03:00
|
|
|
}
|
|
|
|
|
2015-02-02 14:39:46 +03:00
|
|
|
```
|
2018-03-21 15:56:36 +03:00
|
|
|
### Documentation
|
|
|
|
|
2019-01-28 22:27:53 +03:00
|
|
|
* [English](https://help.retailcrm.pro/Developers/Index)
|
|
|
|
* [Russian](https://help.retailcrm.ru/Developers/Index)
|