feat(apiv2): delete endpoints

This commit is contained in:
spiral
2021-10-12 06:41:38 -04:00
parent c164fad2ac
commit 0aefafb62d
4 changed files with 41 additions and 22 deletions

View File

@@ -131,13 +131,20 @@ namespace PluralKit.API
};
}
[HttpDelete("systems/{system}/switches/{switch_id}")]
public async Task<IActionResult> SwitchDelete(string system, string switch_id)
[HttpDelete("systems/@me/switches/{switchRef}")]
public async Task<IActionResult> SwitchDelete(string switchRef)
{
return new ObjectResult("Unimplemented")
{
StatusCode = 501
};
if (!Guid.TryParse(switchRef, out var switchId))
throw APIErrors.SwitchNotFound;
var system = await ResolveSystem("@me");
var sw = await _repo.GetSwitchByUuid(switchId);
if (sw == null || system.Id != sw.System)
throw APIErrors.SwitchNotFound;
await _repo.DeleteSwitch(sw.Id);
return NoContent();
}
}