using API.Contracts.Profiles.Responses; using Microsoft.AspNetCore.Mvc; using RecNet.Application.Profiles; using LoginRequest = API.Contracts.Profiles.Requests.LoginRequest; namespace API.Controllers.Profiles.V1; [Route("api/[controller]/v1")] [ApiController] public class ProfilesController(IProfileService profileService) : ControllerBase { [HttpGet("{id:guid}")] public async Task> GetProfile( Guid id, CancellationToken ct) { var profile = await profileService.GetProfileAsync(id, ct); if (profile == null) return NotFound(); return profile; } [HttpGet("bulk")] public async Task> GetBulkProfiles( [FromQuery(Name = "id")] List ids, CancellationToken ct) => await profileService.GetProfilesAsync(ids, ct); [HttpPost("login")] public async Task> Login( [FromBody] LoginRequest request, CancellationToken ct) { var result = await profileService.LoginAsync( new LoginProfileCommand( request.AppVersion, request.DeviceId, request.PlatformType, request.PlatformId, request.PlatformAuthentication ), ct); if (!result.Succeeded) return BadRequest(result.Message); return new LoginResponse { Profile = result.Profile!, AccessToken = result.AccessToken!, ExpiresIn = result.ExpiresIn }; } }