/// <summary>
        /// Retrives fraud level for given call data.
        /// More information at: https://nextcaller.com/documentation/v2.1/#/fraud-levels/curl.
        /// </summary>
        /// <param name="callData">Call data to be posted.</param>
        /// <param name="accountId">Platform account ID.</param>
        /// <returns>Fraud level for given call data.</returns>
        public FraudLevel AnalyzeCall(AnalyzeCallData callData, string accountId = null)
        {
            Utility.EnsureParameterValid(!(callData == null), "callData");

            string jsonData = JsonSerializer.Serialize(callData);
            string content = AnalyzeCallJson(jsonData);

            return JsonSerializer.Deserialize<FraudLevel>(content);
        }
        public void AnalyzeCall_ValidData_FraudLevelReturned()
        {
            //Arrange
            string jsonFraudLevel = Properties.Resources.JsonFraudLevel;

            AnalyzeCallData data = new AnalyzeCallData
            {
                Ani = "12125551212",
                Dnis = "18005551212",
                Headers = new Dictionary<string, object>
                {
                    { "from", "\"John Smith\" <sip:[email protected]>" },
                    { "via", new List<string> { "SIP/2.0//UDP 1.1.1.1:5060;branch=z9hG4bK3fe1.9a945462b4c1880c5f6fdc0214a205ca.1"} }
                },
                Meta = new Dictionary<string, string>
                {
                    { "caller_id", "12125551212" },
                    { "charge_number", "12125551212" },
                    { "ani2", "0" },
                    { "private", "true" }
                }
            };

            Mock<IHttpTransport> httpTransportMock = new Mock<IHttpTransport>(MockBehavior.Strict);
            httpTransportMock.Setup(httpTransport => httpTransport.Request(It.IsAny<string>(), It.IsAny<ContentType>(), It.IsIn("GET", "POST"), It.IsAny<string>(), It.IsAny<IEnumerable<Header>>()))
                .Returns(jsonFraudLevel);

            //Action
            NextCallerClient client = new NextCallerClient(httpTransportMock.Object);
            string jsonData = JsonSerializer.Serialize(data);
            string fraudLevel = client.AnalyzeCallJson(jsonData);

            //Assert
            httpTransportMock.Verify(httpTransport => httpTransport.Request(It.IsAny<string>(), It.IsAny<ContentType>(), It.IsIn("GET", "POST"), It.IsAny<string>(), It.IsAny<IEnumerable<Header>>()), Times.Once);

            Assert.IsNotNull(fraudLevel);
            Assert.AreEqual(jsonFraudLevel, fraudLevel);
        }
        public static void Run()
        {
            const string Username = "";
            const string Password = "";
            const bool Sandbox = true;

            NextCallerClient client = new NextCallerClient(Username, Password, Sandbox);

            try
            {
                AnalyzeCallData callData = new AnalyzeCallData
                {
                    Ani = "12125551212",
                    Dnis = "18005551212",
                    Headers = new Dictionary<string, object>
                    {
                        { "from", "\"John Smith\" <sip:[email protected]>" },
                        { "via", new List<string> { "SIP/2.0//UDP 1.1.1.1:5060;branch=z9hG4bK3fe1.9a945462b4c1880c5f6fdc0214a205ca.1"} }
                    },
                    Meta = new Dictionary<string, string>
                    {
                        { "caller_id", "12125551212" },
                        { "charge_number", "12125551212" },
                        { "ani2", "0" },
                        { "private", "true" }
                    }
                };

                FraudLevel fraudLevel = client.AnalyzeCall(callData);
            }
            catch (FormatException formatException)
            {

                HttpWebRequest request = formatException.Request;
                HttpWebResponse response = formatException.Response;

                HttpStatusCode code = response.StatusCode;
                Console.WriteLine("Status code: {0}", code);

                string reasonPhrase = response.StatusDescription;
                Console.WriteLine("Reason Phrase: {0}", reasonPhrase);

                string responseContent = formatException.Content;
                Console.WriteLine("Content : {0}", responseContent);

            }
            catch (BadRequestException badRequestException)
            {

                HttpWebRequest request = badRequestException.Request;
                HttpWebResponse response = badRequestException.Response;

                Error parsedError = badRequestException.Error;

                string errorCode = parsedError.Code;
                string message = parsedError.Message;
                string type = parsedError.Type;

                Dictionary<string, string[]> description = parsedError.Description;

                Console.WriteLine(parsedError.ToString());

            }
        }