diff --git a/src/MAVN.Service.PayrexxIntegration.Domain/Enums/IntegrationSupportedCurrency.cs b/src/MAVN.Service.PayrexxIntegration.Domain/Enums/IntegrationSupportedCurrency.cs new file mode 100644 index 0000000..9f046fa --- /dev/null +++ b/src/MAVN.Service.PayrexxIntegration.Domain/Enums/IntegrationSupportedCurrency.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace MAVN.Service.PayrexxIntegration.Domain.Enums +{ + public enum IntegrationSupportedCurrency + { + CHF, + EUR, + GBP, + USD, + RUR + } +} diff --git a/src/MAVN.Service.PayrexxIntegration.Domain/Services/IPartnerIntegrationPropertiesFetcherService.cs b/src/MAVN.Service.PayrexxIntegration.Domain/Services/IPartnerIntegrationPropertiesFetcherService.cs index 4194c3f..b790205 100644 --- a/src/MAVN.Service.PayrexxIntegration.Domain/Services/IPartnerIntegrationPropertiesFetcherService.cs +++ b/src/MAVN.Service.PayrexxIntegration.Domain/Services/IPartnerIntegrationPropertiesFetcherService.cs @@ -11,5 +11,7 @@ public interface IPartnerIntegrationPropertiesService Task FetchPropertiesAsync(Guid partnerId); PayrexxIntegrationProperties DeserializePayrexxIntegrationProperties(string paymentIntegrationProperties); + + Task> GetIntegrationCurrency(); } } diff --git a/src/MAVN.Service.PayrexxIntegration.DomainServices/PartnerIntegrationPropertiesService.cs b/src/MAVN.Service.PayrexxIntegration.DomainServices/PartnerIntegrationPropertiesService.cs index 2b75a25..511b710 100644 --- a/src/MAVN.Service.PayrexxIntegration.DomainServices/PartnerIntegrationPropertiesService.cs +++ b/src/MAVN.Service.PayrexxIntegration.DomainServices/PartnerIntegrationPropertiesService.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using MAVN.Service.CustomerProfile.Client; using MAVN.Service.CustomerProfile.Client.Models.Enums; @@ -89,5 +90,10 @@ public PayrexxIntegrationProperties DeserializePayrexxIntegrationProperties(stri ErrorCode = IntegrationPropertiesErrorCode.None, }; } + + public async Task> GetIntegrationCurrency() + { + return await Task.FromResult(Enum.GetNames(typeof(IntegrationSupportedCurrency)).ToList()); + } } } diff --git a/src/MAVN.Service.PayrexxIntegration/Controllers/PayrexxIntegrationController.cs b/src/MAVN.Service.PayrexxIntegration/Controllers/PayrexxIntegrationController.cs index a969fef..6a87213 100644 --- a/src/MAVN.Service.PayrexxIntegration/Controllers/PayrexxIntegrationController.cs +++ b/src/MAVN.Service.PayrexxIntegration/Controllers/PayrexxIntegrationController.cs @@ -60,7 +60,7 @@ public Task GetPaymentIntegrationPropertie [ProducesResponseType(typeof(List), (int)HttpStatusCode.OK)] public Task> GetPaymentIntegrationSupportedCurrenciesAsync() { - return Task.FromResult(new List { "CHF" }); + return _partnerIntegrationPropertiesFetcherService.GetIntegrationCurrency(); } /// @@ -191,7 +191,7 @@ public async Task CheckPaymentAsync(CheckPaymentRequest r return result; } - switch(paymentStatus.Data[0].Status) + switch (paymentStatus.Data[0].Status) { case "waiting": result.PaymentStatus = PaymentStatus.Pending; diff --git a/tests/MAVN.Service.PayrexxIntegration.Tests/PartnerIntegrationPropertiesServiceTest.cs b/tests/MAVN.Service.PayrexxIntegration.Tests/PartnerIntegrationPropertiesServiceTest.cs new file mode 100644 index 0000000..f409f69 --- /dev/null +++ b/tests/MAVN.Service.PayrexxIntegration.Tests/PartnerIntegrationPropertiesServiceTest.cs @@ -0,0 +1,31 @@ +using System; +using MAVN.Service.CustomerProfile.Client; +using MAVN.Service.PayrexxIntegration.Domain.Enums; +using MAVN.Service.PayrexxIntegration.DomainServices; +using Moq; +using Xunit; + +namespace MAVN.Service.PayrexxIntegration.Tests +{ + public class PartnerIntegrationPropertiesServiceTest + { + + private readonly Mock _customerProfileClient = new Mock(); + private readonly string _fakeApiBaseUrl = Guid.NewGuid().ToString(); + + [Fact] + public async void CheckIntegrationSupportedCurrency_ReturnsNotEmptyStringList() + { + var expectedCount = Enum.GetNames(typeof(IntegrationSupportedCurrency)).Length; + + var result = await CreateSutInstance().GetIntegrationCurrency(); + + Assert.Equal(expectedCount, result.Count); + } + + private PartnerIntegrationPropertiesService CreateSutInstance() + { + return new PartnerIntegrationPropertiesService(_customerProfileClient.Object, _fakeApiBaseUrl); + } + } +}