Closed Hamdysaad20 closed 3 months ago
Fetches a list of minisprints or a specific minisprint based on query parameters.
name
isActive
200 OK:
{ "image": "string", "name": "string", "description": "string", "price": "string", "startDate": "string", "duration": "string", "isActive": "boolean", "keyLearnings": ["string"], "content": [ { "icon": "string", "title": "string", "description": "string" } ], "requirements": ["string"] }
[ { "image": "string", "name": "string", "description": "string", "price": "string", "startDate": "string", "duration": "string", "isActive": "boolean" }, ... ]
404 Not Found: Minisprint not found when name is provided.
GET /api/minisprintSystem/minisprint?name=exampleMinisprint
Creates a new minisprint.
201 Created:
{ "message": "Minisprint created successfully" }
400 Bad Request: Validation error.
409 Conflict: Minisprint already exists.
Edits an existing minisprint.
{ "name": "string", "description": "string", "price": "string", "startDate": "string", "duration": "string", "isActive": "boolean", "keyLearnings": ["string"], "content": [ { "icon": "string", "title": "string", "description": "string" } ], "requirements": ["string"] }
{ "message": "Minisprint updated successfully" }
404 Not Found: Minisprint not found.
Deletes a minisprint.
{ "message": "Minisprint deleted successfully" }
Fetches all bookings.
[ { "id": "number", "minisprintName": "string", "user": { "name": "string", "email": "string" }, "is_paid": "boolean" }, ... ]
Creates a new booking.
{ "minisprintName": "string", "user": { "name": "string", "email": "string" }, "is_paid": "boolean" }
{ "message": "Booking created successfully", "id": "number" }
Edits an existing booking.
{ "id": "number", "minisprintName": "string", "user": { "name": "string", "email": "string" }, "is_paid": "boolean" }
{ "message": "Booking updated successfully" }
404 Not Found: Booking not found.
{ "message": "Method not allowed" }
readJSON(filePath)
Reads a JSON file from the given file path and returns the parsed data.
writeJSON(filePath, data)
Writes the provided data as JSON to the given file path.
GET /api/minisprintSystem/minisprint
GET /api/minisprintSystem/minisprint?isActive=true
POST /api/minisprintSystem/minisprint Content-Type: application/json { "image": "url_to_image", "name": "New Minisprint", "description": "Description of the minisprint", "price": "$100", "startDate": "2024-07-01", "duration": "2 weeks", "isActive": true, "keyLearnings": ["Point 1", "Point 2"], "content": [ { "icon": "url_to_icon", "title": "Content Title", "description": "Content description" } ], "requirements": ["Requirement 1", "Requirement 2"] }
PUT /api/minisprintSystem/minisprint Content-Type: application/json { "name": "New Minisprint", "description": "Updated description" }
DELETE /api/minisprintSystem/minisprint?name=New Minisprint
GET /api/minisprintSystem/book
POST /api/minisprintSystem/book Content-Type: application/json { "minisprintName": "New Minisprint", "user": { "name": "John Doe", "email": "john.doe@example.com" }, "is_paid": true }
PUT /api/minisprintSystem/book Content-Type: application/json { "id": 1, "is_paid": false }
Minisprint Management API
GET /api/minisprintSystem/minisprint
Description:
Fetches a list of minisprints or a specific minisprint based on query parameters.
Query Parameters:
name
(optional): Name of the minisprint to retrieve.isActive
(optional): Boolean to filter minisprints by their active status.Response:
200 OK:
name
is provided and the minisprint is found:isActive
is provided:404 Not Found: Minisprint not found when
name
is provided.Example:
POST /api/minisprintSystem/minisprint
Description:
Creates a new minisprint.
Request Body:
Response:
201 Created:
400 Bad Request: Validation error.
409 Conflict: Minisprint already exists.
PUT /api/minisprintSystem/minisprint
Description:
Edits an existing minisprint.
Request Body:
Response:
200 OK:
400 Bad Request: Validation error.
404 Not Found: Minisprint not found.
DELETE /api/minisprintSystem/minisprint
Description:
Deletes a minisprint.
Query Parameters:
name
(required): Name of the minisprint to delete.Response:
200 OK:
404 Not Found: Minisprint not found.
Booking Management API
GET /api/minisprintSystem/book
Description:
Fetches all bookings.
Response:
POST /api/minisprintSystem/book
Description:
Creates a new booking.
Request Body:
Response:
201 Created:
400 Bad Request: Validation error.
PUT /api/minisprintSystem/book
Description:
Edits an existing booking.
Request Body:
Response:
200 OK:
400 Bad Request: Validation error.
404 Not Found: Booking not found.
Common Responses
405 Method Not Allowed
Helper Functions
readJSON(filePath)
Reads a JSON file from the given file path and returns the parsed data.
writeJSON(filePath, data)
Writes the provided data as JSON to the given file path.
Usage Example
Get all minisprints
Get a specific minisprint by name
Get minisprints by active status
Add a new minisprint
Edit an existing minisprint
Delete a minisprint
Get all bookings
Create a new booking
Edit an existing booking