using Common.Constant;
using Microsoft.AspNetCore.Mvc;
using SicboSub.Api.Business;
using SicboSub.Api.DTO;

namespace SicboSub.Api.Controllers
{
    [ApiController]
    public class SubscriptionController : Controller
    {
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(
            typeof(SubscriptionController)
        );

        ISubscriptionBusiness subscriptionBusiness;

        public SubscriptionController(ISubscriptionBusiness subscriptionBusiness)
        {
            this.subscriptionBusiness = subscriptionBusiness;
        }

        /// <summary>
        /// Register package
        /// POST /apis/package/register
        /// </summary>
        [HttpPost]
        [Route(ApiUrlConstant.RegisterUrl)]
        public async Task<IActionResult> Register([FromBody] RegisterReq request)
        {
            return await subscriptionBusiness.Register(HttpContext.Request, request);
        }

        /// <summary>
        /// Buy more package
        /// POST /apis/package/buymore
        /// </summary>
        [HttpPost]
        [Route(ApiUrlConstant.BuyMoreUrl)]
        public async Task<IActionResult> BuyMore([FromBody] BuyMoreReq request)
        {
            return await subscriptionBusiness.BuyMore(HttpContext.Request, request);
        }
    }
}
