Create feedbackv1.0.0 · JSON Schema
Creates a feedback rating for a Catalog book and returns its generated UUID.
1. Submit a Book Review with Rating and Comment
An authenticated reader submits a 5-star review for “The Left Hand of Darkness” on the storefront book detail page.
Payload details
bookId: Required UUID of the Catalog book being reviewed.firstName: Reviewer’s first name (string | null).lastName: Reviewer’s last name (string | null).comment: Optional written review (string | null).rating: Integer rating from0through5.
Example payload
{ "bookId": "01960a1b-2c3d-7e4f-8a9b-0c1d2e3f4a10", "firstName": "Minh", "lastName": "Nguyen", "comment": "A landmark of anthropological science fiction with unforgettable world-building.", "rating": 5}Using this example
Returns 201 Created with the persisted Feedback JSON object and dispatches FeedbackCreatedIntegrationEvent to update the book’s rating summary in Catalog API.
using BookWorm.Chassis.Utilities.Configurations;using BookWorm.Constants.Aspire;using Refit;
public interface IRatingApiClient{ [Post("/api/v1/feedbacks")] Task<FeedbackResponse> CreateFeedbackAsync( [Body] CreateFeedbackRequest request, CancellationToken cancellationToken = default );}
public sealed record CreateFeedbackRequest( Guid BookId, string? FirstName, string? LastName, string? Comment, int Rating);
// DI registration following BookWorm.Chassis Refit patternbuilder.Services .AddRefitGeneratedClient<IRatingApiClient>(settings, Services.Rating) .ConfigureHttpClient(client => client.BaseAddress = new($"https+http://{Services.Rating}")) .ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler { PooledConnectionLifetime = TimeSpan.FromMinutes(5) } );
// Typed invocationvar feedback = await ratingApiClient.CreateFeedbackAsync( new( Guid.Parse("01960a1b-2c3d-7e4f-8a9b-0c1d2e3f4a10"), "Minh", "Nguyen", "A landmark of anthropological science fiction with unforgettable world-building.", 5 ), cancellationToken);import ratingApiClient from "@workspace/api-client/rating/feedbacks";import useCreateFeedback from "@workspace/api-hooks/rating/useCreateFeedback";
// 1. Direct @workspace/api-client (Axios) callconst feedback = await ratingApiClient.create({ bookId: "01960a1b-2c3d-7e4f-8a9b-0c1d2e3f4a10", firstName: "Minh", lastName: "Nguyen", comment: "A landmark of anthropological science fiction with unforgettable world-building.", rating: 5,});
// 2. React / TanStack Query hook (@workspace/api-hooks)const { mutate: createFeedback, isPending } = useCreateFeedback({ onSuccess: (created) => { console.log(`Submitted feedback ${created.id} with rating ${created.rating}`); },});
createFeedback({ bookId: "01960a1b-2c3d-7e4f-8a9b-0c1d2e3f4a10", firstName: "Minh", lastName: "Nguyen", comment: "A landmark of anthropological science fiction with unforgettable world-building.", rating: 5,});1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "CreateFeedbackCommand",
4 "type": "object",
5 "additionalProperties": false,
6 "required": ["bookId", "firstName", "lastName", "rating"],
7 "properties": {
8 "bookId": {
9 "type": "string",
10 "format": "uuid",
11 "description": "Identifier of the Catalog book being reviewed."
12 },
13 "firstName": {
14 "type": "string",
15 "minLength": 1,
16 "maxLength": 50,
17 "description": "First name of the reviewer."
18 },
19 "lastName": {
20 "type": "string",
21 "minLength": 1,
22 "maxLength": 50,
23 "description": "Last name of the reviewer."
24 },
25 "comment": {
26 "type": ["string", "null"],
27 "maxLength": 1000,
28 "description": "Optional written feedback."
29 },
30 "rating": {
31 "type": "integer",
32 "minimum": 0,
33 "maximum": 5,
34 "description": "Rating value from 0 through 5."
35 }
36 }
37}
38