api-client-dotnet/README.md

78 lines
2.1 KiB
Markdown
Raw Normal View History

2018-03-21 18:13:15 +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)
[![NuGet](https://img.shields.io/nuget/v/Retailcrm.SDK.svg)](https://www.nuget.org/packages/Retailcrm.SDK/)
2014-11-03 13:50:28 +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
PM> Install-Package Retailcrm.SDK
2015-07-23 13:37:17 +03:00
```
## Usage
2014-11-03 13:50:28 +03:00
### Get order
2014-11-03 13:50:28 +03:00
2014-11-03 13:52:08 +03:00
``` csharp
using System.Diagnostics;
using Retailcrm;
using Retailcrm.Versions.V5;
2014-11-03 13:50:28 +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()) {
Debug.WriteLine(Response.GetRawResponse());
2015-02-02 14:46:14 +03:00
} else {
Debug.WriteLine($"Ошибка: [Статус HTTP-ответа {response.GetStatusCode().ToString()}]");
2015-02-02 14:46:14 +03:00
}
```
### Create order
2014-11-03 13:50:28 +03:00
2014-11-03 13:52:08 +03:00
``` csharp
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
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
{
{"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
if (response.isSuccessful()) {
Debug.WriteLine(Response.GetResponse()["externalId"].ToString());
2015-02-02 14:36:40 +03:00
} else {
Debug.WriteLine($"Ошибка: [Статус HTTP-ответа {response.GetStatusCode().ToString()}]");
2014-11-03 13:50:28 +03:00
}
2015-02-02 14:39:46 +03:00
```
### Documentation
* [English](http://www.retailcrm.pro/docs/Developers/Index)
* [Russian](http://www.retailcrm.ru/docs/Developers/Index)