first commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user