public void TestBasicNIRequest(bool passCreds, bool kitchenSink) { //ARRANGE var expectedUri = $"{ApiUrl}/ni/basic/json"; BasicNumberInsightRequest request; var expectedResponseContent = "{\"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\"}"; if (kitchenSink) { expectedUri += $"?number=15555551212&country=GB&api_key={ApiKey}&api_secret={ApiSecret}&"; request = new BasicNumberInsightRequest { Country = "GB", Number = "15555551212" }; } else { expectedUri += $"?number=15555551212&api_key={ApiKey}&api_secret={ApiSecret}&"; request = new BasicNumberInsightRequest { Number = "15555551212" }; } Setup(expectedUri, expectedResponseContent); //ACT BasicInsightResponse response; var creds = Request.Credentials.FromApiKeyAndSecret(ApiKey, ApiSecret); var client = new NexmoClient(creds); if (passCreds) { response = client.NumberInsightClient.GetNumberInsightBasic(request, creds); } else { response = client.NumberInsightClient.GetNumberInsightBasic(request); } //ASSERT Assert.Equal(0, response.Status); Assert.Equal("Success", response.StatusMessage); Assert.Equal("ca4f82b6-73aa-43fe-8c52-874fd9ffffff", response.RequestId); Assert.Equal("15555551212", response.InternationalFormatNumber); Assert.Equal("(555) 555-1212", response.NationalFormatNumber); Assert.Equal("US", response.CountryCode); Assert.Equal("USA", response.CountryCodeIso3); Assert.Equal("United States of America", response.CountryName); Assert.Equal("1", response.CountryPrefix); }
public void Execute() { var VONAGE_API_KEY = Environment.GetEnvironmentVariable("VONAGE_API_KEY") ?? "VONAGE_API_KEY"; var VONAGE_API_SECRET = Environment.GetEnvironmentVariable("VONAGE_API_SECRET") ?? "VONAGE_API_SECRET"; var INSIGHT_NUMBER = Environment.GetEnvironmentVariable("INSIGHT_NUMBER") ?? "INSIGHT_NUMBER"; var creds = Credentials.FromApiKeyAndSecret(VONAGE_API_KEY, VONAGE_API_SECRET); var client = new VonageClient(creds); var request = new BasicNumberInsightRequest() { Number = INSIGHT_NUMBER }; var response = client.NumberInsightClient.GetNumberInsightBasic(request); Console.WriteLine($"Basic insights request complete.\nStatus:{response.Status}\n" + $"Country Code:{response.CountryName}\nNational Formatted Number:{response.NationalFormatNumber}"); }