start reviews endpoint
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using Bender;
|
||||
using OnePeek.Api.Extensions;
|
||||
using OnePeek.Entities;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using System.Linq;
|
||||
|
||||
namespace OnePeek.Api
|
||||
{
|
||||
public class AppRatingEndpoint : ApiBase
|
||||
{
|
||||
public async Task<AppReviews> GetReviews(string appId, StoreType store, StoreCultureType storeCulture, StoreReviewSorting sorting)
|
||||
{
|
||||
if (storeCulture == StoreCultureType.Unknown)
|
||||
{
|
||||
throw new ArgumentException("Please provide a valid store culture");
|
||||
}
|
||||
|
||||
string xml = await ApiHttpClient.Instance.Get(
|
||||
EndpointUris.GetWindowsPhoneReviewsUri(appId, storeCulture.ToString(), sorting.ToString())
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
//string entryXml = XDocument.Parse(xml).Descendants().FirstOrDefault(x => x.Name.LocalName == "entry").ToString();
|
||||
|
||||
AppReviews result = Deserialize.Xml<AppReviews>(xml);
|
||||
result.Id = appId;
|
||||
result.StoreType = store;
|
||||
result.StoreCultureType = storeCulture;
|
||||
result.Sorting = sorting;
|
||||
return result;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Debug.WriteLine(exc.Message);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ namespace OnePeek.Api
|
||||
|
||||
public const string WINDOWSPHONE_METADATA_URI = "http://marketplaceedgeservice.windowsphone.com/v9/catalog/apps/{0}?os=8.10.14219.0&cc={1}&lang={2}";
|
||||
|
||||
public const string WINDOWSPHONE_REVIEWS_URI = "http://marketplaceedgeservice.windowsphone.com/v9/ratings/product/{0}/reviews?os=8.10.14219.0&cc={1}&lang={2}&dm=RM-1045_1012&chunksize=20&skuId=c1424839-be1e-40eb-8bc3-b2730db30b62&orderBy={3}";
|
||||
|
||||
|
||||
|
||||
internal static Uri GetWindowsPhoneMetadataUri(string appId, string culture)
|
||||
@@ -26,6 +28,15 @@ namespace OnePeek.Api
|
||||
|
||||
|
||||
|
||||
internal static Uri GetWindowsPhoneReviewsUri(string appId, string culture, string orderBy)
|
||||
{
|
||||
culture = culture.Replace('_', '-');
|
||||
string country = culture.Split('-')[1];
|
||||
return Uri(WINDOWSPHONE_REVIEWS_URI, appId, country, culture, orderBy);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static Uri Uri(string template, params string[] replacements)
|
||||
{
|
||||
string uriString = String.Format(template, replacements).ToLower();
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace OnePeek.Entities
|
||||
{
|
||||
public class AppReviews
|
||||
{
|
||||
public string Id { get; set; }
|
||||
|
||||
[XmlElement("updated")]
|
||||
public DateTime? StoreDataModifiedDate { get; set; }
|
||||
|
||||
public StoreType StoreType { get; set; }
|
||||
|
||||
public StoreCultureType StoreCultureType { get; set; }
|
||||
|
||||
public StoreReviewSorting Sorting { get; set; }
|
||||
|
||||
public string PrevPageMarkerId { get; set; }
|
||||
|
||||
public string NextPageMarkerId { get; set; }
|
||||
|
||||
public List<AppReview> Reviews { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class AppReview
|
||||
{
|
||||
public DateTime CreatedDate { get; set; }
|
||||
|
||||
public string Author { get; set; }
|
||||
|
||||
public string Text { get; set; }
|
||||
|
||||
public float Rating { get; set; }
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
public string Device { get; set; }
|
||||
|
||||
public string AppVersion { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnePeek.Entities
|
||||
{
|
||||
public enum StoreReviewSorting
|
||||
{
|
||||
Latest,
|
||||
MostHelpful,
|
||||
Lowest,
|
||||
Highest
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user