Esempio n. 1
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();
        }
Esempio n. 2
0
        public async Task ShouldGetSavings()
        {
            MockDiscoveryRequest();

            MockLoginRequest();

            var getSavingsResponse = new GetSavingsResponse()
            {
                Data = new DataResponse()
                {
                    Viewer = new ViewerResponse()
                    {
                        SavingsAccount = new SavingsAccount()
                        {
                            Feed = _savings
                        }
                    }
                }
            };

            _mockRestClient
            .Setup(x => x.PostAsync <GetSavingsResponse>(
                       It.IsAny <string>(),
                       It.IsAny <object>(),
                       It.IsAny <Dictionary <string, string> >()
                       ))
            .ReturnsAsync(getSavingsResponse);

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

            var actualSavings = await nubankClient.GetSavingsAsync();

            Assert.Equal(_savings, actualSavings);

            _mockRestClient.Verify(x => x.PostAsync <GetSavingsResponse>(
                                       It.IsAny <string>(),
                                       It.IsAny <object>(),
                                       It.IsAny <Dictionary <string, string> >()
                                       ), Times.Once());
        }