Example #1
0
        public void ExtractTest()
        {
            //Moq don`t work for silverlight yet
            //making my own mock
            var mockjson = @"[ { ""bill"": { ""state"": ""overdue"", ""id"": ""55256cd0-10f7-4fd3-a3be-213bfe01857d"", ""summary"": { ""due_date"": ""2015-04-20"", ""close_date"": ""2015-04-07"", ""past_balance"": 0, ""total_balance"": 38933, ""interest"": 0, ""total_cumulative"": 38933, ""paid"": 38933, ""minimum_payment"": 5840, ""open_date"": ""2015-03-17"" }, ""_links"": { ""self"": { ""href"": ""https://prod-accounts.nubank.com.br/api/bills/55256cd0-10f7-4fd3-a3be-213bfe01857d"" }, ""boleto_email"": { ""href"": ""https://prod-accounts.nubank.com.br/api/bills/55256cd0-10f7-4fd3-a3be-213bfe01857d/boleto/email"" }, ""barcode"": { ""href"": ""https://prod-accounts.nubank.com.br/api/bills/55256cd0-10f7-4fd3-a3be-213bfe01857d/boleto/barcode"" } }, ""barcode"": ""03394643200000389339646532300000001745800102"", ""linha_digitavel"": ""03399.64652 32300.000000 17458.001025 4 64320000038933"", ""line_items"": [ { ""post_date"": ""2015-03-31"", ""amount"": 3850, ""title"": ""Rest Bolinha"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/551585a8-244c-4ab8-9dce-0113d465ad8e"" }, { ""post_date"": ""2015-03-31"", ""amount"": 12505, ""title"": ""Posto de Servico Dinam"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/55152410-5315-4aeb-b7f3-263170767191"" }, { ""post_date"": ""2015-04-02"", ""amount"": 4180, ""title"": ""Brunetto Massa e Risot"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/551ac6d1-3c44-4f68-a404-788083f00955"" }, { ""post_date"": ""2015-04-07"", ""amount"": 18398, ""title"": ""Pao de Acucar Lj"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/55219aaa-2b9d-40bc-a8d3-bb31f14d2382"" } ] } }, { ""bill"": { ""state"": ""closed"", ""id"": ""554cc619-5998-4687-8fd3-743fd88ef704"", ""summary"": { ""due_date"": ""2015-05-20"", ""close_date"": ""2015-05-07"", ""past_balance"": 0, ""total_balance"": 174326, ""interest"": 0, ""total_cumulative"": 174326, ""paid"": 0, ""minimum_payment"": 26149, ""open_date"": ""2015-04-07"" }, ""_links"": { ""self"": { ""href"": ""https://prod-accounts.nubank.com.br/api/bills/554cc619-5998-4687-8fd3-743fd88ef704"" }, ""boleto_email"": { ""href"": ""https://prod-accounts.nubank.com.br/api/bills/554cc619-5998-4687-8fd3-743fd88ef704/boleto/email"" }, ""barcode"": { ""href"": ""https://prod-accounts.nubank.com.br/api/bills/554cc619-5998-4687-8fd3-743fd88ef704/boleto/barcode"" } }, ""barcode"": ""03397643400001743269646532300000001745800102"", ""linha_digitavel"": ""03399.64652 32300.000000 17458.001025 7 64340000174326"", ""line_items"": [ { ""post_date"": ""2015-04-08"", ""amount"": -38933, ""title"": ""Pagamento recebido"" }, { ""post_date"": ""2015-04-11"", ""amount"": 17270, ""title"": ""Eolo Restaurante e Caf"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/5526abd4-7439-4749-a39b-1ac6b1914d60"" }, { ""post_date"": ""2015-04-14"", ""amount"": 11162, ""title"": ""Centreville Serv"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/552b044e-acd3-4fc7-be52-07ff1624aa1e"" }, { ""post_date"": ""2015-04-14"", ""amount"": 4299, ""title"": ""Coisa Boa"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/5527ffc3-ce31-4797-8edf-112dfebb30df"" }, { ""post_date"": ""2015-04-14"", ""amount"": 8200, ""title"": ""Purpurina Of de Pizzas"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/5528642e-324a-4518-a970-261d2dd7f8be"" }, { ""post_date"": ""2015-04-15"", ""amount"": 10856, ""title"": ""la da Venda"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/552ad24a-ee6d-41ae-9163-1d5bc05ad05d"" }, { ""post_date"": ""2015-04-18"", ""amount"": 1500, ""title"": ""Stop Green"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/55302f74-34f7-4dfa-927a-623c1b8de677"" }, { ""post_date"": ""2015-04-18"", ""amount"": 6674, ""title"": ""Supermercados Mambo"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/553037ae-a115-46dc-97cc-cb61385575da"" }, { ""post_date"": ""2015-04-21"", ""amount"": 858, ""title"": ""Schoenberger Sorv"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/55341952-3916-47df-8fad-7bce92626a97"" }, { ""post_date"": ""2015-04-21"", ""amount"": 1274, ""title"": ""Schoenberger Sorv"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/55342ed2-0402-491d-8d46-13fd62953be8"" }, { ""post_date"": ""2015-04-21"", ""amount"": 5306, ""title"": ""Auto Posto Playgas"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/5532c42f-5d22-426a-94f9-15ac615fc367"" }, { ""post_date"": ""2015-04-23"", ""amount"": 21356, ""title"": ""Zaffari Lj 25 Bourbon"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/5536b428-e638-4c50-9413-0b45189bcf42"" }, { ""post_date"": ""2015-04-23"", ""amount"": 11630, ""title"": ""America Bourbon"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/55369f68-0230-4c03-b210-e8bbc0e49135"" }, { ""post_date"": ""2015-04-24"", ""amount"": 11088, ""title"": ""Wall Street Bar"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/5538554b-8379-435d-9e0f-3d947b7958ef"" }, { ""post_date"": ""2015-04-28"", ""amount"": 12601, ""title"": ""Auto Posto Cerro Cora"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/553d2f73-8871-4fc0-9d89-ae2bc6de5cfd"" }, { ""post_date"": ""2015-04-28"", ""amount"": 7333, ""title"": ""Pao de Acucar Lj"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/553d2d14-9da9-41a1-8882-ff7533a0a6ed"" }, { ""post_date"": ""2015-04-29"", ""amount"": 7606, ""title"": ""Esso Auto Posto"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/55355574-3670-4c19-aca3-48fc364992f0"" }, { ""post_date"": ""2015-05-05"", ""amount"": 12169, ""title"": ""Casa do Espeto Pompéia"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/5545189a-f16d-4938-8bd2-cb9a197900fa"" }, { ""post_date"": ""2015-05-05"", ""amount"": 8056, ""title"": ""Supermercados Mambo"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/5542b9b0-d502-4022-9470-887d586d3076"" }, { ""post_date"": ""2015-05-05"", ""amount"": 2400, ""title"": ""Ta Kombinado Pasta"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/554248d7-9fc0-4c18-8a35-6d20239f8cd3"" }, { ""post_date"": ""2015-05-06"", ""amount"": 6180, ""title"": ""Hellofood Intermediaca Sao Paulo Bra"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/5546a598-7d1d-42c8-878c-965f35a0fa9b"" }, { ""post_date"": ""2015-05-06"", ""amount"": 4758, ""title"": ""de Guste Cafe Ltda Sao Paulo Bra"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/554a410c-ecbc-4469-93b5-96edf1657f41"" }, { ""post_date"": ""2015-05-07"", ""amount"": 1750, ""title"": ""Bar Lanches Galhardo"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/5548f7de-be3e-4a42-977a-25fce7d07bab"" } ] } }, { ""bill"": { ""state"": ""open"", ""summary"": { ""minimum_payment"": 5944, ""total_balance"": 39627, ""interest"": 0, ""due_date"": ""2015-06-20"", ""close_date"": ""2015-06-05"", ""total_cumulative"": 39627, ""open_date"": ""2015-05-07"", ""past_balance"": 0 }, ""_links"": { ""barcode"": { ""href"": ""https://prod-accounts.nubank.com.br/api/accounts/55085752-3dcf-42a5-870a-81eed6b08172/bills/open/boleto/barcode"" }, ""boleto_email"": { ""href"": ""https://prod-accounts.nubank.com.br/api/accounts/55085752-3dcf-42a5-870a-81eed6b08172/bills/open/boleto/email"" } }, ""barcode"": ""03395646500000396279646532300000001745800102"", ""linha_digitavel"": ""03399.64652 32300.000000 17458.001025 5 64650000039627"", ""line_items"": [ { ""post_date"": ""2015-05-09"", ""amount"": 1642, ""title"": ""Al Fanous Restaurante"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/554b8b66-0f3b-444b-9f67-2f467bd2e032"" }, { ""post_date"": ""2015-05-12"", ""amount"": 18402, ""title"": ""Bem Brasil Grelhados"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/554d6515-669f-4214-8cab-d67113deebdb"" }, { ""post_date"": ""2015-05-15"", ""amount"": 8901, ""title"": ""Babbo Giovanni"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/55568d22-998d-47a0-a4b8-315e21b3cbda"" }, { ""post_date"": ""2015-05-15"", ""amount"": 6217, ""title"": ""Apl* Itunes.com/bill"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/555653bc-9070-49bc-ab4d-c7556db1ff34"" }, { ""post_date"": ""2015-05-15"", ""amount"": 311, ""title"": ""Apl* Itunes.com/bill"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/55564ec1-aeb8-44cd-87d8-b1f434c03148"" }, { ""post_date"": ""2015-05-15"", ""amount"": 2200, ""title"": ""Vitrollasfoodtruck"", ""index"": 0, ""charges"": 1, ""href"": ""nuapp://transaction/5556120b-d490-4ff1-b644-2a8732a02192"" }, { ""post_date"": ""2015-05-15"", ""amount"": 1954, ""title"": ""Gol Tran Aereo Interne"", ""index"": 0, ""charges"": 2, ""href"": ""nuapp://transaction/55540206-0099-4c01-9209-81f298dc9b93"" } ] } }, { ""bills"": [ { ""state"": ""future"", ""summary"": { ""minimum_payment"": 293, ""total_balance"": 1954, ""interest"": 0, ""due_date"": ""2015-07-20"", ""close_date"": ""2015-07-07"", ""total_cumulative"": 1954, ""open_date"": ""2015-06-05"", ""past_balance"": 0 }, ""_links"": { }, ""line_items"": [ { ""post_date"": ""2015-06-15"", ""amount"": 1954, ""title"": ""Gol Tran Aereo Interne"", ""index"": 1, ""charges"": 2, ""href"": ""nuapp://transaction/55540206-0099-4c01-9209-81f298dc9b93"" } ] } ] } ]";

            var billResponse = new ExtractResponse();
            billResponse.Data = JsonConvert.DeserializeObject<List<RootObject>>(mockjson);
            billResponse.Status = 200;

            var ExtractVM = new ViewModel.ExtractVM(billResponse);
            Assert.IsTrue(ExtractVM.Bills.Count > 0);
        }
Example #2
0
        private async Task GetExtract()
        {
            ExtractVM = null; 
            
            try
            {
                var extractResponse = await Helper.Current.Api.GetExtract();

                if(extractResponse.Status == 200)
                {
                    ExtractVM = new ViewModel.ExtractVM(extractResponse);
                }
                else
                    HandleError(extractResponse);
            }
            catch(Exception ex)
            {
                IsError = true;
                ErrorMessage = "Parece que você está sem internet! Por favor,verifique a sua conexão.";
            }
        }