public void should_send_basic_ni_request() { var resp = new Mock <IWebResponse>(); resp.Setup(e => e.GetResponseStream()).Returns(new MemoryStream(Encoding.UTF8.GetBytes("{\"status\": 0,\"status_message\": \"Success\",\"request_id\": \"ca4f82b6-73aa-43fe-8c52-874fd9ffffff\",\"international_format_number\": \"15555551212\",\"national_format_number\": \"(555) 555-1212\",\"country_code\": \"US\",\"country_code_iso3\": \"USA\",\"country_name\": \"United States of America\",\"country_prefix\": \"1\"}"))); var postDataStream = new MemoryStream(); _request.Setup(e => e.GetRequestStream()).Returns(postDataStream); _request.Setup(e => e.GetResponse()).Returns(resp.Object); var result = NumberInsight.RequestBasic(new NumberInsight.NumberInsightBasicRequest { number = "15555551212" }); _mock.Verify(h => h.CreateHttp(new Uri( string.Format("{0}/number/format/json", ApiUrl))), Times.Once); postDataStream.Position = 0; var sr = new StreamReader(postDataStream); var postData = sr.ReadToEnd(); Assert.AreEqual(string.Format("number=15555551212&api_key={0}&api_secret={1}&", ApiKey, ApiSecret), postData); Assert.AreEqual("0", result.status); Assert.AreEqual("15555551212", result.international_format_number); Assert.AreEqual("(555) 555-1212", result.national_format_number); }
public void should_send_basic_ni_request() { var result = NumberInsight.RequestBasic(new NumberInsight.NumberInsightBasicRequest { number = Configuration.Instance.Settings["test_number"] }); Assert.AreEqual("0", result.status); Assert.AreEqual(Configuration.Instance.Settings["test_number"], result.international_format_number); Assert.AreEqual("(555) 555-1212", result.national_format_number); }
public void should_send_basic_ni_request() { var result = NumberInsight.RequestBasic(new NumberInsight.NumberInsightBasicRequest { number = "15555551212" }); Assert.AreEqual("0", result.status); Assert.AreEqual("15555551212", result.international_format_number); Assert.AreEqual("(555) 555-1212", result.national_format_number); }
public void should_send_basic_ni_request() { SetExpect($"{ApiUrl}/ni/basic/json", "{\"status\": 0,\"status_message\": \"Success\",\"request_id\": \"ca4f82b6-73aa-43fe-8c52-874fd9ffffff\",\"international_format_number\": \"15555551212\",\"national_format_number\": \"(555) 555-1212\",\"country_code\": \"US\",\"country_code_iso3\": \"USA\",\"country_name\": \"United States of America\",\"country_prefix\": \"1\"}", $"number=15555551212&api_key={ApiKey}&api_secret={ApiSecret}&"); var result = NumberInsight.RequestBasic(new NumberInsight.NumberInsightRequest { number = "15555551212" }); Assert.AreEqual("0", result.status); Assert.AreEqual("15555551212", result.international_format_number); Assert.AreEqual("(555) 555-1212", result.national_format_number); }
public ActionResult Basic(string number) { var results = NumberInsight.RequestBasic(new NumberInsight.NumberInsightBasicRequest { number = number, }); Session["requestID"] = results.request_id; Session["iNumber"] = results.international_format_number; Session["nNumber"] = results.national_format_number; Session["status"] = results.status_message; Session["country"] = results.country_name; Session["countryCode"] = results.country_code; return(RedirectToAction("BasicResults")); }
/// <summary> /// This is a quick sanity check with 90%+ code coverage of the ApiRequest classes /// </summary> private static void ApiRequestCoverageTest() { Console.WriteLine("Account.GetBalance() = {0}", Account.GetBalance()); Console.WriteLine("Account.GetNumbers() = {0}", Account.GetNumbers().count); ///// var niResp = NumberInsight.RequestBasic(new NumberInsight.NumberInsightRequest { number = Configuration.Instance.Settings["test_number"] }); Console.WriteLine("NumberInsight.Request() = {0}", niResp.status); ///// var appRequest = new ApplicationRequest { name = "coveragetest", type = "voice", answer_url = "https://abcdefg.ngrok.io/api/voice", event_url = "https://abcdefg.ngrok.io/api/voice", }; var appResp = Application.Create(appRequest); Console.WriteLine("Application.Create() = {0}", appResp.id); var appList = Application.List(); Console.WriteLine("Application.List() = {0}", appList.Count); var filteredAppList = Application.List(10, 0, appResp.id); Console.WriteLine("Application.List(10, 0, appResp.id) = {0}", filteredAppList.Count); appRequest.id = appResp.id; appRequest.name = "updcoveragetest"; var appUpdateResp = Application.Update(appRequest); Console.WriteLine("Application.Update(appRequest) = {0}", appUpdateResp.name); var isDeleted = Application.Delete(appUpdateResp.id); Console.WriteLine("Application.Delete(id) = {0}", isDeleted); ///// var results = Call.Do(new Call.CallCommand { to = new[] { new Call.Endpoint { type = "phone", number = Configuration.Instance.Settings["test_number"] } }, @from = new Call.Endpoint { type = "phone", number = Configuration.Instance.Settings["nexmo_number"] }, answer_url = new[] { "https://nexmo-community.github.io/ncco-examples/first_call_talk.json" } }); Console.WriteLine("Call.Do() = {0}", results.status); var callListResults = Call.List(); Console.WriteLine("Call.List() = {0}", callListResults.count); }