mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 12:11:10 +00:00
Converts the web client request objects from classes to records.
This commit is contained in:
1 parent
5a27c22109
commit
defbd9176f
26 files changed
+247
-383
No files matched your search
+5
-5
@@ -22,12 +22,12 @@ public class ReorderArtworkProvidersEndpointSummary : Summary<ReorderArtworkProv
|
||||
Summary = "Reorders the artwork providers of a media library.";
|
||||
Description = "Reorders the artwork providers of the media library identified by the route, in the provided order.";
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose artwork providers are reordered. Required.");
|
||||
RequestParam(r => r.PluginIds, "The plugin Ids in the new order, from highest to lowest rank. Required.");
|
||||
|
||||
ExampleRequest = new ReorderLibraryArtworkProvidersRequest
|
||||
{
|
||||
LibraryId = Guid.NewGuid(),
|
||||
PluginIds = [Guid.NewGuid(), Guid.NewGuid()]
|
||||
};
|
||||
ExampleRequest = new ReorderLibraryArtworkProvidersRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
PluginIds: [Guid.NewGuid(), Guid.NewGuid()]
|
||||
);
|
||||
|
||||
Response(200, "The artwork providers of the media library are reordered.", example: new SuccessResponse(true));
|
||||
}
|
||||
|
||||
+5
-5
@@ -25,14 +25,14 @@ public class ReorderMetadataProvidersEndpointSummary : Summary<ReorderMetadataPr
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose metadata providers are reordered. Required.");
|
||||
RequestParam(r => r.PluginIds, "The plugin Ids in the new order, from highest to lowest rank. Required.");
|
||||
|
||||
ExampleRequest = new ReorderLibraryMetadataProvidersRequest
|
||||
{
|
||||
LibraryId = Guid.NewGuid(),
|
||||
PluginIds = [
|
||||
ExampleRequest = new ReorderLibraryMetadataProvidersRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
PluginIds:
|
||||
[
|
||||
Guid.NewGuid(),
|
||||
Guid.NewGuid(),
|
||||
]
|
||||
};
|
||||
);
|
||||
|
||||
Response(200, "The metadata providers of the media library are reordered.", example: new SuccessResponse(true));
|
||||
}
|
||||
|
||||
+5
-6
@@ -25,12 +25,11 @@ public class SetArtworkProviderEnabledEndpointSummary : Summary<SetArtworkProvid
|
||||
RequestParam(r => r.PluginId, "The unique identifier of the plugin providing the artwork. Required.");
|
||||
RequestParam(r => r.IsEnabled, "Whether the artwork provider should be enabled for the media library, or not. Required.");
|
||||
|
||||
ExampleRequest = new SetLibraryArtworkProviderEnabledRequest
|
||||
{
|
||||
LibraryId = Guid.NewGuid(),
|
||||
PluginId = Guid.NewGuid(),
|
||||
IsEnabled = true
|
||||
};
|
||||
ExampleRequest = new SetLibraryArtworkProviderEnabledRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
PluginId: Guid.NewGuid(),
|
||||
IsEnabled: true
|
||||
);
|
||||
|
||||
Response(200, "The artwork provider of the media library is enabled or disabled.", example: new SuccessResponse(true));
|
||||
}
|
||||
|
||||
+5
-6
@@ -25,12 +25,11 @@ public class SetBookReaderEnabledEndpointSummary : Summary<SetBookReaderEnabledE
|
||||
RequestParam(r => r.PluginId, "The unique identifier of the plugin providing the book reader. Required.");
|
||||
RequestParam(r => r.IsEnabled, "Whether the book reader should be enabled for the media library, or not. Required.");
|
||||
|
||||
ExampleRequest = new SetBookReaderEnabledRequest
|
||||
{
|
||||
LibraryId = Guid.NewGuid(),
|
||||
PluginId = Guid.NewGuid(),
|
||||
IsEnabled = true
|
||||
};
|
||||
ExampleRequest = new SetBookReaderEnabledRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
PluginId: Guid.NewGuid(),
|
||||
IsEnabled: true
|
||||
);
|
||||
|
||||
Response(200, "The book reader of the media library is enabled or disabled.", example: new SuccessResponse(true));
|
||||
}
|
||||
|
||||
+5
-6
@@ -25,12 +25,11 @@ public class SetMetadataProviderEnabledEndpointSummary : Summary<SetMetadataProv
|
||||
RequestParam(r => r.PluginId, "The unique identifier of the plugin providing the metadata. Required.");
|
||||
RequestParam(r => r.IsEnabled, "Whether the metadata provider should be enabled for the media library, or not. Required.");
|
||||
|
||||
ExampleRequest = new SetLibraryMetadataProviderEnabledRequest
|
||||
{
|
||||
LibraryId = Guid.NewGuid(),
|
||||
PluginId = Guid.NewGuid(),
|
||||
IsEnabled = true
|
||||
};
|
||||
ExampleRequest = new SetLibraryMetadataProviderEnabledRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
PluginId: Guid.NewGuid(),
|
||||
IsEnabled: true
|
||||
);
|
||||
|
||||
Response(200, "The metadata provider of the media library is enabled or disabled.", example: new SuccessResponse(true));
|
||||
}
|
||||
|
||||
+10
-11
@@ -33,17 +33,16 @@ public class GetLibraryItemsEndpointSummary : Summary<GetLibraryItemsEndpoint, G
|
||||
RequestParam(r => r.SortBy, "The name of the field by which to sort the results. Optional.");
|
||||
RequestParam(r => r.SortOrder, "The direction in which to sort the results. Optional.");
|
||||
|
||||
ExampleRequest = new GetBooksLiteRequest
|
||||
{
|
||||
LibraryId = Guid.NewGuid(),
|
||||
CurrentPage = 1,
|
||||
PerPage = 48,
|
||||
SearchTerm = "fellowship",
|
||||
FilterAlphaKey = "f",
|
||||
ShouldIgnoreThePrefixForAlphaPicker = true,
|
||||
SortBy = "title",
|
||||
SortOrder = SortOrder.Ascending
|
||||
};
|
||||
ExampleRequest = new GetBooksLiteRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
CurrentPage: 1,
|
||||
PerPage: 48,
|
||||
SearchTerm: "fellowship",
|
||||
FilterAlphaKey: "f",
|
||||
ShouldIgnoreThePrefixForAlphaPicker: true,
|
||||
SortBy: "title",
|
||||
SortOrder: SortOrder.Ascending
|
||||
);
|
||||
|
||||
Response(200, "The lightweight details of the books of the media library are returned.", example: new SuccessResponse<PaginatedBookLiteDto>(true, default));
|
||||
}
|
||||
|
||||
+6
-5
@@ -50,14 +50,15 @@ public class SaveBookEndpoint : BaseEndpoint<UpdateBookRequest, IResult>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(UpdateBookRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
// The book is identified by the {bookId} route value, not by the id posted in the form, so that a mismatched id can never redirect
|
||||
// the update to another book; the value is normalized to a Guid before it is substituted into the upstream URL, so that a crafted
|
||||
// route value can never escape its URL segment, and an unparseable id is reported by the API as a missing book id.
|
||||
// The book is identified by the {bookId} route value, not by the id posted in the body, so that a mismatched id can never redirect
|
||||
// the update to another book; both ids are normalized to Guids before they are substituted into the upstream URL, so that a crafted
|
||||
// value can never escape its URL segment, and an unparseable id is reported by the API as a missing book id.
|
||||
string routeId = HttpContext.Request.RouteValues["bookId"]?.ToString() ?? string.Empty;
|
||||
request.BookId = Guid.TryParse(routeId, out Guid bookId) ? bookId.ToString() : Guid.Empty.ToString();
|
||||
string bookId = Guid.TryParse(routeId, out Guid parsedBookId) ? parsedBookId.ToString() : Guid.Empty.ToString();
|
||||
UpdateBookRequest requestWithRouteId = request with { BookId = bookId };
|
||||
|
||||
BookDetailsDto book = await _apiHttpClient.PutAsync<BookDetailsDto, UpdateBookRequest>(
|
||||
ApiRoutes.Books.UPDATE_BOOK.Replace("{libraryId}", request.LibraryId.ToString()).Replace("{bookId}", request.BookId), request, cancellationToken).ConfigureAwait(false);
|
||||
ApiRoutes.Books.UPDATE_BOOK.Replace("{libraryId}", requestWithRouteId.LibraryId.ToString()).Replace("{bookId}", bookId), requestWithRouteId, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(book);
|
||||
}
|
||||
}
|
||||
+21
-22
@@ -72,11 +72,10 @@ public class SaveBookEndpointSummary : Summary<SaveBookEndpoint, UpdateBookReque
|
||||
RequestParam(r => r.Contributors, "The list of media contributors of the book. Required.");
|
||||
RequestParam(r => r.Ratings, "The list of ratings of the book. Required.");
|
||||
|
||||
ExampleRequest = new UpdateBookRequest
|
||||
{
|
||||
BookId = Guid.NewGuid().ToString(),
|
||||
LibraryId = Guid.NewGuid(),
|
||||
Metadata = new WrittenContentMetadataDto
|
||||
ExampleRequest = new UpdateBookRequest(
|
||||
BookId: Guid.NewGuid().ToString(),
|
||||
LibraryId: Guid.NewGuid(),
|
||||
Metadata: new WrittenContentMetadataDto
|
||||
{
|
||||
Title = "The Fellowship of the Ring",
|
||||
OriginalTitle = "The Fellowship of the Ring",
|
||||
@@ -117,28 +116,28 @@ public class SaveBookEndpointSummary : Summary<SaveBookEndpoint, UpdateBookReque
|
||||
Publisher = "Houghton Mifflin",
|
||||
PageCount = 398
|
||||
},
|
||||
Format = BookFormat.Paperback,
|
||||
Edition = "50th Anniversary Edition",
|
||||
VolumeNumber = 1,
|
||||
Series = new BookSeriesDto
|
||||
Format: BookFormat.Paperback,
|
||||
Edition: "50th Anniversary Edition",
|
||||
VolumeNumber: 1,
|
||||
Series: new BookSeriesDto
|
||||
{
|
||||
Title = "The Lord of the Rings"
|
||||
},
|
||||
ASIN = "B007978NPG",
|
||||
GoodreadsId = "3",
|
||||
LCCN = "54009621",
|
||||
OCLCNumber = "ocm00012345",
|
||||
OpenLibraryId = "OL7603910M",
|
||||
LibraryThingId = "3203347",
|
||||
GoogleBooksId = "aWZzLPhY4o0C",
|
||||
BarnesAndNobleId = "1100307790",
|
||||
AppleBooksId = "id395211",
|
||||
ISBNs =
|
||||
ASIN: "B007978NPG",
|
||||
GoodreadsId: "3",
|
||||
LCCN: "54009621",
|
||||
OCLCNumber: "ocm00012345",
|
||||
OpenLibraryId: "OL7603910M",
|
||||
LibraryThingId: "3203347",
|
||||
GoogleBooksId: "aWZzLPhY4o0C",
|
||||
BarnesAndNobleId: "1100307790",
|
||||
AppleBooksId: "id395211",
|
||||
ISBNs:
|
||||
[
|
||||
new IsbnDto { Value = "0395272238", Format = IsbnFormat.Isbn10 },
|
||||
new IsbnDto { Value = "9780395272237", Format = IsbnFormat.Isbn13 }
|
||||
],
|
||||
Contributors =
|
||||
Contributors:
|
||||
[
|
||||
new MediaContributorDto
|
||||
{
|
||||
@@ -151,12 +150,12 @@ public class SaveBookEndpointSummary : Summary<SaveBookEndpoint, UpdateBookReque
|
||||
Role = MediaContributorRole.Illustrator
|
||||
}
|
||||
],
|
||||
Ratings =
|
||||
Ratings:
|
||||
[
|
||||
new BookRatingDto { Source = BookRatingSource.GoogleBooks, Value = 4.36M, MaxValue = 5, VoteCount = 2345678 },
|
||||
new BookRatingDto { Source = BookRatingSource.Amazon, Value = 4.7M, MaxValue = 5, VoteCount = 87654 }
|
||||
]
|
||||
};
|
||||
);
|
||||
|
||||
Response(200, "The updated book is returned.", example: new SuccessResponse<BookDetailsDto>(true, default));
|
||||
}
|
||||
|
||||
+4
-5
@@ -25,15 +25,14 @@ public class UpdatePluginSettingsEndpointSummary : Summary<UpdatePluginSettingsE
|
||||
RequestParam(r => r.PluginId, "The unique identifier of the plugin. Required.");
|
||||
RequestParam(r => r.Settings, "The settings of the plugin. Optional.");
|
||||
|
||||
ExampleRequest = new UpdatePluginSettingsRequest
|
||||
{
|
||||
PluginId = Guid.NewGuid(),
|
||||
Settings = new Dictionary<string, string>
|
||||
ExampleRequest = new UpdatePluginSettingsRequest(
|
||||
PluginId: Guid.NewGuid(),
|
||||
Settings: new Dictionary<string, string>
|
||||
{
|
||||
{ "preferredLanguage", "fr" },
|
||||
{ "selectionStrategy", "first" }
|
||||
}
|
||||
};
|
||||
);
|
||||
|
||||
Response(200, "The settings of the plugin are updated.", example: new SuccessResponse(true));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user