Ejemplo n.º 1
0
        public void CanParseAccountXml()
        {
            Account account = AccountParser.Parse(_xml);

            Assert.AreEqual("Сбер-вклад", account.Name, "Account name should be parsed");
            Assert.AreEqual("BANK", account.Type, "Account type should be parsed");
            CheckIf.EqualId("5a977b5e74b8dbaa94239d15c889798d", account.Id, "Account id should be parsed");
            CheckIf.EqualId("4f21b4bc82713c0a03457515456ecb78", account.ParentId.Value, "Account parent id should be parsed");
            Assert.AreEqual("RUB", account.Commodity, "Account commodity should be parsed");
        }
        /// <summary>
        /// Gets merchant account. Privatbank API reference: <https://api.privatbank.ua/#p24/balance>.
        /// </summary>
        /// <param name="password">Private merchant password.</param>
        /// <param name="merchantId">Merchant id.</param>
        /// <param name="cardNumber">Merchant assossiated card number.</param>
        /// <returns></returns>
        public async Task <PrivatbankAccount> GetMerchantAccountAsync(string password, string merchantId, string cardNumber)
        {
            AccountBalanceRequest request  = new AccountBalanceRequest(password, merchantId, cardNumber);
            HttpResponseMessage   response = await _privatbankClient.GetMerchantDataAsync("balance", request.Xml);

            string xml = await response.Content.ReadAsStringAsync();

            AccountParser     parser  = new AccountParser();
            PrivatbankAccount account = parser.Parse(xml);

            return(account);
        }
        public void StoreToDisk()
        {
            AccountParser parser = new AccountParser();

            parser.WriteAccounts(_accounts);
        }