Скачайте готовые классы для работы с API

 

				
					public class ZApi
{
    ZadarmaApi zadarma;
    public ZApi() {
        zadarma = new ZadarmaApi("key", "secret");
    }
    public string outCalls() {
        var parameters = new SortedDictionary<string, string>()
        {
            {"end", "2022-07-14 05:00:00"},
            { "start", "2022-06-14 10:00:00"},
        };
        var response = zadarma.Call("/v1/statistics/", parameters);
        string str = response.Content.ReadAsStringAsync().Result;
        return str;
    }
    public string incCalls()
    {
        var parameters = new SortedDictionary<string, string>()
        {
            {"end", "2022-07-14 05:00:00"},
            { "start", "2022-06-14 10:00:00"},
        };
        var response = zadarma.Call("/v1/statistics/incoming-calls/", parameters);
        string str = response.Content.ReadAsStringAsync().Result;
        return str;
    }
    public string Clients()
    {
        var response = zadarma.Call("/v1/zcrm/customers");
        string str = response.Content.ReadAsStringAsync().Result;
        return HttpUtility.UrlDecode(str.Replace("\\", "%"));
    }
    public string Leads()
    {
        var response = zadarma.Call("/v1/zcrm/leads");
        string str = response.Content.ReadAsStringAsync().Result;
        return HttpUtility.UrlDecode(str.Replace("\\", "%"));
    }
}

				
			

Использование

				
					var api = new ZApi();
int c = int.Parse(((WindowsUIButton)e.Button).Tag.ToString());
switch (c)
{
    case 1:
        jsonTreeView.ShowJson(api.incCalls());
        break;
    case 2:
        jsonTreeView.ShowJson(api.outCalls());
        break;
    case 3:
        jsonTreeView.ShowJson(api.Clients());
        break;
    case 4:
        jsonTreeView.ShowJson(api.Leads());
        break;
}
jsonTreeView.ExpandAll();

				
			

Интересный компонент JsonTreeView для отображения Json строки в виде дерева.

Интеграция C# приложения с CRM Zadorma
Tagged on:         

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.