Files
Core_Be/Controllers/SubscriptionRenewalApprovalController.cs
T
Dhananjaya99 bffc9b1686 first commit
2026-09-28 11:44:26 +05:30

40 lines
1.8 KiB
C#

using Fitness_core_BE.Helpers;
using Fitness_core_BE.Interfaces.Services;
using Fitness_core_BE.Models.IOs;
using Microsoft.AspNetCore.Mvc;
using static Fitness_core_BE.Helpers.JwtMiddleware;
using static Fitness_core_BE.Helpers.ApiResponseHelper;
namespace Fitness_core_BE.Controllers
{
public record ChangeRenewalPlanRequest(Guid NewCustomerPlanId);
// Staff-facing approval queue for the unapproved (IsActive=false) invoices the daily
// SubscriptionRenewalJob sweep creates. See ISubscriptionRenewalApprovalService.
[ApiController]
[Route("api/client/renewal-approvals")]
[CustomMiddleware]
[TenantResolution]
[RequiresPermission("customer-payments")]
public class SubscriptionRenewalApprovalController(ISubscriptionRenewalApprovalService approvalService) : ControllerBase
{
private readonly ISubscriptionRenewalApprovalService _approvalService = approvalService;
[HttpGet]
public async Task<ActionResult<ApiResponse<object>>> GetUnapprovedInvoices()
=> Response(await _approvalService.GetUnapprovedInvoicesAsync(HttpContext));
[HttpPost("{invoiceId:guid}/approve")]
public async Task<ActionResult<ApiResponse<object>>> Approve(Guid invoiceId)
=> Response(await _approvalService.ApproveAsync(invoiceId, HttpContext));
[HttpPost("{invoiceId:guid}/change-plan")]
public async Task<ActionResult<ApiResponse<object>>> ChangePlan(Guid invoiceId, [FromBody] ChangeRenewalPlanRequest request)
=> Response(await _approvalService.ChangePlanAsync(invoiceId, request.NewCustomerPlanId, HttpContext));
[HttpPost("{invoiceId:guid}/reject")]
public async Task<ActionResult<ApiResponse<object>>> Reject(Guid invoiceId)
=> Response(await _approvalService.RejectAsync(invoiceId, HttpContext));
}
}