Skip to content

Commit

Permalink
elaborate a todo
Browse files Browse the repository at this point in the history
  • Loading branch information
civsiv committed Apr 4, 2024
1 parent 08a807e commit 5948b2f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions OpenActive.Server.NET/CustomBookingEngine/CustomBookingEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ private Guid ConvertToGuid(string uuidString)
if (Guid.TryParse(uuidString, out Guid result))
{
return result;
} else
}
else
{
throw new OpenBookingException(new OpenBookingError(), "Invalid format for Order UUID");
}
Expand Down Expand Up @@ -423,7 +424,7 @@ public async Task<ResponseContent> ProcessOrderCreationB(string clientId, Uri se
{
// Attempt to use idempotency cache if it exists
var cachedResponse = await GetResponseFromIdempotencyStoreIfExists(settings, orderId, orderJson);
if (cachedResponse != null)
if (cachedResponse != null)
{
return cachedResponse;
}
Expand All @@ -448,7 +449,7 @@ public async Task<ResponseContent> ProcessOrderProposalCreationP(string clientId
{
// Attempt to use idempotency cache if it exists
var cachedResponse = await GetResponseFromIdempotencyStoreIfExists(settings, orderId, orderJson);
if (cachedResponse != null)
if (cachedResponse != null)
{
return cachedResponse;
}
Expand All @@ -461,7 +462,7 @@ public async Task<ResponseContent> ProcessOrderProposalCreationP(string clientId

private async Task<ResponseContent> GetResponseFromIdempotencyStoreIfExists(BookingEngineSettings settings, OrderIdComponents orderId, string orderJson)
{
// Attempt to use idempotency cache if it exists
// Attempt to use idempotency cache if it exists
if (settings.IdempotencyStore != null)
{
var cachedResponse = await settings.IdempotencyStore.GetSuccessfulOrderCreationResponse(orderId, orderJson);
Expand All @@ -473,7 +474,8 @@ private async Task<ResponseContent> GetResponseFromIdempotencyStoreIfExists(Book
return null;
}

private async Task<ResponseContent> CreateResponseViaIdempotencyStoreIfExists(BookingEngineSettings settings, OrderIdComponents orderId, string orderJson, Order response) {
private async Task<ResponseContent> CreateResponseViaIdempotencyStoreIfExists(BookingEngineSettings settings, OrderIdComponents orderId, string orderJson, Order response)
{
// Return a 409 status code if any OrderItem level errors exist
var httpStatusCode = response.OrderedItem.Exists(x => x.Error?.Count > 0) ? HttpStatusCode.Conflict : HttpStatusCode.Created;
var responseJson = OpenActiveSerializer.Serialize(response);
Expand Down Expand Up @@ -729,7 +731,7 @@ async Task<ResponseContent> IBookingEngine.InsertTestOpportunity(string testData
throw new OpenBookingException(new OpenBookingError(), "Only bookable opportunities are permitted in the test interface");

// TODO: add this error class to the library
// CS: Is this still the case? Unclear where this library is, and hard to believe OpenBookingError would not be in the libary
// CS: Does this mean add a new specific error to OpenActive.Net, something like OnlyBookableOpportunitesPermittedInTestInterfaceError
}

if (!genericEvent.TestOpportunityCriteria.HasValue)
Expand Down

0 comments on commit 5948b2f

Please sign in to comment.