Skip to content

Commit

Permalink
utcTimestamp has been added to balance movement create api
Browse files Browse the repository at this point in the history
  • Loading branch information
mElzantot committed Sep 26, 2024
1 parent 92d9079 commit 14f94a2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/Balance/SubsBase.SDK.Balance.Test/BalanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,36 @@ public void Step_18_GetAllBalanceMovements_ShouldGetAlBalanceMovements()
balance.Value.TotalRecords.Should();
balance.Value.Data.FirstOrDefault().NetBalance.Should().BePositive();
}


[Test, Order(19)]
public void Step_19_AddBalanceMovementWithInvalidTimestamp_ShouldNotAddMovement()
{
var balance = balanceSdk.BalanceMovement.CreateAsync(new BalanceMovementNew()
{
BalanceId = _1StBalanceId,
Type = MovementType.Credit,
Amount = 1000,
Description = "Load Balance With timestamp - 1000 EGP",
UtcTimestamp = DateTime.UtcNow.AddDays(-1)
}).GetAwaiter().GetResult();

balance.IsFailed.Should().BeTrue();
balance.Value.Should().BeNull();
}

[Test, Order(20)]
public void Step_20_AddBalanceMovementWithFutureTimestamp_ShouldNotAddMovement()
{
var balance = balanceSdk.BalanceMovement.CreateAsync(new BalanceMovementNew()
{
BalanceId = _1StBalanceId,
Type = MovementType.Credit,
Amount = 1000,
Description = "Load Balance With timestamp - 1000 EGP",
UtcTimestamp = DateTime.UtcNow.AddDays(1)
}).GetAwaiter().GetResult();

balance.IsFailed.Should().BeTrue();
balance.Value.Should().BeNull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public BalanceMovementClient(ApiClient apiClient, BalanceConfiguration balanceCo
{ "balanceId", balanceMovementNew.BalanceId.ToString() },
{ "description", balanceMovementNew.Description },
{ "expirationDate", balanceMovementNew.ExpirationDate ?? null},
{ "utcTimestamp", balanceMovementNew.UtcTimestamp ?? null},
{ "type", balanceMovementNew.Type.ToString() }
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class BalanceDetails
public class BalanceMovement
{
[JsonPropertyName("utcTimestamp")] public DateTime UtcTimestamp { get; set; }
[JsonPropertyName("createdAtUtc")] public DateTime CreatedAtUtc { get; set; }
[JsonPropertyName("amount")] public decimal Amount { get; set; }
[JsonPropertyName("netBalance")] public decimal NetBalance { get; set; }
[JsonPropertyName("description")] public string Description { get; set; } = string.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class BalanceMovementNew
[JsonPropertyName("type")] [JsonConverter(typeof(JsonStringEnumConverter))] public MovementType Type { get; set; }
[JsonPropertyName("amount")] public decimal Amount { get; set; }
[JsonPropertyName("expirationDate") ] public DateTime? ExpirationDate { get; set; }
[JsonPropertyName("utcTimestamp") ] public DateTime? UtcTimestamp { get; set; }
[JsonPropertyName("description")] public string Description { get; set; } = string.Empty;
}

Expand Down

0 comments on commit 14f94a2

Please sign in to comment.