@@ -1,5 +1,6 @@
|
||||
using Refit;
|
||||
using Models.Requests;
|
||||
using CvMatcher.Models.Responses;
|
||||
|
||||
namespace Api.Clients.Api.Contracts;
|
||||
|
||||
@@ -7,8 +8,8 @@ public interface ICvMatcherApi
|
||||
{
|
||||
[Multipart]
|
||||
[Post("/api/cv/upload")]
|
||||
Task<HttpResponseMessage> Upload([AliasAs("cv")] StreamPart cv, [AliasAs("gdprConsent")] bool gdprConsent);
|
||||
Task<CvUploadResponse> Upload([AliasAs("cv")] StreamPart cv, [AliasAs("gdprConsent")] bool gdprConsent);
|
||||
|
||||
[Post("/api/cv/match-job")]
|
||||
Task<HttpResponseMessage> MatchJob([Body] JobMatchRequest request);
|
||||
Task<JobMatchResponse> MatchJob([Body] JobMatchRequest request);
|
||||
}
|
||||
|
||||
@@ -70,8 +70,8 @@ public sealed class CvMatcherController : ControllerBase
|
||||
|
||||
var stream = cv.OpenReadStream();
|
||||
var part = new Refit.StreamPart(stream, cv.FileName, "application/pdf");
|
||||
using var response = await _cvApi.Upload(part, gdprConsent);
|
||||
return await ProxyResponseAsync(response, ct);
|
||||
var res = await _cvApi.Upload(part, gdprConsent);
|
||||
return Ok(res);
|
||||
}
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested)
|
||||
{
|
||||
@@ -114,9 +114,8 @@ public sealed class CvMatcherController : ControllerBase
|
||||
request.CvDocumentId,
|
||||
!string.IsNullOrWhiteSpace(request.JobUrl),
|
||||
!string.IsNullOrWhiteSpace(request.JobDescription));
|
||||
|
||||
using var response = await _cvApi.MatchJob(request);
|
||||
return await ProxyResponseAsync(response, ct);
|
||||
var res = await _cvApi.MatchJob(request);
|
||||
return Ok(res);
|
||||
}
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested)
|
||||
{
|
||||
@@ -129,15 +128,4 @@ public sealed class CvMatcherController : ControllerBase
|
||||
return StatusCode(StatusCodes.Status502BadGateway, new { error = "CV matcher API request failed." });
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<ContentResult> ProxyResponseAsync(HttpResponseMessage response, CancellationToken ct)
|
||||
{
|
||||
var body = await response.Content.ReadAsStringAsync(ct);
|
||||
return new ContentResult
|
||||
{
|
||||
StatusCode = (int)response.StatusCode,
|
||||
Content = body,
|
||||
ContentType = response.Content.Headers.ContentType?.ToString() ?? "application/json"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,5 +7,6 @@ namespace Api.Services.Contracts
|
||||
Task SendContactAsync(ContactRequest req, CancellationToken ct);
|
||||
Task SendSubscribeAsync(SubscribeRequest req, CancellationToken ct);
|
||||
Task SendFileDownloadNotificationAsync(string fileName, string? userIp, CancellationToken ct);
|
||||
Task SendMatchAsync(string? explicitTo, string subject, string body, CancellationToken ct);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,5 +166,10 @@ namespace Api.Services
|
||||
await client.SendAsync(message, ct);
|
||||
await client.DisconnectAsync(true, ct);
|
||||
}
|
||||
|
||||
public Task SendMatchAsync(string? explicitTo, string subject, string body, CancellationToken ct)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\api-models\api-models.csproj" />
|
||||
<ProjectReference Include="..\cv-matcher-api-models\cv-matcher-api-models.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user