2018-03-21 18:21:08 +03:00
[![Visual Studio Team services ](https://img.shields.io/vso/build/gwinn/f01d2ec1-f511-4908-8c02-d48757d71370/3.svg?style=flat-square )](https://visualstudio.com)
2018-03-21 18:40:33 +03:00
[![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
2015-02-02 14:46:14 +03:00
if (response.isSuccessful()) {
2017-10-30 13:51:45 +03:00
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
2017-10-30 13:51:45 +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
* [English ](http://www.retailcrm.pro/docs/Developers/Index )
* [Russian ](http://www.retailcrm.ru/docs/Developers/Index )