46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using uPromise;
|
|
|
|
namespace Online
|
|
{
|
|
public class UgcService
|
|
{
|
|
private readonly IHttpEngine httpEngine;
|
|
|
|
public UgcService(IHttpEngine httpEngine)
|
|
{
|
|
this.httpEngine = httpEngine;
|
|
}
|
|
|
|
public Promise Like(string ugcId)
|
|
{
|
|
return ModifyUgcProperty(ugcId, HttpMethod.Put, "like");
|
|
}
|
|
|
|
public Promise Unlike(string ugcId)
|
|
{
|
|
return ModifyUgcProperty(ugcId, HttpMethod.Delete, "like");
|
|
}
|
|
|
|
public Promise Report(string ugcId)
|
|
{
|
|
return ModifyUgcProperty(ugcId, HttpMethod.Post, "reports");
|
|
}
|
|
|
|
public Promise View(string ugcId)
|
|
{
|
|
return ModifyUgcProperty(ugcId, HttpMethod.Post, "views");
|
|
}
|
|
|
|
private Promise ModifyUgcProperty(string ugcId, HttpMethod method, string property)
|
|
{
|
|
return OnlineEngine.Session.Refresh()
|
|
.Then(session =>
|
|
{
|
|
var request = session.JmcsFacade.BuildRequest("ugc", 2, "/ugcs/" + ugcId + "/" + property);
|
|
request.Method = method;
|
|
|
|
return httpEngine.Execute(request);
|
|
});
|
|
}
|
|
}
|
|
}
|