renew operation and termunit changes

This commit is contained in:
Santhosh Bomma 2023-03-20 20:42:02 -07:00
Родитель 142a1577d7
Коммит 59988a9267
4 изменённых файлов: 21 добавлений и 3 удалений

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

@ -18,6 +18,7 @@ namespace Microsoft.Marketplace.SaaS.Models
OperationActionEnum.ChangeQuantity => "ChangeQuantity",
OperationActionEnum.Suspend => "Suspend",
OperationActionEnum.Reinstate => "Reinstate",
OperationActionEnum.Renew => "Renew",
_ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown OperationActionEnum value.")
};
@ -28,6 +29,7 @@ namespace Microsoft.Marketplace.SaaS.Models
if (string.Equals(value, "ChangeQuantity", StringComparison.InvariantCultureIgnoreCase)) return OperationActionEnum.ChangeQuantity;
if (string.Equals(value, "Suspend", StringComparison.InvariantCultureIgnoreCase)) return OperationActionEnum.Suspend;
if (string.Equals(value, "Reinstate", StringComparison.InvariantCultureIgnoreCase)) return OperationActionEnum.Reinstate;
if (string.Equals(value, "Renew", StringComparison.InvariantCultureIgnoreCase)) return OperationActionEnum.Renew;
throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown OperationActionEnum value.");
}
}

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

@ -19,6 +19,8 @@ namespace Microsoft.Marketplace.SaaS.Models
/// <summary> Suspend. </summary>
Suspend,
/// <summary> Reinstate. </summary>
Reinstate
Reinstate,
/// <summary> Renew. </summary>
Renew
}
}

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

@ -15,10 +15,21 @@ namespace Microsoft.Marketplace.SaaS.Models
{
internal static SubscriptionTerm DeserializeSubscriptionTerm(JsonElement element)
{
Optional<TermUnitEnum> termUnit = default;
Optional<DateTimeOffset> startDate = default;
Optional<DateTimeOffset> endDate = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("termUnit"))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
property.ThrowNonNullablePropertyIsNull();
continue;
}
termUnit = property.Value.GetString().ToTermUnitEnum();
continue;
}
if (property.NameEquals("startDate"))
{
if (property.Value.ValueKind == JsonValueKind.Null)
@ -40,7 +51,7 @@ namespace Microsoft.Marketplace.SaaS.Models
continue;
}
}
return new SubscriptionTerm(Optional.ToNullable(startDate), Optional.ToNullable(endDate));
return new SubscriptionTerm(Optional.ToNullable(termUnit), Optional.ToNullable(startDate), Optional.ToNullable(endDate));
}
}
}

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

@ -18,14 +18,17 @@ namespace Microsoft.Marketplace.SaaS.Models
}
/// <summary> Initializes a new instance of SubscriptionTerm. </summary>
/// <param name="termUnit"> . </param>
/// <param name="startDate"> . </param>
/// <param name="endDate"> . </param>
internal SubscriptionTerm(DateTimeOffset? startDate, DateTimeOffset? endDate)
internal SubscriptionTerm(TermUnitEnum? termUnit, DateTimeOffset? startDate, DateTimeOffset? endDate)
{
TermUnit = termUnit;
StartDate = startDate;
EndDate = endDate;
}
public TermUnitEnum? TermUnit { get; }
public DateTimeOffset? StartDate { get; }
public DateTimeOffset? EndDate { get; }
}