Пример #1
0
        public async Task ShouldGetTokenIfAutenticateWithQrCodeIsCalledWithoutLoginMade()
        {
            MockDiscoveryRequest();
            MockDiscoveryAppRequest();

            MockLoginRequestWithouEventsUrl();
            var nubankClient = new Nubank(_mockRestClient.Object, "login", "password");

            var code = Guid.NewGuid().ToString();

            MockLiftRequest(code);

            await nubankClient.AutenticateWithQrCodeAsync(code);

            var expectedPayload = new
            {
                qr_code_id = code,
                type       = "login-webapp"
            };

            _mockRestClient.Verify(x => x.PostAsync <Dictionary <string, object> >(
                                       "lift_url",
                                       It.Is <object>(o => o.GetHashCode() == expectedPayload.GetHashCode()),
                                       It.Is <Dictionary <string, string> >(dictionary => IsValidAuthorizationHeader(dictionary))
                                       ), Times.Once());
        }
Пример #2
0
        static async Task Main()
        {
            Console.WriteLine("Nubank Client");
            Console.WriteLine("Please, type your login (CPF):");
            var login = Console.ReadLine().Trim();

            Console.WriteLine("Type your password:"******"You must authenticate with your phone to be able to access your data.");
                Console.WriteLine("Scan the QRCode below with you Nubank application on the following menu:");
                Console.WriteLine("Nu(Seu Nome) > Perfil > Acesso pelo site");
                Console.WriteLine();

                Console.WriteLine(result.GetQrCodeAsAscii());
                Console.WriteLine($"Use your phone to scan and after this press any key to continue...");
                Console.ReadKey();

                await nubankClient.AutenticateWithQrCodeAsync(result.Code);
            }

            try
            {
                var savings = await nubankClient.GetSavingsAsync();

                ConsoleTable
                .From(savings)
                .Write(Format.Alternative);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            var events = await nubankClient.GetEventsAsync();

            ConsoleTable
            .From(events)
            .Write(Format.Alternative);

            Console.ReadKey();
        }