Add basic Greenfield API Get and Delete operations for apps (#3894)

* Add basic Greenfield API Get and Delete operations for apps

Will follow-up with PATCH and also with GET which returns more than just basic data later. This sets up the basic stuff first.

* Add methods to LocalBTCPayServerClient
This commit is contained in:
Umar Bolatov
2022-06-26 18:14:16 -07:00
committed by GitHub
parent 61c6a2ab57
commit 95b9e4dfd9
5 changed files with 173 additions and 5 deletions

View File

@@ -86,6 +86,38 @@ namespace BTCPayServer.Controllers.Greenfield
return Ok(ToModel(appData));
}
[HttpGet("~/api/v1/apps/{appId}")]
[Authorize(Policy = Policies.CanModifyStoreSettings, AuthenticationSchemes = AuthenticationSchemes.Greenfield)]
public async Task<IActionResult> GetApp(string appId)
{
var app = await _appService.GetApp(appId, AppType.PointOfSale);
if (app == null)
{
return AppNotFound();
}
return Ok(ToModel(app));
}
[HttpDelete("~/api/v1/apps/{appId}")]
public async Task<IActionResult> DeleteApp(string appId)
{
var app = await _appService.GetApp(appId, null);
if (app == null)
{
return AppNotFound();
}
await _appService.DeleteApp(app);
return Ok();
}
private IActionResult AppNotFound()
{
return this.CreateAPIError(404, "app-not-found", "The app with specified ID was not found");
}
private PointOfSaleAppData ToModel(AppData appData)
{
return new PointOfSaleAppData