-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: #869: Add new debug endpoint for Atlas donor store to test don…
…or import.
- Loading branch information
Showing
3 changed files
with
51,040 additions
and
56,999 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
Atlas.DonorImport.Functions/Functions/Debug/DonorFunctions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System.Collections.Generic; | ||
using Atlas.Common.Utils.Http; | ||
using Atlas.DonorImport.ExternalInterface; | ||
using AzureFunctions.Extensions.Swashbuckle.Attribute; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Azure.WebJobs; | ||
using Microsoft.Azure.WebJobs.Extensions.Http; | ||
using Newtonsoft.Json; | ||
using System.IO; | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
using Atlas.DonorImport.ExternalInterface.Models; | ||
|
||
namespace Atlas.DonorImport.Functions.Functions.Debug | ||
{ | ||
public class DonorFunctions | ||
{ | ||
private readonly IDonorReader donorReader; | ||
|
||
public DonorFunctions(IDonorReader donorReader) | ||
{ | ||
this.donorReader = donorReader; | ||
} | ||
|
||
[FunctionName(nameof(GetDonors))] | ||
[ProducesResponseType(typeof(IEnumerable<Donor>), (int)HttpStatusCode.OK)] | ||
public async Task<IActionResult> GetDonors( | ||
[HttpTrigger(AuthorizationLevel.Function, "post", Route = $"{RouteConstants.DebugRoutePrefix}/donors")] | ||
[RequestBodyType(typeof(string[]), "Donor Record Ids")] | ||
HttpRequest request) | ||
{ | ||
var recordIds = JsonConvert.DeserializeObject<string[]>(await new StreamReader(request.Body).ReadToEndAsync()); | ||
|
||
var donors = await donorReader.GetDonorsByExternalDonorCodes(recordIds); | ||
|
||
return new JsonResult(donors.Values); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.