banking-bot/BankingBot/BankingClient.cs
2017-02-12 22:21:36 +00:00

71 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using BankingBot.Contracts;
using BankingBot.ActionManagers.LoginManagers;
using BankingBot.Models;
using OpenQA.Selenium;
using BankingBot.ActionManagers.AccountManagers;
using BankingBot.Responses;
using BankingBot.Enums;
namespace BankingBot
{
public class BankingClient <T> : IClient
where T : IWebDriver
{
#region Dependencies
readonly ILoginManager loginManager;
readonly IAccountManager accountManager;
protected readonly IBrowserBot BrowserBot;
#endregion
public ILoginCredentials LoginCredentials { get; private set; }
public Provider Provider { get; private set; }
public bool IsLoggedIn
{
get { return LoginCredentials != null; }
}
public BankingClient()
{
BrowserBot = new BrowserBot<T>();
loginManager = new LoginManager(BrowserBot);
accountManager = new AccountManager(BrowserBot);
}
#region Actions - Login Manager
public Response Login(ILoginCredentials credentials)
{
LoginCredentials = credentials;
Provider = credentials.GetProvider();
var response = loginManager.Login(credentials);
if (response.Status == ResponseStatus.Success)
{
accountManager.Init(Provider);
}
return response;
}
#endregion
public decimal GetBalance()
{
throw new NotImplementedException();
}
#region Actions - Account Manager
public IEnumerable<Account> GetAccounts()
{
return accountManager.GetAccounts();
}
#endregion
}
}