Skip to content

Commit

Permalink
Merge pull request #7 from LykkeCity/from-restricted-area
Browse files Browse the repository at this point in the history
NewCustomerFromUnrestrictedAreaGroups
  • Loading branch information
KonstantinRyazantsev authored Nov 16, 2022
2 parents cae7a18 + 59b4f1d commit b27e829
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public class MailerliteConfig
public string AddCustomerToGroupUrl { set; get; }
public string FindGroupIdByNameUrl { set; get; }
public string DeleteCustomerFromGroupUrl { set; get; }
public IEnumerable<string> NewCustomerGroups { set; get; }
public IEnumerable<string> NewCustomerFromAllAreasGroups { set; get; }
public IEnumerable<string> NewCustomerFromUnrestrictedAreaGroups { set; get; }
public string KycReminderGroup { set; get; }
public IEnumerable<string> StatusesToDeleteFromKycReminderGroup { set; get; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ public async Task Consume(ConsumeContext<CreateCustomerCommand> context)

await _mailerlite.SetCustomerRegisteredAsync(command.Email, command.Timestamp);

var groupsToSubscribe = _mailerliteConfig.NewCustomerGroups;
var groupsToSubscribe = _mailerliteConfig.NewCustomerFromAllAreasGroups;
if (!command.FromRestrictedArea)
{
groupsToSubscribe = groupsToSubscribe
.Union(_mailerliteConfig.NewCustomerFromUnrestrictedAreaGroups)
.Union(new [] { _mailerliteConfig.KycReminderGroup });
}

Expand Down
24 changes: 18 additions & 6 deletions tests/Lykke.MailerliteTests/Sdk/WorkerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public class WorkerFixture
public string AddCustomerToGroupUrl { set; get; }
public string FindGroupIdByNameUrl { set; get; }
public string DeleteCustomerFromGroupUrl { set; get; }
public IEnumerable<string> NewCustomerGroups { set; get; }
public IEnumerable<string> NewCustomerFromAllAreasGroups { set; get; }
public IEnumerable<string> NewCustomerFromUnrestrictedAreaGroups { set; get; }
public string KycReminderGroup { set; get; }
public IEnumerable<string> StatusesToDeleteFromKycReminderGroup { set; get; }
public string MailerliteApiKey { get; }
Expand All @@ -59,7 +60,12 @@ public WorkerFixture(RabbitMqFixture rabbitMqFixture, PersistenceFixture persist
AddCustomerToGroupUrl = "http://fakeurl.com/groups/add";
FindGroupIdByNameUrl = "http://fakeurl.com/groups/search";
DeleteCustomerFromGroupUrl = "http://fakeurl.com/groups/delete/{0}/{1}";
NewCustomerGroups = new List<string>
NewCustomerFromAllAreasGroups = new List<string>
{
"test1",
"test2"
};
NewCustomerFromUnrestrictedAreaGroups = new List<string>
{
"test1",
"test2"
Expand Down Expand Up @@ -93,10 +99,15 @@ public async Task InitializeAsync()
{"Mailerlite:DeleteCustomerFromGroupUrl", DeleteCustomerFromGroupUrl},
{"Mailerlite:KycReminderGroup", KycReminderGroup},
};
var newCustomerGroupsList = NewCustomerGroups.ToList();
for (int index = 0; index < newCustomerGroupsList.Count; index++)
var newCustomerFromAllAreasGroupsList = NewCustomerFromAllAreasGroups.ToList();
for (int index = 0; index < newCustomerFromAllAreasGroupsList.Count; index++)
{
defaultAppSettings.Add($"Mailerlite:NewCustomerFromAllAreasGroups:{index}", newCustomerFromAllAreasGroupsList[index]);
}
var newCustomerFromUnrestrictedAreaGroupsList = NewCustomerFromUnrestrictedAreaGroups.ToList();
for (int index = 0; index < newCustomerFromUnrestrictedAreaGroupsList.Count; index++)
{
defaultAppSettings.Add($"Mailerlite:NewCustomerGroups:{index}", newCustomerGroupsList[index]);
defaultAppSettings.Add($"Mailerlite:NewCustomerFromUnrestrictedAreaGroups:{index}", newCustomerFromUnrestrictedAreaGroupsList[index]);
}
var statusesToDeleteFromKycReminderGroupList = StatusesToDeleteFromKycReminderGroup.ToList();
for (int index = 0; index < statusesToDeleteFromKycReminderGroupList.Count; index++)
Expand Down Expand Up @@ -125,7 +136,8 @@ public async Task InitializeAsync()
AddCustomerToGroupUrl = AddCustomerToGroupUrl,
FindGroupIdByNameUrl = FindGroupIdByNameUrl,
DeleteCustomerFromGroupUrl = DeleteCustomerFromGroupUrl,
NewCustomerGroups = NewCustomerGroups,
NewCustomerFromAllAreasGroups = NewCustomerFromAllAreasGroups,
NewCustomerFromUnrestrictedAreaGroups = NewCustomerFromUnrestrictedAreaGroups,
KycReminderGroup = KycReminderGroup,
StatusesToDeleteFromKycReminderGroup = StatusesToDeleteFromKycReminderGroup
}));
Expand Down

0 comments on commit b27e829

Please sign in to comment.