Files
baya-monorepo/server/src/API/Baya.Web.Api/Controllers/V1/RefundsController.cs
T
2026-07-13 11:26:39 +03:30

34 lines
1.5 KiB
C#

using System.ComponentModel.DataAnnotations;
using Asp.Versioning;
using Baya.Application.Features.Refunds.Queries.GetRefundByBooking;
using Baya.Application.Features.Refunds.Queries.GetRefundStatus;
using Baya.Application.Models.Refunds;
using Baya.WebFramework.Attributes;
using Baya.WebFramework.BaseController;
using Mediator;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Baya.Web.Api.Controllers.V1;
/// <summary>The customer-facing refund status — the only customer-visible refund surface (there is no
/// self-service refund initiation). Tenancy-scoped: a customer sees only their own refund.</summary>
[ApiVersion("1")]
[ApiController]
[Route("api/v{version:apiVersion}/refunds")]
[Authorize]
[Display(Description = "Customer refund status")]
public sealed class RefundsController(ISender sender) : BaseController
{
[HttpGet("{id}/status")]
[ProducesOkApiResponseType<RefundStatusDto>]
public async Task<IActionResult> Status(long id, CancellationToken cancellationToken)
=> OperationResult(await sender.Send(new GetRefundStatusQuery(id), cancellationToken));
// Reach the refund from its booking id (the id the customer holds) — 404 when none exists (REQ-021).
[HttpGet("by_booking/{bookingId}")]
[ProducesOkApiResponseType<RefundStatusDto>]
public async Task<IActionResult> ByBooking(long bookingId, CancellationToken cancellationToken)
=> OperationResult(await sender.Send(new GetRefundByBookingQuery(bookingId), cancellationToken));
}