2019-07-17 13:45:36 +02:00
|
|
|
using System.Threading.Tasks;
|
2020-02-12 15:16:19 +01:00
|
|
|
|
2019-07-17 13:45:36 +02:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
2019-12-28 15:52:59 +01:00
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
2020-02-12 15:16:19 +01:00
|
|
|
using PluralKit.Core;
|
|
|
|
|
|
|
|
namespace PluralKit.API
|
2019-07-17 13:45:36 +02:00
|
|
|
{
|
|
|
|
[ApiController]
|
2020-05-07 04:39:49 +02:00
|
|
|
[ApiVersion("1.0")]
|
|
|
|
[Route( "v{version:apiVersion}/a" )]
|
2019-07-17 13:45:36 +02:00
|
|
|
public class AccountController: ControllerBase
|
|
|
|
{
|
2019-10-26 19:45:30 +02:00
|
|
|
private IDataStore _data;
|
2019-07-17 13:45:36 +02:00
|
|
|
|
2020-06-16 01:15:59 +02:00
|
|
|
public AccountController(IDataStore data)
|
2019-07-17 13:45:36 +02:00
|
|
|
{
|
2019-10-26 19:45:30 +02:00
|
|
|
_data = data;
|
2019-07-17 13:45:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[HttpGet("{aid}")]
|
2019-12-28 15:52:59 +01:00
|
|
|
public async Task<ActionResult<JObject>> GetSystemByAccount(ulong aid)
|
2019-07-17 13:45:36 +02:00
|
|
|
{
|
2019-10-26 19:45:30 +02:00
|
|
|
var system = await _data.GetSystemByAccount(aid);
|
2019-07-17 13:45:36 +02:00
|
|
|
if (system == null) return NotFound("Account not found.");
|
|
|
|
|
2020-06-16 01:15:59 +02:00
|
|
|
return Ok(system.ToJson(User.ContextFor(system)));
|
2019-07-17 13:45:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|