2020-12-15 13:29:48 +03:00
|
|
|
[![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/)
|
2020-02-20 00:12:18 +03:00
|
|
|
|
2014-11-03 13:50:28 +03:00
|
|
|
|
2020-12-15 13:29:48 +03:00
|
|
|
# RetailCRM API C# client
|
2018-03-21 15:56:36 +03:00
|
|
|
|
2020-12-15 13:29:48 +03:00
|
|
|
This is C# RetailCRM API client. This library allows to use all available API versions.
|
2018-03-21 15:56:36 +03:00
|
|
|
|
|
|
|
## 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
|
|
|
...
|
|
|
|
|
2020-12-15 13:29:48 +03:00
|
|
|
Client api = new Client("https://demo.retailcrm.pro", "T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH");
|
2017-10-30 13:51:45 +03:00
|
|
|
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
|
|
|
|
2020-12-15 13:29:48 +03:00
|
|
|
Client api = new Client("https://demo.retailcrm.pro", "T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH");
|
2017-10-30 13:51:45 +03:00
|
|
|
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 {
|
2020-12-15 13:29:48 +03:00
|
|
|
Debug.WriteLine($"Error: [HTTP status code {response.GetStatusCode().ToString()}]");
|
2014-11-03 13:50:28 +03:00
|
|
|
}
|
|
|
|
|
2015-02-02 14:39:46 +03:00
|
|
|
```
|