api-client-dotnet/Retailcrm/Versions/V5/Integrations.cs
Alex Lushpai 72cac6d6f0
Multiversion client (#6)
* Multiversion sdk
* Remove redundant code
* More test coverage;
2017-10-30 13:51:45 +03:00

60 lines
1.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;
namespace Retailcrm.Versions.V5
{
public partial class Client
{
/// <summary>
/// Get integration settings
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public Response IntegrationsSettingGet(string code)
{
if (string.IsNullOrEmpty(code))
{
throw new ArgumentException("Parameter `code` is mandatory");
}
return Request.MakeRequest(
$"/integration-modules/{code}",
Request.MethodGet
);
}
/// <summary>
/// Create/Update integration settings
/// </summary>
/// <param name="integrationModule"></param>
/// <returns></returns>
public Response IntegrationsSettingsEdit(Dictionary<string, object> integrationModule)
{
if (integrationModule.Count < 1)
{
throw new ArgumentException("Parameter `integrationModule` must contain data");
}
if (!integrationModule.ContainsKey("code"))
{
throw new ArgumentException("Parameter `integrationModule` should contain `code`");
}
if (!integrationModule.ContainsKey("name"))
{
throw new ArgumentException("Parameter `integrationModule` should contain `name`");
}
return Request.MakeRequest(
$"/integration-modules/{integrationModule["code"].ToString()}/edit",
Request.MethodPost,
new Dictionary<string, object>
{
{ "integrationModule", new JavaScriptSerializer().Serialize(integrationModule) }
}
);
}
}
}