Exemplo n.º 1
0
        public async Task TestScoreClientStatusAsync()
        {
            var client = new ScoreClient(this.customerId,
                                         this.apiKey,
                                         string.Format("http://localhost:{0}", this.mockServer.Port));

            await client.ScoreAsync("15555555555", "create");

            Assert.AreEqual("POST", this.requests.Last().HttpMethod, "method is not as expected");
            Assert.AreEqual("/v1/score/15555555555", this.requests.Last().RawUrl, "path is not as expected");
            Assert.AreEqual("application/x-www-form-urlencoded", this.requestHeaders.Last()["Content-Type"]);
            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"]);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string customerId = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890";
            string apiKey     = "EXAMPLETE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==";

            string phoneNumber = "phone_number";

            string accountLifecycleEvent = "create";

            try
            {
                ScoreClient scoreClient = new ScoreClient(customerId, apiKey);
                RestClient.TelesignResponse telesignResponse = scoreClient.Score(phoneNumber, accountLifecycleEvent);

                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();
        }
Exemplo n.º 3
0
        public ScoreBoard()
        {
            _scoreUtil = new ScoreClient();
            InitializeComponent();


            SystemNavigationManager.GetForCurrentView().BackRequested += (sender, args) =>
            {
                var rootframe = Window.Current.Content as Frame;
                if ((rootframe != null) && rootframe.CanGoBack && (args.Handled == false))
                {
                    args.Handled = true;
                    rootframe.GoBack();
                }
            };
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var client = new ScoreClient();

            Console.ReadLine();
        }
Exemplo n.º 5
0
 public void TestScoreClientConstructors()
 {
     var ScoreClient = new ScoreClient(this.customerId, this.apiKey);
 }