public static void Main(string[] args) { string customerId = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890"; string apiKey = "EXAMPLETE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw=="; string phoneNumber = "phone_number"; string ucid = "BACF"; try { PhoneIdClient phoneIdClient = new PhoneIdClient(customerId, apiKey); RestClient.TelesignResponse telesignResponse = phoneIdClient.Score(phoneNumber, ucid); if (telesignResponse.OK) { Console.WriteLine(string.Format("Phone number {0} has a '{1}' risk level and the recommendation is to '{2}' the transaction.", phoneNumber, telesignResponse.Json["risk"]["level"], telesignResponse.Json["risk"]["recommendation"])); } } catch (Exception e) { Console.WriteLine(e); } Console.WriteLine("Press any key to quit."); Console.ReadKey(); }
static void Main(string[] args) { string customerId = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890"; string apiKey = "EXAMPLETE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw=="; string phoneNumber = "phone_number"; string extraDigit = "0"; string incorrectPhoneNumber = string.Format("{0}{1}", phoneNumber, extraDigit); try { PhoneIdClient phoneIdClient = new PhoneIdClient(customerId, apiKey); RestClient.TelesignResponse telesignResponse = phoneIdClient.PhoneId(incorrectPhoneNumber); if (telesignResponse.OK) { Console.WriteLine(string.Format("Cleansed phone number has country code {0} and phone number is {1}.", telesignResponse.Json["numbering"]["cleansing"]["call"]["country_code"], telesignResponse.Json["numbering"]["cleansing"]["call"]["phone_number"])); Console.WriteLine(string.Format("Original phone number was {0}.", telesignResponse.Json["numbering"]["original"]["complete_phone_number"])); } } catch (Exception e) { Console.WriteLine(e); } Console.WriteLine("Press any key to quit."); Console.ReadKey(); }
public async Task TestPhoneIdClientPhoneIdAsync() { var client = new PhoneIdClient(this.customerId, this.apiKey, string.Format("http://localhost:{0}", this.mockServer.Port)); await client.PhoneIdAsync("15555555555"); Assert.AreEqual("POST", this.requests.Last().HttpMethod, "method is not as expected"); Assert.AreEqual("/v1/phoneid/15555555555", this.requests.Last().RawUrl, "path is not as expected"); Assert.AreEqual("application/json", this.requestHeaders.Last()["Content-Type"], "Content-Type header is not as expected"); Assert.AreEqual("HMAC-SHA256", this.requestHeaders.Last()["x-ts-auth-method"], "x-ts-auth-method header is not as expected"); Guid dummyGuid; Assert.IsTrue(Guid.TryParse(this.requestHeaders.Last()["x-ts-nonce"], out dummyGuid), "x-ts-nonce header is not a valid UUID"); DateTime dummyDateTime; Assert.IsTrue(DateTime.TryParse(this.requestHeaders.Last()["Date"], out dummyDateTime), "Date header is not valid rfc2616 format"); Assert.IsNotNull(this.requestHeaders.Last()["Authorization"]); }
static void Main(string[] args) { string customerId = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890"; string apiKey = "EXAMPLETE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw=="; string phoneNumber = "phone_number"; string phoneTypeVoip = "5"; try { PhoneIdClient phoneIdClient = new PhoneIdClient(customerId, apiKey); RestClient.TelesignResponse telesignResponse = phoneIdClient.PhoneId(phoneNumber); if (telesignResponse.OK) { if (telesignResponse.Json["phone_type"]["code"].ToString() == phoneTypeVoip) { Console.WriteLine(string.Format("Phone number {0} is a VOIP phone.", phoneNumber)); } else { Console.WriteLine(string.Format("Phone number {0} is not a VOIP phone.", phoneNumber)); } } } catch (Exception e) { Console.WriteLine(e); } Console.WriteLine("Press any key to quit."); Console.ReadKey(); }
static void Main(string[] args) { string customerId = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890"; string apiKey = "EXAMPLETE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw=="; string phoneNumber = "phone_number"; Dictionary <string, object> contact = new Dictionary <string, object>(); contact.Add("contact", new Dictionary <string, object>()); Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("addons", contact); try { PhoneIdClient phoneIdClient = new PhoneIdClient(customerId, apiKey); RestClient.TelesignResponse telesignResponse = phoneIdClient.PhoneId(phoneNumber, parameters); if (telesignResponse.OK) { Console.WriteLine(telesignResponse.Json); } } catch (Exception e) { Console.WriteLine(e); } Console.WriteLine("Press any key to quit."); Console.ReadKey(); }
public static void Main(string[] args) { string customerId = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890"; string apiKey = "EXAMPLETE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw=="; string phoneNumber = "phone_number"; string ucid = "ATCK"; try { PhoneIdClient phoneIdClient = new PhoneIdClient(customerId, apiKey); RestClient.TelesignResponse telesignResponse = phoneIdClient.NumberDeactivation(phoneNumber, ucid); if (telesignResponse.OK) { if (telesignResponse.Json["number_deactivation"]["last_deactivated"].Type != JTokenType.Null) { Console.WriteLine(string.Format("Phone number {0} was last deactivated {1}.", telesignResponse.Json["number_deactivation"]["number"], telesignResponse.Json["number_deactivation"]["last_deactivated"])); } else { Console.WriteLine(string.Format("Phone number {0} has not been deactivated.", telesignResponse.Json["number_deactivation"]["number"])); } } } catch (Exception e) { Console.WriteLine(e); } Console.WriteLine("Press any key to quit."); Console.ReadKey(); }
public void TestPhoneIdClientConstructors() { var phoneIdClient = new PhoneIdClient(this.customerId, this.apiKey); }