PluralKit/PluralKit.API/Controllers/v2/SystemControllerV2.cs
spiral e2a56a198f
feat(apiv2): GET endpoints except guilds
- ResolveT methods in ControllerBase
- ContextFor methods in ControllerBase
2021-10-12 05:17:54 -04:00

36 lines
962 B
C#

using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using PluralKit.Core;
namespace PluralKit.API
{
[ApiController]
[ApiVersion("2.0")]
[Route("v{version:apiVersion}/systems")]
public class SystemControllerV2: PKControllerBase
{
public SystemControllerV2(IServiceProvider svc) : base(svc) { }
[HttpGet("{systemRef}")]
public async Task<IActionResult> SystemGet(string systemRef)
{
var system = await ResolveSystem(systemRef);
if (system == null) return NotFound();
else return Ok(system.ToJson(this.ContextFor(system), v: APIVersion.V2));
}
[HttpPatch("{system}")]
public async Task<IActionResult> SystemPatch(string system, [FromBody] JObject data)
{
return new ObjectResult("Unimplemented")
{
StatusCode = 501
};
}
}
}