Standardize all Bruno environment variables to use snake_case convention
(aligned with Go naming practices) and remove duplicate camelCase variants.
Changes:
- Environment file cleanup:
- Remove: baseUrl, ebookid, fakebookid, libraryId, mediaItemId, isVisible, refreshToken
- Standardize: fakebookid → fake_book_id, isVisible → is_visible, refreshToken → refresh_token
- All variables now use consistent snake_case format
- Update all Bruno requests to use standardized variables:
- ebooks: {{ebookid}} → {{ebook_id}}
- library: {{libraryId}} → {{library_id}}
- media-items: {{mediaItemId}} → {{media_item_id}}
- visibility: {{isVisible}} → {{is_visible}}
- auth: {{refreshToken}} → {{refresh_token}}
Benefits:
- Single source of truth for each variable
- Consistent with Go naming conventions
- No ambiguity about which variable name to use
- Cleaner, more maintainable codebase
112 lines
2.7 KiB
Plaintext
112 lines
2.7 KiB
Plaintext
meta {
|
|
name: Create Media Rating
|
|
type: http
|
|
seq: 1
|
|
}
|
|
|
|
post {
|
|
url: {{base_url}}/api/media-items/{{media_item_id}}/rating
|
|
auth: inherit
|
|
body: json
|
|
}
|
|
|
|
headers {
|
|
Content-Type: application/json
|
|
}
|
|
|
|
body:json {
|
|
{
|
|
"rating": 8
|
|
}
|
|
}
|
|
|
|
tests {
|
|
test_create_rating_success(status, headers, body) {
|
|
if (status !== 201) {
|
|
throw new Error("Expected status 201, got " + status);
|
|
}
|
|
|
|
const contentType = headers["content-type"];
|
|
if (!contentType || !contentType.includes("application/json")) {
|
|
throw new Error("Expected content-type to contain application/json, got " + contentType);
|
|
}
|
|
|
|
// Verify response body is valid JSON and has expected structure
|
|
let data;
|
|
try {
|
|
data = JSON.parse(body);
|
|
} catch (e) {
|
|
throw new Error("Response body is not valid JSON");
|
|
}
|
|
|
|
if (!data || typeof data !== "object") {
|
|
throw new Error("Expected response body to be an object");
|
|
}
|
|
|
|
// Check for required fields in rating response
|
|
if (!data.id) {
|
|
throw new Error("Rating response missing required field: id");
|
|
}
|
|
|
|
if (!data.media_item_id) {
|
|
throw new Error("Rating response missing required field: media_item_id");
|
|
}
|
|
|
|
if (typeof data.rating !== "number" || data.rating < 1 || data.rating > 10) {
|
|
throw new Error("Invalid rating value: " + data.rating + " (must be 1-10)");
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
vars:pre-request {
|
|
mediaItemId: "9932c704-i29b-81d4-e716-446655440004"
|
|
}
|
|
|
|
settings {
|
|
encodeUrl: true
|
|
timeout: 0
|
|
}
|
|
|
|
docs {
|
|
## Create Media Rating
|
|
|
|
Creates or updates the authenticated user's rating for a specific media item.
|
|
|
|
**Method:** POST
|
|
|
|
**Endpoint:** /api/media-items/{id}/rating
|
|
|
|
**Authentication:** Required (Bearer token)
|
|
|
|
**Path Parameters:**
|
|
- `id` (string, required): Media item UUID
|
|
|
|
**Request Body:**
|
|
- `rating` (number, required): Rating value (1-10, where odd numbers = half-stars)
|
|
- 1,3,5,7,9 = 0.5,1.5,2.5,3.5,4.5 stars (half-star precision)
|
|
- 2,4,6,8,10 = 1,2,3,4,5 stars (full stars)
|
|
|
|
**Example Request:**
|
|
- `"rating": 7` = 3.5 stars (frontend display)
|
|
- `"rating": 8` = 4.0 stars (frontend display)
|
|
|
|
**Response:** Rating object
|
|
- `id` (string): Rating UUID
|
|
- `media_item_id` (string): Media item UUID
|
|
- `user_id` (string): User UUID
|
|
- `rating` (number): Rating value (1-10)
|
|
- `created_at` (string): Creation timestamp
|
|
- `updated_at` (string): Last update timestamp
|
|
|
|
**Status Codes:**
|
|
- 201: Rating created successfully
|
|
- 200: Rating updated successfully (if rating already existed)
|
|
- 400: Invalid rating value (must be 1-10)
|
|
- 401: Unauthorized
|
|
- 403: Forbidden (rating access denied)
|
|
- 404: Media item not found
|
|
- 500: Internal server error
|
|
}
|