2017-08-19 07:59:19 -04:00
|
|
|
|
using System;
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using Bit.Core.Models.Api;
|
2019-02-21 22:43:37 -05:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Bit.Core.Utilities;
|
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
2019-02-22 08:08:48 -05:00
|
|
|
|
using Bit.Core;
|
2017-08-19 07:59:19 -04:00
|
|
|
|
|
|
|
|
|
|
namespace Bit.Api.Controllers
|
|
|
|
|
|
{
|
|
|
|
|
|
public class MiscController : Controller
|
|
|
|
|
|
{
|
2019-02-21 22:43:37 -05:00
|
|
|
|
private readonly BitPayClient _bitPayClient;
|
2019-02-22 08:08:48 -05:00
|
|
|
|
private readonly GlobalSettings _globalSettings;
|
2019-02-21 22:43:37 -05:00
|
|
|
|
|
2019-02-22 08:08:48 -05:00
|
|
|
|
public MiscController(BitPayClient bitPayClient,
|
|
|
|
|
|
GlobalSettings globalSettings)
|
2019-02-21 22:43:37 -05:00
|
|
|
|
{
|
|
|
|
|
|
_bitPayClient = bitPayClient;
|
2019-02-22 08:08:48 -05:00
|
|
|
|
_globalSettings = globalSettings;
|
2019-02-21 22:43:37 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-08-19 07:59:19 -04:00
|
|
|
|
[HttpGet("~/alive")]
|
2017-10-06 15:30:54 -04:00
|
|
|
|
[HttpGet("~/now")]
|
2017-08-19 07:59:19 -04:00
|
|
|
|
public DateTime Get()
|
|
|
|
|
|
{
|
|
|
|
|
|
return DateTime.UtcNow;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[HttpGet("~/version")]
|
|
|
|
|
|
public VersionResponseModel Version()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new VersionResponseModel();
|
|
|
|
|
|
}
|
2018-05-21 21:18:19 -04:00
|
|
|
|
|
|
|
|
|
|
[HttpGet("~/ip")]
|
|
|
|
|
|
public JsonResult Ip()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new JsonResult(new
|
|
|
|
|
|
{
|
|
|
|
|
|
Ip = HttpContext.Connection?.RemoteIpAddress?.ToString(),
|
|
|
|
|
|
Headers = HttpContext.Request?.Headers,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2019-02-21 22:43:37 -05:00
|
|
|
|
|
|
|
|
|
|
[Authorize("Application")]
|
|
|
|
|
|
[HttpPost("~/bitpay-invoice")]
|
|
|
|
|
|
[SelfHosted(NotSelfHostedOnly = true)]
|
|
|
|
|
|
public async Task<string> PostBitPayInvoice([FromBody]BitPayInvoiceRequestModel model)
|
|
|
|
|
|
{
|
2019-02-22 08:08:48 -05:00
|
|
|
|
var invoice = await _bitPayClient.CreateInvoiceAsync(model.ToBitpayClientInvoice(_globalSettings));
|
2019-02-21 22:43:37 -05:00
|
|
|
|
return invoice.Url;
|
|
|
|
|
|
}
|
2017-08-19 07:59:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|