diff --git a/src/OnePeek.Api/AppMetadataEndpoint.cs b/src/OnePeek.Api/AppMetadataEndpoint.cs
index 6433f36..516d930 100644
--- a/src/OnePeek.Api/AppMetadataEndpoint.cs
+++ b/src/OnePeek.Api/AppMetadataEndpoint.cs
@@ -23,7 +23,7 @@ namespace OnePeek.Api
///
public async Task GetMetadata(string appId, StoreType store, StoreCultureType storeCulture)
{
- if (storeCulture == StoreCultureType.Unknown)
+ if (storeCulture == StoreCultureType.Unknown || storeCulture == StoreCultureType.All)
{
throw new ArgumentException("Please provide a valid store culture");
}
@@ -70,6 +70,41 @@ namespace OnePeek.Api
+ ///
+ /// Get app rating (count + average) in the specified culture.
+ ///
+ /// The ID of the app. Can be found in the dev portal or the store URI.
+ /// The store where the app is published.
+ /// Culture of the query (returns location specific ratings).
+ ///
+ public async Task GetRating(string appId, StoreType store, StoreCultureType storeCulture)
+ {
+ if (storeCulture == StoreCultureType.Unknown || storeCulture == StoreCultureType.All)
+ {
+ throw new ArgumentException("Please provide a valid store culture");
+ }
+
+ string xml = await ApiHttpClient.Instance.Get(
+ EndpointUris.GetWindowsPhoneMetadataUri(appId, storeCulture.ToString())
+ );
+
+ IEnumerable xel = XDocument.Parse(xml).Elements().First().Descendants();
+
+ // create rating
+ AppRating result = new AppRating();
+ result.Culture = storeCulture;
+ result.RatingCount = Convert.ToInt32(xel.Get("userRatingCount"));
+ result.AverageRating = xel.GetFloat("averageUserRating");
+ if (Configuration.UseFiveStarSystem)
+ {
+ result.AverageRating = (float)(result.AverageRating * 0.5);
+ }
+
+ return result;
+ }
+
+
+
///
/// Creates an URI from an image urn (included in the AppImage POCO).
///
@@ -101,7 +136,9 @@ namespace OnePeek.Api
public async Task> GetMetadataForAllCultures(string appId, StoreType store, CancellationToken ct, IProgress progress)
{
- IEnumerable cultures = Enum.GetValues(typeof(StoreCultureType)).Cast();
+ IEnumerable cultures = Enum.GetValues(typeof(StoreCultureType))
+ .Cast()
+ .Where(x => x != StoreCultureType.All && x != StoreCultureType.Unknown);
IEnumerable> tasks = cultures.Select(culture =>
{
@@ -110,6 +147,21 @@ namespace OnePeek.Api
return await Task.WhenAll(tasks).ConfigureAwait(false);
}
+
+
+ public async Task> GetRatingsForAllCultures(string appId, StoreType store, CancellationToken ct, IProgress progress)
+ {
+ IEnumerable cultures = Enum.GetValues(typeof(StoreCultureType))
+ .Cast()
+ .Where(x => x != StoreCultureType.All && x != StoreCultureType.Unknown);
+
+ IEnumerable> tasks = cultures.Select(culture =>
+ {
+ return GetRating(appId, store, culture);
+ });
+
+ return await Task.WhenAll(tasks).ConfigureAwait(false);
+ }
}
diff --git a/src/OnePeek.Api/AppRatingEndpoint.cs b/src/OnePeek.Api/AppRatingEndpoint.cs
index 777752e..4b4c5bf 100644
--- a/src/OnePeek.Api/AppRatingEndpoint.cs
+++ b/src/OnePeek.Api/AppRatingEndpoint.cs
@@ -20,7 +20,7 @@ namespace OnePeek.Api
///
public async Task GetReviews(string appId, StoreType store, StoreCultureType storeCulture, StoreReviewSorting sorting, string prevPageMarkerId = null, string nextPageMarkerId = null)
{
- if (storeCulture == StoreCultureType.Unknown)
+ if (storeCulture == StoreCultureType.Unknown || storeCulture == StoreCultureType.All)
{
throw new ArgumentException("Please provide a valid store culture");
}
diff --git a/src/OnePeek.Entities/AppRating.cs b/src/OnePeek.Entities/AppRating.cs
index 7082c33..62a89d3 100644
--- a/src/OnePeek.Entities/AppRating.cs
+++ b/src/OnePeek.Entities/AppRating.cs
@@ -5,6 +5,11 @@ namespace OnePeek.Entities
[XmlRoot("feed")]
public partial class AppRating
{
+ ///
+ /// Defines the culture where the rating applies to.
+ ///
+ public StoreCultureType Culture { get; set; }
+
///
/// Average rating of the app from 1-10 (can be changed to 1-5 with Configuration.UseFiveStarSystem).
/// Is dependent on the current culture.
diff --git a/src/OnePeek.Entities/StoreCultureType.cs b/src/OnePeek.Entities/StoreCultureType.cs
index 0f27a7a..2abcb29 100644
--- a/src/OnePeek.Entities/StoreCultureType.cs
+++ b/src/OnePeek.Entities/StoreCultureType.cs
@@ -9,6 +9,10 @@ namespace OnePeek.Entities
///
Unknown,
///
+ /// Summary of all cultures. Is only used by OnePeek, not by Microsoft
+ ///
+ All,
+ ///
/// Angola (Português - Portugal)
///
[Display(Name = "Angola (Português - Portugal)")]