Skip to content

contribution_api

sandeshkhadka edited this page Jun 21, 2024 · 3 revisions

Creating a Contribution

POST /api/create/contribution HTTP/1.1
Host: localhost:3000
Content-Type: application/json
Authorization: Bearer <JWT_TOKEN>
{
    "name": "<CONTRIBUTION_NAME>",
    "type": "<CONTRIBUTION_TYPE>",
    "amount":   "<NUMERIC_VALUE>" 

}

CONTRIBUTION_TYPE is defined in routes.ts Success Response:

{
    "contribution": {
        "id": "<CONTRIBUTION_ID>",
        "name": "<CONTRIBUTION_NAME>",
        "type": "<CONTRIBUTION_TYPE>",
        "amount": "<NUMERIC_VALUE>",
        "belongsToId": "<USER_ID>",
        "createdAt": "<TIMESTAMP>",
        "approvedBy": "<LIST_OF_USER_ID>",
        "passed": "<BOOLEAN>"
    }
}

Failure Response:

{
    "message": "Could not create Contribuion"
}

Deleting a Contribution

DELETE /api/contribution/<CONTRIBUTION_ID> HTTP/1.1
Host: localhost:3000
Content-Type: application/json
Authorization: Bearer <JWT_TOKEN>

Success response:

{
    "deleted": {
        "id": "<CONTRIBUTION_ID>",
        "name": "<CONTRIBUTION_NAME>",
        "type": "<CONTRIBUTION_TYPE>",
        "amount": "<NUMERIC_VALUE>",
        "belongsToId": "<USER_ID>",
        "createdAt": "<TIMESTAMP>",
        "approvedBy": "<LIST_OF_USER_ID>",
        "passed": "<BOOLEAN>"
    }
}

Failure response:

{
    "message": "Could not delete contribution"
}

Approving a Contributin

POST /api/contribution/approve/<CONTRIBUTION_ID> HTTP/1.1
Host: localhost:3000
Content-Type: application/json
Authorization: Bearer <JWT_TOKEN>

Success response:

{
    "updatedContribution": {
        "id": "<CONTRIBUTION_ID>",
        "name": "<CONTRIBUTION_NAME>",
        "type": "<CONTRIBUTION_TYPE>",
        "amount": "<NUMERIC_VALUE>",
        "belongsToId": "<USER_ID>",
        "createdAt": "<TIMESTAMP>",
        "approvedBy": "<LIST_OF_USER_ID>",
        "passed": "<BOOLEAN>"
    }
}

Failure response

{
    "message": "Contribution not found"
}
{
    "message": "already approved"
}
Clone this wiki locally