2018-04-18 16:46:53 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using RestEase;
|
|
|
|
|
|
|
|
|
|
namespace IW4MAdmin.Application.API.Master
|
|
|
|
|
{
|
|
|
|
|
public class AuthenticationId
|
2018-05-20 22:35:56 -04:00
|
|
|
|
{
|
2018-04-18 16:46:53 -04:00
|
|
|
|
[JsonProperty("id")]
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class TokenId
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty("access_token")]
|
|
|
|
|
public string AccessToken { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-19 01:48:14 -04:00
|
|
|
|
public class VersionInfo
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty("current-version-stable")]
|
|
|
|
|
public float CurrentVersionStable { get; set; }
|
|
|
|
|
[JsonProperty("current-version-prerelease")]
|
|
|
|
|
public float CurrentVersionPrerelease { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class ResultMessage
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty("message")]
|
|
|
|
|
public string Message { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Endpoint
|
|
|
|
|
{
|
|
|
|
|
#if !DEBUG
|
2018-08-03 22:11:58 -04:00
|
|
|
|
private static readonly IMasterApi api = RestClient.For<IMasterApi>("http://api.raidmax.org:5000");
|
2018-04-19 01:48:14 -04:00
|
|
|
|
#else
|
|
|
|
|
private static IMasterApi api = RestClient.For<IMasterApi>("http://127.0.0.1");
|
|
|
|
|
#endif
|
|
|
|
|
public static IMasterApi Get() => api;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-18 16:46:53 -04:00
|
|
|
|
[Header("User-Agent", "IW4MAdmin-RestEase")]
|
|
|
|
|
public interface IMasterApi
|
|
|
|
|
{
|
|
|
|
|
[Header("Authorization")]
|
|
|
|
|
string AuthorizationToken { get; set; }
|
|
|
|
|
|
|
|
|
|
[Post("authenticate")]
|
|
|
|
|
Task<TokenId> Authenticate([Body] AuthenticationId Id);
|
|
|
|
|
|
|
|
|
|
[Post("instance/")]
|
2018-04-19 01:48:14 -04:00
|
|
|
|
Task<ResultMessage> AddInstance([Body] ApiInstance instance);
|
2018-04-18 16:46:53 -04:00
|
|
|
|
|
|
|
|
|
[Put("instance/{id}")]
|
2018-04-19 01:48:14 -04:00
|
|
|
|
Task<ResultMessage> UpdateInstance([Path] string id, [Body] ApiInstance instance);
|
|
|
|
|
|
|
|
|
|
[Get("version")]
|
|
|
|
|
Task<VersionInfo> GetVersion();
|
2018-05-08 00:58:46 -04:00
|
|
|
|
|
|
|
|
|
[Get("localization")]
|
2018-05-20 22:35:56 -04:00
|
|
|
|
Task<List<SharedLibraryCore.Localization.Layout>> GetLocalization();
|
|
|
|
|
|
|
|
|
|
[Get("localization/{languageTag}")]
|
|
|
|
|
Task<SharedLibraryCore.Localization.Layout> GetLocalization([Path("languageTag")] string languageTag);
|
2018-04-18 16:46:53 -04:00
|
|
|
|
}
|
|
|
|
|
}
|