diff --git a/CHANGELOG.md b/CHANGELOG.md index ef17f66..fc57abc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Added + +- StarsFive, StarsFour, StarsThree, StarsTwo, StarsOne to the RatingResponse +- ## [3.17.0] - 2025-01-29 diff --git a/dotnet/Controllers/RoutesController.cs b/dotnet/Controllers/RoutesController.cs index 630afa9..74d9e8d 100644 --- a/dotnet/Controllers/RoutesController.cs +++ b/dotnet/Controllers/RoutesController.cs @@ -299,6 +299,11 @@ public async Task ProcessReviewApiAction(string requestedAction, RatingResponse ratingResponse = new RatingResponse { Average = average.Average, + StarsFive = average.StarsFive, + StarsFour = average.StarsFour, + StarsThree = average.StarsThree, + StarsTwo = average.StarsTwo, + StarsOne = average.StarsOne, TotalCount = wrapper.Range.Total }; diff --git a/dotnet/Models/RatingResponse.cs b/dotnet/Models/RatingResponse.cs index fecb9cf..f7db326 100644 --- a/dotnet/Models/RatingResponse.cs +++ b/dotnet/Models/RatingResponse.cs @@ -10,6 +10,21 @@ public class RatingResponse [JsonProperty("average")] public decimal Average { get; set; } + [JsonProperty("starsFive")] + public int StarsFive { get; set; } + + [JsonProperty("starsFour")] + public int StarsFour { get; set; } + + [JsonProperty("starsThree")] + public int StarsThree { get; set; } + + [JsonProperty("starsTwo")] + public int StarsTwo { get; set; } + + [JsonProperty("starsOne")] + public int StarsOne { get; set; } + [JsonProperty("totalCount")] public long TotalCount { get; set; } } diff --git a/dotnet/Services/ProductReviewService.cs b/dotnet/Services/ProductReviewService.cs index 3104560..5582528 100644 --- a/dotnet/Services/ProductReviewService.cs +++ b/dotnet/Services/ProductReviewService.cs @@ -162,7 +162,7 @@ public async Task GetAverageRatingByProductId(string productId) } - AverageCount avergae = new AverageCount + AverageCount average = new AverageCount { Average = decimal.Round(averageRating, 2, MidpointRounding.AwayFromZero), StarsFive = stars5, @@ -172,7 +172,7 @@ public async Task GetAverageRatingByProductId(string productId) StarsOne = stars1, Total = numberOfReviews }; - return avergae; + return average; } public async Task GetReview(string Id)