# Submission API Documentation

#### Base URL

The base URL for the submission endpoints is `/submission`.

### Routes

#### Create Submission

* **URL**: `/submission/new`
* **Method**: `POST`
* **Authentication Required**: Yes

**Request Parameters**

* `name` (optional): Name of the submission.
* `projectName` (required): Name of the project.
* `email` (required): Email address associated with the submission.
* `about` (optional): Details about the submission.
* `links` (optional Stringify json data):Relevant links (e.g., social media, website).

**Request Example**

```json
{
  "name": "John Doe",
  "projectName": "Project Alpha",
  "email": "john.doe@example.com",
  "about": "This is a submission about Project Alpha.",
  "links": JSON.stringify({
    "facebook": "https://facebook.com/johndoe",
    "twitter": "https://twitter.com/johndoe",
    "website": "https://johndoe.com",
    "github": "https://github.com/johndoe"
  })
}
```

**Example Request Using cURL**

```sh
curl -X POST 'https://paal-ecosystem-backend.onrender.com/submission/new' \
-H 'Content-Type: application/json' \
-H 'Bearer: your-authentication-token' \
-d '{
  "name": "John Doe",
  "projectName": "Project Alpha",
  "email": "john.doe@example.com",
  "about": "This is a submission about Project Alpha.",
  "links": '{
    "facebook": "https://facebook.com/johndoe",
    "twitter": "https://twitter.com/johndoe",
    "website": "https://johndoe.com",
    "github": "https://github.com/johndoe"
  }'
}'
```

#### Modify Submission

* **URL**: `/submission/save`
* **Method**: `POST`
* **Authentication Required**: Yes

**Request Parameters**

* `id` (required): ID of the submission to modify.
* `name` (optional): Updated name.
* `projectName` (optional): Updated project name.
* `email` (optional): Updated email address.
* `about` (optional): Updated details.
* `links` (optional): Updated links.

**Request Example**

```json
{
  "id": "submission-id",
  "name": "Jane Doe",
  "projectName": "Project Beta",
  "email": "jane.doe@example.com",
  "about": "Updated submission details.",
  "links": JSON.stringify({
    "facebook": "https://facebook.com/janedoe",
    "twitter": "https://twitter.com/janedoe",
    "website": "https://janedoe.com",
    "github": "https://github.com/janedoe"
  })
}
```

**Example Request Using cURL**

```sh
curl -X POST 'https://paal-ecosystem-backend.onrender.com/submission/save' \
-H 'Content-Type: application/json' \
-H 'Bearer: your-authentication-token' \
-d '{
  "id": "submission-id",
  "name": "Jane Doe",
  "projectName": "Project Beta",
  "email": "jane.doe@example.com",
  "about": "Updated submission details.",
  "links": '{
    "facebook": "https://facebook.com/janedoe",
    "twitter": "https://twitter.com/janedoe",
    "website": "https://janedoe.com",
    "github": "https://github.com/janedoe"
  }'
}'
```

#### Delete Submission

* **URL**: `/submission/delete`
* **Method**: `POST`
* **Authentication Required**: Yes

**Request Parameters**

* `id` (required): ID of the submission to delete.

**Request Example**

```json
{
  "id": "submission-id"
}
```

**Example Request Using cURL**

```sh
curl -X POST 'https://paal-ecosystem-backend.onrender.com/submission/delete' \
-H 'Content-Type: application/json' \
-H 'Bearer: your-authentication-token' \
-d '{
  "id": "submission-id"
}'
```

#### Retrieve Submission

* **URL**: `/submission`
* **Method**: `GET`
* **Authentication Required**: No

**Request Parameters**

* `id` (required): ID of the submission to retrieve.

**Request Example**

```http
GET /submission?id=submission-id
```

**Example Request Using cURL**

```sh
curl -X GET 'https://paal-ecosystem-backend.onrender.com/submission?id=submissionId'
```

#### Retrieve All Submissions

* **URL**: `/submission/all`
* **Method**: `GET`
* **Authentication Required**: No

**Request Parameters**

* `sort`: Optional. Sort order of the results. Can be `asc` (ascending) or `desc` (descending). Default is `asc`.
* `num`: Required. Number of submissions to retrieve. Can be `all` to retrieve all submissions or a specific number.

**Request Example**

```http
GET /submission/all?sort=desc&num=10
```

**Example Request Using cURL**

```sh
curl -X GET 'https://paal-ecosystem-backend.onrender.com/submission/all?sort=desc&num=10'
```

## Submission Search API Documentation

This document details the API endpoint for searching submission data within the PAAL AI platform.

### Base URL

The base URL for the submission search endpoint is `/submission/search`.

### Route

#### Search Submissions

* **URL**: `/submission/search`
* **Method**: `GET`
* **Authentication Required**: No

**Request Parameters**

* `sort` (optional): Sort order of the results. Can be `asc` (ascending) or `desc` (descending). Default is `asc`.
* `num` (optional): Number of submissions to retrieve. Can be `all` to retrieve all submissions or a specific number.
* `key` (required): The field to search within the submissions.
* `value` (required): The value to search for in the specified field.

**Request Example**

```http
GET /submission/search?key=name&value=example
```

**Example Request Using cURL**

```sh
curl -X GET 'https://paal-ecosystem-backend.onrender.com/submission/search?key=name&value=example'
```

### Response

The response will include an array of submission data objects matching the search criteria, or an empty array if no submissions match the search.

Each submission data object contains the following fields:

* `id`: ID of the submission.
* `projectName`: Name of the project associated with the submission.
* `name`: Name of the submitter.
* `about`: Description or details about the submission.
* `email`: Email address of the submitter.
* `links`: Links provided by the submitter.
* `date`: Date of the submission.
* `data`: Additional data related to the submission.

### Example Response

```json
{
  "status": true,
  "data": [
    {
      "id": "submission-id-1",
      "projectName": "Example Project 1",
      "name": "John Doe",
      "about": "This is my submission.",
      "email": "john@example.com",
      "links": {
        "faceook": "",
        "twitter": "",
        "website": "",
        "github": ""
      },
      "date": 1653700145000,
      "data": {}
    },
    {
      "id": "submission-id-2",
      "projectName": "Example Project 2",
      "name": "Jane Smith",
      "about": "Another submission.",
      "email": "jane@example.com",
      "links": {
        "faceook": "",
        "twitter": "",
        "website": "",
        "github": ""
      },
      "date": 1653700145000,
      "data": {}
    }
  ]
}
```

### Error Responses

* If required parameters (`key` and `value`) are missing:

  ```json
  {
    "error": "Missing parameters",
    "params": "Key, Value"
  }
  ```
* If no submissions match the search criteria:

  ```json
  {
    "status": true,
    "data": []
  }
  ```
