public static void Main(string[] args) { // Find your Account SID and Auth Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var phoneNumber = PhoneNumberResource.Fetch( new PhoneNumber("+15108675310"), type: new List <string> { "carrier" }); var mcc = phoneNumber.Carrier["mobile_country_code"]; var mnc = phoneNumber.Carrier["mobile_network_code"]; var countryCode = phoneNumber.CountryCode; var countries = CountryResource.Fetch(countryCode); var prices = countries .OutboundSmsPrices .Where(price => price.Mcc.Equals(mcc) && price.Mnc.Equals(mnc)) .SelectMany(price => price.Prices); foreach (var price in prices) { Console.WriteLine($"Country {countryCode}"); Console.WriteLine($"Current price {price.BasePrice}"); Console.WriteLine($"Current price {price.CurrentPrice}"); } }
public static void Main(string[] args) { // Find your Account SID and Auth Token at twilio.com/console // To set up environmental variables, see http://twil.io/secure const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); const string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN"); TwilioClient.Init(accountSid, authToken); var phoneNumber = PhoneNumberResource.Fetch( new PhoneNumber("+15108675310"), type: new List <string> { "carrier" }); var mcc = phoneNumber.Carrier["mobile_country_code"]; var mnc = phoneNumber.Carrier["mobile_network_code"]; var countryCode = phoneNumber.CountryCode; var countries = CountryResource.Fetch(countryCode); var prices = countries .OutboundSmsPrices .Where(price => price.Mcc.Equals(mcc) && price.Mnc.Equals(mnc)) .SelectMany(price => price.Prices); foreach (var price in prices) { Console.WriteLine($"Country {countryCode}"); Console.WriteLine($"Current price {price.BasePrice}"); Console.WriteLine($"Current price {price.CurrentPrice}"); } }
public static async Task <ResourceSet <CountryResource> > GetVoicePricingAsync(ITwilioRestClient client, long?limit) { var options = new ReadCountryOptions { Limit = limit, PageSize = null }; return(await CountryResource.ReadAsync(options, client)); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var country = CountryResource.Fetch(pathIsoCountry: "US"); Console.WriteLine(country.Country); }
public void GetCountry_Patient_Succesful() { // Arrange Helpers.PatientLogin(); // Act Country country = new CountryResource().GetCountry("DK"); // Assert Assert.AreEqual("Denmark", country.Name); Assert.AreEqual("DK", country.Code); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console // DANGER! This is insecure. See http://twil.io/secure const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var country = CountryResource.Fetch(pathIsoCode: "US"); Console.WriteLine(country.Name); }
public static void Main(string[] args) { // Find your Account SID and Auth Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var country = CountryResource.Fetch("EE"); foreach (var price in country.InboundSmsPrices) { Console.WriteLine(price.CurrentPrice); } }
public void TestReadFullResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"countries\": [{\"country\": \"Andorra\",\"iso_country\": \"AD\",\"url\": \"https://pricing.twilio.com/v1/Voice/Countries/AD\"}],\"meta\": {\"first_page_url\": \"https://pricing.twilio.com/v1/Voice/Countries?PageSize=50&Page=0\",\"key\": \"countries\",\"next_page_url\": null,\"page\": 0,\"page_size\": 50,\"previous_page_url\": null,\"url\": \"https://pricing.twilio.com/v1/Voice/Countries?PageSize=50&Page=0\"}}" )); var response = CountryResource.Read(client: twilioRestClient); Assert.NotNull(response); }
public void TestFetchResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"country\": \"United States\",\"iso_country\": \"US\",\"phone_number_prices\": [{\"number_type\": \"local\",\"base_price\": \"1.00\",\"current_price\": \"1.00\"},{\"number_type\": \"toll free\",\"base_price\": \"2.00\",\"current_price\": \"2.00\"}],\"price_unit\": \"USD\",\"url\": \"https://pricing.twilio.com/v1/PhoneNumbers/Countries/US\"}" )); var response = CountryResource.Fetch("US", client: twilioRestClient); Assert.NotNull(response); }
public static void Main(string[] args) { // Find your Account SID and Auth Token at twilio.com/console const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var countries = CountryResource.Read(); foreach (var country in countries) { Console.WriteLine(country.IsoCountry); } }
public void TestFetchResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"country\": \"Estonia\",\"iso_country\": \"EE\",\"phone_number_prices\": [{\"base_price\": 3.0,\"current_price\": 3.0,\"type\": \"mobile\"},{\"base_price\": 1.0,\"current_price\": 1.0,\"type\": \"national\"}],\"price_unit\": \"usd\",\"url\": \"https://pricing.twilio.com/v1/PhoneNumbers/Countries/US\"}" )); var response = CountryResource.Fetch("US", client: twilioRestClient); Assert.NotNull(response); }
public void TestReadUsResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"content\": [{\"iso_code\": \"US\",\"name\": \"United States/Canada\",\"country_codes\": [\"+1\"],\"continent\": \"NORTH_AMERICA\",\"low_risk_numbers_enabled\": false,\"high_risk_special_numbers_enabled\": false,\"high_risk_tollfraud_numbers_enabled\": false,\"url\": \"https://voice.twilio.com/v1/DialingPermissions/Countries/US\",\"links\": {\"highrisk_special_prefixes\": \"https://voice.twilio.com/v1/DialingPermissions/Countries/US/HighRiskSpecialPrefixes\"}}],\"meta\": {\"first_page_url\": \"https://voice.twilio.com/v1/DialingPermissions/Countries?PageSize=50&Page=0\",\"key\": \"content\",\"next_page_url\": null,\"page\": 0,\"page_size\": 50,\"previous_page_url\": null,\"url\": \"https://voice.twilio.com/v1/DialingPermissions/Countries?PageSize=50&Page=0\"}}" )); var response = CountryResource.Read(client: twilioRestClient); Assert.NotNull(response); }
public void TestReadEmptyResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"countries\": [],\"meta\": {\"first_page_url\": \"https://pricing.twilio.com/v1/PhoneNumbers/Countries?PageSize=1&Page=0\",\"key\": \"countries\",\"next_page_url\": null,\"page\": 0,\"page_size\": 1,\"previous_page_url\": null,\"url\": \"https://pricing.twilio.com/v1/PhoneNumbers/Countries?PageSize=1&Page=0\"}}" )); var response = CountryResource.Read(client: twilioRestClient); Assert.NotNull(response); }
public void TestFetchResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"country\": \"country\",\"inbound_sms_prices\": [{\"base_price\": 0.05,\"current_price\": 0.05,\"number_type\": \"mobile\"}],\"iso_country\": \"US\",\"outbound_sms_prices\": [{\"carrier\": \"att\",\"mcc\": \"foo\",\"mnc\": \"bar\",\"prices\": [{\"base_price\": 0.05,\"current_price\": 0.05,\"number_type\": \"mobile\"}]}],\"price_unit\": \"USD\",\"url\": \"http://www.example.com\"}" )); var response = CountryResource.Fetch("US", client: twilioRestClient); Assert.NotNull(response); }
public void TestFetchResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"country\": \"United States\",\"inbound_call_prices\": [{\"current_price\": \"0.0085\",\"number_type\": \"local\",\"base_price\": \"0.0085\"},{\"current_price\": \"0.022\",\"number_type\": \"toll free\",\"base_price\": \"0.022\"}],\"iso_country\": \"US\",\"outbound_prefix_prices\": [{\"prefixes\": [\"1907\"],\"current_price\": \"0.090\",\"friendly_name\": \"Programmable Outbound Minute - United States - Alaska\",\"base_price\": \"0.090\"}],\"price_unit\": \"USD\",\"url\": \"https://pricing.twilio.com/v1/Voice/Countries/US\"}" )); var response = CountryResource.Fetch("US", client: twilioRestClient); Assert.NotNull(response); }
public void TestFetchResponse() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); twilioRestClient.AccountSid.Returns("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); twilioRestClient.Request(Arg.Any <Request>()) .Returns(new Response( System.Net.HttpStatusCode.OK, "{\"country\": \"Australia\",\"inbound_call_prices\": [{\"base_price\": \"0.0075\",\"current_price\": \"0.0075\",\"number_type\": \"local\"}],\"iso_country\": \"AU\",\"outbound_prefix_prices\": [{\"base_price\": \"0.024\",\"current_price\": \"0.024\",\"friendly_name\": \"Programmable Outbound Minute - Australia - Major Cities\",\"prefixes\": [\"6128\",\"6129\",\"6138\",\"6139\",\"6173\",\"61261\",\"61262\",\"61861\",\"61862\",\"61863\",\"61864\",\"61865\",\"61870\",\"61881\",\"61882\",\"61883\",\"61884\",\"61892\",\"61893\",\"61894\"]},{\"base_price\": \"0.035\",\"current_price\": \"0.035\",\"friendly_name\": \"Programmable Outbound Minute - Australia\",\"prefixes\": [\"61\"]},{\"base_price\": \"0.095\",\"current_price\": \"0.095\",\"friendly_name\": \"Programmable Outbound Minute - Australia - Shared Cost Service\",\"prefixes\": [\"6113\"]},{\"base_price\": \"0.095\",\"current_price\": \"0.095\",\"friendly_name\": \"Programmable Outbound Minute - Australia - Mobile\",\"prefixes\": [\"614\",\"6116\",\"61400\",\"61401\",\"61402\",\"61403\",\"61404\",\"61405\",\"61406\",\"61407\",\"61408\",\"61409\",\"61410\",\"61411\",\"61412\",\"61413\",\"61414\",\"61415\",\"61416\",\"61417\",\"61418\",\"61419\",\"61421\",\"61422\",\"61423\",\"61424\",\"61425\",\"61426\",\"61427\",\"61428\",\"61429\",\"61430\",\"61431\",\"61432\",\"61433\",\"61434\",\"61435\",\"61437\",\"61438\",\"61439\",\"61447\",\"61448\",\"61449\",\"61450\",\"61451\",\"61452\",\"61453\",\"61455\",\"61456\",\"61457\",\"61458\",\"61459\",\"61466\",\"61467\",\"61474\",\"61477\",\"61478\",\"61481\",\"61482\",\"61487\",\"61490\",\"61497\",\"61498\",\"61499\",\"614202\",\"614203\",\"614204\",\"614205\",\"614206\",\"614207\",\"614208\",\"614209\",\"614444\",\"614683\",\"614684\",\"614685\",\"614686\",\"614687\",\"614688\",\"614689\",\"614790\",\"614791\",\"614880\",\"614881\",\"614882\",\"614883\",\"614884\",\"614885\",\"614886\",\"614887\",\"614889\"]}],\"price_unit\": \"USD\",\"url\": \"https://pricing.twilio.com/v1/Voice/Countries/US\"}" )); var response = CountryResource.Fetch("US", client: twilioRestClient); Assert.NotNull(response); }
static void Main(string[] args) { // Find your Account Sid and Token at twilio.com/console // DANGER! This is insecure. See http://twil.io/secure const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; const string authToken = "your_auth_token"; TwilioClient.Init(accountSid, authToken); var countries = CountryResource.Read(limit: 20); foreach (var record in countries) { Console.WriteLine(record.Country); } }
public static void Main(string[] args) { // Find your Account SID and Auth Token at twilio.com/console // To set up environmental variables, see http://twil.io/secure const string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"); const string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN"); TwilioClient.Init(accountSid, authToken); var countries = CountryResource.Read(); foreach (var country in countries) { Console.WriteLine(country.IsoCountry); } }
public void TestReadRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Get, Twilio.Rest.Domain.Voice, "/v1/DialingPermissions/Countries", "" ); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { CountryResource.Read(client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }
public void TestFetchRequest() { var twilioRestClient = Substitute.For <ITwilioRestClient>(); var request = new Request( HttpMethod.Get, Twilio.Rest.Domain.Pricing, "/v1/PhoneNumbers/Countries/US", "" ); twilioRestClient.Request(request).Throws(new ApiException("Server Error, no content")); try { CountryResource.Fetch("US", client: twilioRestClient); Assert.Fail("Expected TwilioException to be thrown for 500"); } catch (ApiException) {} twilioRestClient.Received().Request(request); }
public static async Task <CountryResource> GetVoicePricingAsync(ITwilioRestClient client, CountryCode countryCode) { return(await CountryResource.FetchAsync($"{countryCode:G}", client)); }
public CountryController() { _countryResource = new CountryResource(); }
public void TestInitialize() { CountryResource = new CountryResource(); Helpers.SetBaseAddress(); Helpers.Wipe(); }