.NET client for retailCRM API
Go to file
2016-03-14 23:19:47 +03:00
RetailCrm fix deserialize json && add new methods 2016-02-04 12:37:40 +03:00
.gitignore Initial commit 2014-11-03 12:26:10 +03:00
LICENSE Update LICENSE 2015-02-02 16:21:59 +03:00
README.md Update README.md 2016-03-14 23:18:43 +03:00
README.ru.md Update README.ru.md 2016-03-14 23:19:47 +03:00

.NET client for retailCRM API

.NET client for RetailCRM API.

Requirements

Install with NuGet

Install NuGet.

Run this command into Package Manager Console

PM> Install-Package RetailCRM.ApiClient

Usage

Get order

using RetailCrm;
using RetailCrm.Response;
...
ApiClient api;
try
{
    api = new ApiClient(
    	"https://demo.retailcrm.pro",
    	"T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH"
    );
}
catch (WebException e)
{
    System.Console.WriteLine(e.ToString());
}

ApiResponse response = null;
try
{
    response = api.ordersGet("M-2342");
}
catch (WebException e)
{
    System.Console.WriteLine(e.ToString());
}

if (response.isSuccessful()) {
	System.Console.WriteLine(response["totalSumm"]);
} else {
	System.Console.WriteLine(
		"Error: [HTTP-code  " +
		response["statusCosde"] + "] " +
		response["errorMsg"]
	);
}

Create order

using RetailCrm;
using RetailCrm.Response;
...
ApiClient api;
string url, key;
try
{
    api = new ApiClient(url, key);
}
catch (WebException e)
{
    System.Console.WriteLine(e.ToString());
}

Dictionary<string, object> tmpOrder = new Dictionary<string, object>(){
                {"number", "example"},
                {"externalId", "example"},
                {"createdAt", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},
                {"discount", 50},
                {"phone", "89263832233"},
                {"email", "example@gmail.com"},
                {"customerComment", "example"},
                {"customFields", new Dictionary<string, object>(){
                                     {"reciever_phone", "example"},
                                     {"reciever_name", "example"},
                                     {"ext_number", "example"}
                                 }
                },
                {"contragentType", "individual"},
                {"orderType", "eshop-individual"},
                {"orderMethod", "app"},
                {"customerId", "555"},
                {"managerId", 8},
                {"items", new Dictionary<string, object>(){
                              {"0", new Dictionary<string, object>(){
                                        {"initialPrice", 100},
                                        {"quantity", 1},
                                        {"productId", 55},
                                        {"productName", "example"}
                                    }
                              }
                          }
                },
                {"delivery", new Dictionary<string, object>(){
                                 {"code", "courier"},
                                 {"date", DateTime.Now.ToString("Y-m-d")},
                                 {"address", new Dictionary<string, object>(){
                                                 {"text", "example"}
                                             }
                                 }
                             }
                }
            };

ApiResponse response = null;
try
{
    response = api.ordersEdit(order);
}
catch (WebException e)
{
    System.Console.WriteLine(e.ToString());
}

if (response.isSuccessful() && 201 == response["statusCosde"]) {
	System.Console.WriteLine(
		"Order created. Order ID is " + response["id"]
	);
} else {
	System.Console.WriteLine(
		"Error: [HTTP-code " +
		response["statusCode"] + "] " +
		response["errorMsg"]
	);
}