Esempio n. 1
0
        public async void RetrievesTransactions()
        {
            KontomatikApi api = await LoginWithMockCredentials();

            string transactions = await api.GetTransactionsXml("PL05114020170000400213015148", new DateTime(2000, 1, 1));

            Assert.Contains("<kind>PRZELEW ZEWNĘTRZNY</kind>", transactions);
        }
Esempio n. 2
0
        public async void RetrievesFinHealthIndicator()
        {
            KontomatikApi api = await LoginWithMockCredentials();

            string finHealtIndicator = await api.GetFinHealthIndicatorXml();

            Assert.Contains("<reply", finHealtIndicator);
        }
Esempio n. 3
0
        public async void RetrievesAccounts()
        {
            KontomatikApi api = await LoginWithMockCredentials();

            string accounts = await api.GetAccountsXml();

            Assert.Contains("<iban>PL05114020170000400213015148</iban>", accounts);
        }
Esempio n. 4
0
        public async void RetrievesOwnerData()
        {
            KontomatikApi api = await LoginWithMockCredentials();

            string owner = await api.GetOwnerDetailsXml();

            Assert.Contains("<name>Jan Kowalski</name>", owner);
        }
Esempio n. 5
0
        private async Task <KontomatikApi> LoginWithMockCredentials()
        {
            KontomatikApi api = new KontomatikApi(appSettings.ApiKey, appSettings.ApiUrl);
            Queue <KontomatikCredential> credentials = new Queue <KontomatikCredential>();

            credentials.Enqueue(new KontomatikCredential("STATIC_LOGIN", "test"));
            credentials.Enqueue(new KontomatikCredential("STATIC_PASSWORD", "Test123"));
            string loginResult = await api.EnterCredentials("Mbank", credentials);

            return(api);
        }
Esempio n. 6
0
        private async Task runCommand(Dictionary <string, string> commandInfo, KontomatikApi api)
        {
            string Id          = commandInfo["id"];
            string apiResponse = "";
            string commandName = GetCommandName(Id);

            try
            {
                switch (commandName)
                {
                case "ImportOwnerDetails":
                    apiResponse = await api.GetOwnerDetailsXml();

                    break;

                case "ImportAccounts":
                    apiResponse = await api.GetAccountsXml();

                    break;

                case "ImportTransactions":
                    apiResponse = await api.GetTransactionsXml(commandInfo["iban"],
                                                               Convert.ToDateTime(commandInfo["since"]));

                    break;

                case "FinHealthIndicator":
                    apiResponse = await api.GetFinHealthIndicatorXml();

                    break;

                default:
                    this.SendToClient(Id, "", "Unrecognized command: " + Id);
                    break;
                }
                if (!String.IsNullOrEmpty(apiResponse))
                {
                    this.SendToClient(Id, apiResponse, null);
                }
            }
            catch (KontomatikException exception)
            {
                this.SendToClient(Id, "", exception.Message);
            }
        }
Esempio n. 7
0
        private async Task HandleKontomatikJson(string json)
        {
            Dictionary <string, string> values = JsonConvert.DeserializeObject <Dictionary <string, string> >(json);

            if (values == null)
            {
                this.SendToClient(null, null, "Empty datagram received");
                throw new KontomatikException("WebSocket received an empty datagram");
            }
            if (values.ContainsKey("sessionId") && values.ContainsKey("externalOwnerId") && api == null)
            {
                api = new KontomatikApi(values["sessionId"],
                                        appsettings.GetValue <String>("externalOwnerId"),
                                        appsettings.GetValue <String>("ApiKey"),
                                        appsettings.GetValue <String>("ApiUrl"));
            }
            if (values.ContainsKey("id"))
            {
                await runCommand(values, api);
            }
        }
Esempio n. 8
0
        public async void LogsInWithMockCredentials()
        {
            KontomatikApi api = await LoginWithMockCredentials();

            Assert.NotNull(api);
        }