diff --git a/BankingBot/ActionManagers/LoginManagers/BarclaysLoginManager.cs b/BankingBot/ActionManagers/LoginManagers/BarclaysLoginManager.cs
new file mode 100644
index 0000000..dd72901
--- /dev/null
+++ b/BankingBot/ActionManagers/LoginManagers/BarclaysLoginManager.cs
@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using BankingBot.Attributes;
+using BankingBot.Contracts;
+using BankingBot.Enums;
+using BankingBot.LoginCredentials;
+using BankingBot.Responses;
+using OpenQA.Selenium;
+
+namespace BankingBot.ActionManagers.LoginManagers
+{
+ [ProviderIdentifier(Provider.Barclays)]
+ public class BarclaysLoginManager : IProviderLoginManager
+ {
+ private readonly IScriptManager _scriptManager;
+ private readonly IBrowserBot _browserBot;
+
+ private static class Urls
+ {
+ public const string Login = "https://bank.barclays.co.uk/olb/auth/LoginLink.action";
+ }
+
+ public BarclaysLoginManager(
+ IBrowserBot browserBot,
+ IScriptManager scriptManager)
+ {
+ _browserBot = browserBot;
+ _scriptManager = scriptManager;
+ }
+
+ public Response Login(ILoginCredentials credentials)
+ {
+ var barcCreds = credentials as BarclaysLoginCredentials;
+
+ _browserBot.WebDriver.Url = Urls.Login;
+ _browserBot.WebDriver.Navigate();
+
+ _browserBot.WebDriver.FindElement(By.Id("surname")).SendKeys(barcCreds.Surname);
+
+ // Chosen to use membership number
+ if (barcCreds.MembershipNumber != null)
+ {
+ _browserBot.WebDriver.FindElement(By.Id("membership-radio")).Click();
+ _browserBot.WebDriver.FindElement(By.Id("membership-num")).SendKeys(barcCreds.MembershipNumber);
+ }
+ // Chosen to use card number
+ else if (barcCreds.CardNumber != null)
+ {
+ _browserBot.WebDriver.FindElement(By.Id("card-radio")).Click();
+
+ var cardSplit = Helpers.CardHelpers.SplitCardNumber(barcCreds.CardNumber);
+ for (var i = 0; i < 4; i++)
+ {
+ var fieldId = $"debitCardSet{i + 1}";
+ _browserBot.WebDriver.FindElement(By.Id(fieldId)).SendKeys(cardSplit[i]);
+ }
+ }
+
+ _browserBot.WebDriver.FindElement(By.Id("forward")).Click();
+ }
+ }
+}
diff --git a/BankingBot/BankingBot.csproj b/BankingBot/BankingBot.csproj
index 46dc715..609e5dc 100644
--- a/BankingBot/BankingBot.csproj
+++ b/BankingBot/BankingBot.csproj
@@ -61,6 +61,7 @@
+
diff --git a/BankingBot/Enums/Provider.cs b/BankingBot/Enums/Provider.cs
index 7b0a642..cd398fe 100644
--- a/BankingBot/Enums/Provider.cs
+++ b/BankingBot/Enums/Provider.cs
@@ -2,6 +2,7 @@
{
public enum Provider
{
- Lloyds
+ Lloyds,
+ Barclays
}
}
\ No newline at end of file
diff --git a/BankingBot/Helpers/CardHelpers.cs b/BankingBot/Helpers/CardHelpers.cs
new file mode 100644
index 0000000..e9fc9aa
--- /dev/null
+++ b/BankingBot/Helpers/CardHelpers.cs
@@ -0,0 +1,21 @@
+using System;
+
+namespace BankingBot.Helpers
+{
+ public static class CardHelpers
+ {
+ public static string[] SplitCardNumber(string cardNumber)
+ {
+ if (cardNumber.Length != 16)
+ throw new ArgumentException("Card number was have a length of 16 characters.");
+
+ return new[]
+ {
+ cardNumber.Substring(0, 4),
+ cardNumber.Substring(4, 4),
+ cardNumber.Substring(8, 4),
+ cardNumber.Substring(12, 4)
+ };
+ }
+ }
+}
diff --git a/BankingBot/LoginCredentials/BarclaysLoginCredentials.cs b/BankingBot/LoginCredentials/BarclaysLoginCredentials.cs
new file mode 100644
index 0000000..ae93573
--- /dev/null
+++ b/BankingBot/LoginCredentials/BarclaysLoginCredentials.cs
@@ -0,0 +1,17 @@
+using BankingBot.Attributes;
+using BankingBot.Enums;
+
+namespace BankingBot.LoginCredentials
+{
+ [ProviderIdentifier(Provider.Barclays)]
+ public class BarclaysLoginCredentials : LoginCredentials
+ {
+ public string Surname;
+ public string MembershipNumber;
+ public string CardNumber;
+ public string SortCode;
+ public string AccountNumber;
+ public string Password;
+ public string MemorableWord;
+ }
+}