using System;
using System.Collections.Generic;
using System.Web.Script.Serialization;
namespace Retailcrm.Versions.V3
{
public partial class Client
{
///
/// Get manager
///
///
///
///
public Response TelephonyManagerGet(string phone, string details = "1")
{
Dictionary parameters = new Dictionary();
if (string.IsNullOrEmpty(phone))
{
throw new ArgumentException("Parameter `phone` must contains a data");
}
parameters.Add("details", details);
parameters.Add("phone", phone);
return Request.MakeRequest("/telephony/manager", Request.MethodGet, parameters);
}
///
/// Send call event
///
///
///
///
///
///
public Response TelephonyCallEvent(string phone, string type, string status, string code)
{
if (string.IsNullOrEmpty(phone))
{
throw new ArgumentException("Parameter `phone` must contains a data");
}
if (string.IsNullOrEmpty(code))
{
throw new ArgumentException("Parameter `phone` must contains a data");
}
List statuses = new List { "answered", "busy", "cancel", "failed", "no answered" };
List types = new List { "hangup", "in", "out" };
if (!statuses.Contains(status))
{
throw new ArgumentException("Parameter `status` must be equal one of `answered|busy|cancel|failed|no answered`");
}
if (!types.Contains(type))
{
throw new ArgumentException("Parameter `type` must be equal one of `hangup|in|out`");
}
return Request.MakeRequest(
"/telephony/call/event",
Request.MethodPost,
new Dictionary
{
{ "phone", phone },
{ "type", type },
{ "hangupStatus", status},
{ "code", code }
}
);
}
///
/// Upload calls
///
///
///
public Response TelephonyCallsUpload(List