-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a7045f
commit 9676978
Showing
11 changed files
with
210 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/MAVN.Service.Kyc.Domain/Services/INotificationsService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace MAVN.Service.Kyc.Domain.Services | ||
{ | ||
public interface INotificationsService | ||
{ | ||
Task NotifyKycApprovedAsync(string adminUserId, string adminUserEmail, string adminUserName, | ||
string partnerName); | ||
|
||
Task NotifyKycRejectedAsync(string adminUserId, string adminUserEmail, string adminUserName, string partnerName, | ||
string rejectionComment); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/MAVN.Service.Kyc.DomainServices/NotificationsService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Lykke.Common; | ||
using Lykke.RabbitMqBroker.Publisher; | ||
using MAVN.Service.Kyc.Domain.Services; | ||
using MAVN.Service.NotificationSystem.SubscriberContract; | ||
|
||
namespace MAVN.Service.Kyc.DomainServices | ||
{ | ||
public class NotificationsService : INotificationsService | ||
{ | ||
private readonly IRabbitPublisher<EmailMessageEvent> _emailsPublisher; | ||
private readonly string _backOfficeUrl; | ||
private readonly string _kycApprovedEmailTemplateId; | ||
private readonly string _kycApprovedEmailSubjectTemplateId; | ||
private readonly string _kycRejectedEmailTemplateId; | ||
private readonly string _kycRejectedEmailSubjectTemplateId; | ||
private readonly string _voucherManagerUrl; | ||
|
||
public NotificationsService( | ||
IRabbitPublisher<EmailMessageEvent> emailsPublisher, | ||
string backOfficeUrl, | ||
string kycApprovedEmailTemplateId, | ||
string kycApprovedEmailSubjectTemplateId, | ||
string kycRejectedEmailTemplateId, | ||
string kycRejectedEmailSubjectTemplateId, | ||
string voucherManagerUrl) | ||
{ | ||
_emailsPublisher = emailsPublisher; | ||
_backOfficeUrl = backOfficeUrl; | ||
_kycApprovedEmailTemplateId = kycApprovedEmailTemplateId; | ||
_kycApprovedEmailSubjectTemplateId = kycApprovedEmailSubjectTemplateId; | ||
_kycRejectedEmailTemplateId = kycRejectedEmailTemplateId; | ||
_kycRejectedEmailSubjectTemplateId = kycRejectedEmailSubjectTemplateId; | ||
_voucherManagerUrl = voucherManagerUrl; | ||
} | ||
|
||
public async Task NotifyKycApprovedAsync(string adminUserId, string adminUserEmail, string adminUserName, string partnerName) | ||
{ | ||
var values = new Dictionary<string, string> | ||
{ | ||
{"BusinessName", partnerName}, | ||
{"VoucherManagerUrl", _backOfficeUrl + _voucherManagerUrl}, | ||
{"AdminUserName", $" {adminUserName}"}, | ||
}; | ||
|
||
await SendEmailAsync(adminUserId, adminUserEmail, values, _kycApprovedEmailTemplateId, | ||
_kycApprovedEmailSubjectTemplateId); | ||
} | ||
|
||
public async Task NotifyKycRejectedAsync(string adminUserId, string adminUserEmail, string adminUserName, string partnerName, string rejectionComment) | ||
{ | ||
var values = new Dictionary<string, string> | ||
{ | ||
{"BusinessName", partnerName}, | ||
{"RejectionComment", rejectionComment}, | ||
{"AdminUserName", $" {adminUserName}"}, | ||
}; | ||
|
||
await SendEmailAsync(adminUserId, adminUserEmail, values, _kycRejectedEmailTemplateId, | ||
_kycRejectedEmailSubjectTemplateId); | ||
} | ||
|
||
private async Task SendEmailAsync(string customerId, string destination, Dictionary<string, string> values, string emailTemplateId, string subjectTemplateId) | ||
{ | ||
if (!string.IsNullOrWhiteSpace(destination)) | ||
values["target_email"] = destination; | ||
|
||
await _emailsPublisher.PublishAsync(new EmailMessageEvent | ||
{ | ||
CustomerId = customerId, | ||
MessageTemplateId = emailTemplateId, | ||
SubjectTemplateId = subjectTemplateId, | ||
TemplateParameters = values, | ||
Source = $"{AppEnvironment.Name} - {AppEnvironment.Version}" | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
using JetBrains.Annotations; | ||
using Lykke.Sdk.Settings; | ||
using MAVN.Service.AdminManagement.Client; | ||
using MAVN.Service.PartnerManagement.Client; | ||
|
||
namespace MAVN.Service.Kyc.Settings | ||
{ | ||
[UsedImplicitly(ImplicitUseTargetFlags.WithMembers)] | ||
public class AppSettings : BaseAppSettings | ||
{ | ||
public KycSettings KycService { get; set; } | ||
|
||
public AdminManagementServiceClientSettings AdminManagementService { get; set; } | ||
|
||
public PartnerManagementServiceClientSettings PartnerManagementService { get; set; } | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/MAVN.Service.Kyc/Settings/EmailSettings/KycApprovedEmail.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace MAVN.Service.Kyc.Settings.EmailSettings | ||
{ | ||
public class KycApprovedEmail | ||
{ | ||
public string EmailTemplateId { set; get; } | ||
public string SubjectTemplateId { set; get; } | ||
public string VoucherManagerUrl { get; set; } | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/MAVN.Service.Kyc/Settings/EmailSettings/KycRejectedEmail.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace MAVN.Service.Kyc.Settings.EmailSettings | ||
{ | ||
public class KycRejectedEmail | ||
{ | ||
public string EmailTemplateId { set; get; } | ||
public string SubjectTemplateId { set; get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters