Add autorenew filed to subscription export

This commit is contained in:
harshabacharaju 2022-04-27 10:29:23 -07:00
Родитель e046ba2899
Коммит bebe7168af
3 изменённых файлов: 18 добавлений и 7 удалений

Просмотреть файл

@ -40,6 +40,8 @@ internal record Subscription
public ItemType ProductType { get; init; } = new ItemType();
public bool AutoRenewEnabled { get; init; }
public NewCommerceEligibility MigrationEligibility { get; set; } = new NewCommerceEligibility();
public string MigratedFromSubscriptionId { get; init; } = string.Empty;
@ -63,6 +65,8 @@ internal record MigrationRequest
public DateTime ExpirationDate { get; init; }
public bool AutoRenewEnabled { get; init; }
public bool MigrationEligible { get; set; }
public string NcePsa { get; set; } = string.Empty;

Просмотреть файл

@ -226,7 +226,7 @@ internal class NewCommerceMigrationProvider : INewCommerceMigrationProvider
}
var result = this.PrepareMigrationResult(migrationResult, migrationResult.BatchId, migration, migrationError);
return (result, migration?.AddOnMigrations);
return (result!, migration?.AddOnMigrations ?? Enumerable.Empty<NewCommerceMigration>());
}
/// <summary>
@ -363,12 +363,18 @@ internal class NewCommerceMigrationProvider : INewCommerceMigrationProvider
/// <returns>The add on migration results.</returns>
private List<MigrationResult> PrepareAddOnMigrationResult(IEnumerable<MigrationRequest> addOnMigrationRequests, string batchId, NewCommerceMigration? newCommerceMigration, NewCommerceMigrationError? newCommerceMigrationError, List<MigrationResult> migrationResults)
{
foreach (var addOnMigrationResponse in newCommerceMigration.AddOnMigrations)
if(newCommerceMigration != null)
{
var addOnMigrationRequest = addOnMigrationRequests.SingleOrDefault(n => n.LegacySubscriptionId.Equals(addOnMigrationResponse.CurrentSubscriptionId, StringComparison.OrdinalIgnoreCase));
addOnMigrationResponse.Status = newCommerceMigration.Status;
addOnMigrationResponse.Id = newCommerceMigration.Id;
PrepareMigrationResult(addOnMigrationRequest, batchId, addOnMigrationResponse, newCommerceMigrationError, migrationResults);
foreach (var addOnMigrationResponse in newCommerceMigration.AddOnMigrations)
{
var addOnMigrationRequest = addOnMigrationRequests.SingleOrDefault(n => n.LegacySubscriptionId.Equals(addOnMigrationResponse.CurrentSubscriptionId, StringComparison.OrdinalIgnoreCase));
if(addOnMigrationRequest != null)
{
addOnMigrationResponse.Status = newCommerceMigration.Status;
addOnMigrationResponse.Id = newCommerceMigration.Id;
PrepareMigrationResult(addOnMigrationRequest, batchId, addOnMigrationResponse, newCommerceMigrationError, migrationResults);
}
}
}
return migrationResults;

Просмотреть файл

@ -237,7 +237,7 @@ internal class SubscriptionProvider : ISubscriptionProvider
migrationResponse.EnsureSuccessStatusCode();
var newCommerceEligibility = await migrationResponse.Content.ReadFromJsonAsync<NewCommerceEligibility>().ConfigureAwait(false);
if (newCommerceEligibility.AddOnMigrations.Any())
if (newCommerceEligibility!.AddOnMigrations.Any())
{
addOnEligibilityList.Add(newCommerceEligibility.AddOnMigrations);
}
@ -279,6 +279,7 @@ internal class SubscriptionProvider : ISubscriptionProvider
LegacySubscriptionName = subscription.FriendlyName,
LegacyProductName = subscription.OfferName,
ExpirationDate = subscription.CommitmentEndDate,
AutoRenewEnabled = subscription.AutoRenewEnabled,
MigrationEligible = newCommerceEligibility.IsEligible,
NcePsa = newCommerceEligibility.CatalogItemId,
CurrentTerm = subscription.TermDuration,