final1
This commit is contained in:
@@ -15,6 +15,10 @@ namespace SecureBank.Website.Services
|
||||
Task<APIResponse<GetPasswordVariantResponse>> GetPasswordVariant(int accountId);
|
||||
Task<APIResponse<string>> Authentication(int accountId, AuthenticationRequest data);
|
||||
Task<APIResponse<string>> AuthenticationRefresh();
|
||||
Task<APIResponse> ChangePassword(ChangePasswordRequest data);
|
||||
Task<APIResponse<IEnumerable<AccountResponse>>> GetAccounts(int? id = null, string? iban = null);
|
||||
Task<APIResponse> ResetPassword(int accountId);
|
||||
Task<APIResponse> UnlockAccount(int accountId);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +61,7 @@ namespace SecureBank.Website.Services
|
||||
|
||||
public async Task<APIResponse<string>> Authentication(int accountId, AuthenticationRequest data)
|
||||
{
|
||||
string url = string.Format(_configuration.AccountsAuthentication, accountId);
|
||||
return await _apiClient.SendAsync<string, AuthenticationRequest>(APIMethodType.POST, url, data);
|
||||
return await _apiClient.SendAsync<string, AuthenticationRequest>(APIMethodType.POST, _configuration.AccountsAuthentication, data);
|
||||
}
|
||||
|
||||
public async Task<APIResponse<string>> AuthenticationRefresh()
|
||||
@@ -66,6 +69,37 @@ namespace SecureBank.Website.Services
|
||||
return await _apiClient.SendAsync<string>(APIMethodType.POST, _configuration.AccountsAuthenticationRefresh);
|
||||
}
|
||||
|
||||
public async Task<APIResponse> ChangePassword(ChangePasswordRequest data)
|
||||
{
|
||||
return await _apiClient.SendAsync(APIMethodType.PATCH, _configuration.AccountsChangePassword, data);
|
||||
}
|
||||
|
||||
public async Task<APIResponse<IEnumerable<AccountResponse>>> GetAccounts(int? id = null, string? iban = null)
|
||||
{
|
||||
Dictionary<string, string> query = new Dictionary<string, string>();
|
||||
if (id.HasValue)
|
||||
{
|
||||
query.Add("id", id.Value.ToString());
|
||||
}
|
||||
if (iban is not null)
|
||||
{
|
||||
query.Add("iban", iban);
|
||||
}
|
||||
return await _apiClient.SendAsync<IEnumerable<AccountResponse>>(APIMethodType.GET, _configuration.AccountsGetAccounts, query);
|
||||
}
|
||||
|
||||
public async Task<APIResponse> ResetPassword(int accountId)
|
||||
{
|
||||
string url = string.Format(_configuration.AccountsResetPassword, accountId);
|
||||
return await _apiClient.SendAsync(APIMethodType.PATCH, url);
|
||||
}
|
||||
|
||||
public async Task<APIResponse> UnlockAccount(int accountId)
|
||||
{
|
||||
string url = string.Format(_configuration.AccountsUnlockAccount, accountId);
|
||||
return await _apiClient.SendAsync(APIMethodType.PATCH, url);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
using SecureBank.Common.Accounts;
|
||||
using SecureBank.Common;
|
||||
using SecureBank.Website.API;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SecureBank.Website.Services
|
||||
{
|
||||
public interface IBalanceService
|
||||
{
|
||||
Task<APIResponse<decimal>> GetAccountBalance(int accountId);
|
||||
Task<APIResponse<decimal>> GetBalance();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class BalanceService : IBalanceService
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
private readonly APIClient _apiClient;
|
||||
private readonly APIEndpointsConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public BalanceService(APIClient apiClient, APIEndpointsConfiguration configuration)
|
||||
{
|
||||
_apiClient = apiClient;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region METHODS
|
||||
|
||||
public async Task<APIResponse<decimal>> GetAccountBalance(int accountId)
|
||||
{
|
||||
string url = string.Format(_configuration.BalanceGetAccountBalance, accountId);
|
||||
return await _apiClient.SendAsync<decimal>(APIMethodType.GET, url);
|
||||
}
|
||||
|
||||
public async Task<APIResponse<decimal>> GetBalance()
|
||||
{
|
||||
return await _apiClient.SendAsync<decimal>(APIMethodType.GET, _configuration.BalanceGetBalance);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using SecureBank.Common.Accounts;
|
||||
using SecureBank.Common;
|
||||
using SecureBank.Website.API;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SecureBank.Common.Transfers;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace SecureBank.Website.Services
|
||||
{
|
||||
public interface ITransfersService
|
||||
{
|
||||
Task<APIResponse> CreateAdminTransfer(CreateAdminTransferRequest data);
|
||||
Task<APIResponse> CreateUserTransfer(CreateUserTransferRequest data);
|
||||
Task<APIResponse<IEnumerable<TransferResponse>>> GetTransfers();
|
||||
Task<APIResponse<IEnumerable<TransferResponse>>> GetUserTransfers(int accountId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class TransfersService : ITransfersService
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
private readonly APIClient _apiClient;
|
||||
private readonly APIEndpointsConfiguration _configuration;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public TransfersService(APIClient apiClient, APIEndpointsConfiguration configuration)
|
||||
{
|
||||
_apiClient = apiClient;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region METHODS
|
||||
|
||||
public async Task<APIResponse<IEnumerable<TransferResponse>>> GetTransfers()
|
||||
{
|
||||
return await _apiClient.SendAsync<IEnumerable<TransferResponse>>(APIMethodType.GET, _configuration.TransfersGetTransfers);
|
||||
}
|
||||
|
||||
public async Task<APIResponse<IEnumerable<TransferResponse>>> GetUserTransfers(int accountId)
|
||||
{
|
||||
string url = string.Format(_configuration.TransfersGetUserTransfers, accountId);
|
||||
return await _apiClient.SendAsync<IEnumerable<TransferResponse>>(APIMethodType.GET, url);
|
||||
}
|
||||
|
||||
public async Task<APIResponse> CreateAdminTransfer(CreateAdminTransferRequest data)
|
||||
{
|
||||
return await _apiClient.SendAsync(APIMethodType.POST, _configuration.TransfersCreateAdminTransfer, data);
|
||||
}
|
||||
|
||||
public async Task<APIResponse> CreateUserTransfer(CreateUserTransferRequest data)
|
||||
{
|
||||
return await _apiClient.SendAsync(APIMethodType.POST, _configuration.TransfersCreateUserTransfer, data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user