dragonsbootcampllc / DraagonsWebsite24

This is a staging Branch for Dragons Website that means (it's not the production, the production is getting the content from here after merging this repo[staging] the the other repo[Production])
https://dragonsbootcampstaging.netlify.app/
3 stars 3 forks source link

Mini Sprint API #101

Closed Hamdysaad20 closed 3 months ago

Hamdysaad20 commented 4 months ago

Minisprint Management API

GET /api/minisprintSystem/minisprint

Description:

Fetches a list of minisprints or a specific minisprint based on query parameters.

Query Parameters:

Response:

Example:

GET /api/minisprintSystem/minisprint?name=exampleMinisprint

POST /api/minisprintSystem/minisprint

Description:

Creates a new minisprint.

Request Body:

{
    "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"]
}

Response:

PUT /api/minisprintSystem/minisprint

Description:

Edits an existing minisprint.

Request Body:

{
    "name": "string",
    "description": "string",
    "price": "string",
    "startDate": "string",
    "duration": "string",
    "isActive": "boolean",
    "keyLearnings": ["string"],
    "content": [
        {
            "icon": "string",
            "title": "string",
            "description": "string"
        }
    ],
    "requirements": ["string"]
}

Response:

DELETE /api/minisprintSystem/minisprint

Description:

Deletes a minisprint.

Query Parameters:

Response:


Booking Management API

GET /api/minisprintSystem/book

Description:

Fetches all bookings.

Response:

POST /api/minisprintSystem/book

Description:

Creates a new booking.

Request Body:

{
    "minisprintName": "string",
    "user": {
        "name": "string",
        "email": "string"
    },
    "is_paid": "boolean"
}

Response:

PUT /api/minisprintSystem/book

Description:

Edits an existing booking.

Request Body:

{
    "id": "number",
    "minisprintName": "string",
    "user": {
        "name": "string",
        "email": "string"
    },
    "is_paid": "boolean"
}

Response:


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 /api/minisprintSystem/minisprint

Get a specific minisprint by name

GET /api/minisprintSystem/minisprint?name=exampleMinisprint

Get minisprints by active status

GET /api/minisprintSystem/minisprint?isActive=true

Add a new minisprint

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"]
}

Edit an existing minisprint

PUT /api/minisprintSystem/minisprint
Content-Type: application/json
{
    "name": "New Minisprint",
    "description": "Updated description"
}

Delete a minisprint

DELETE /api/minisprintSystem/minisprint?name=New Minisprint

Get all bookings

GET /api/minisprintSystem/book

Create a new booking

POST /api/minisprintSystem/book
Content-Type: application/json
{
    "minisprintName": "New Minisprint",
    "user": {
        "name": "John Doe",
        "email": "john.doe@example.com"
    },
    "is_paid": true
}

Edit an existing booking

PUT /api/minisprintSystem/book
Content-Type: application/json
{
    "id": 1,
    "is_paid": false
}