# request\_board

### **Request\_board endpoint**

## get\_request\_board

<mark style="color:blue;">`GET`</mark> `https://carpoolingbackend.herokuapp.com/v1/apis/request_board`

Get the request\_board status of demands and offers

#### Path Parameters

| Name          | Type   | Description                                           |
| ------------- | ------ | ----------------------------------------------------- |
| Authorization | string | The `auth_token` of the currently authenticated user. |

{% tabs %}
{% tab title="200 Successful board\_request status get." %}

```
[
  {
    "id": 2,
    "status": "PE",
    "offer": 2,
    "demand": 2
  }
]
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
The board\_request endpoint returns the status of the trip.

the trip can exist in three states;&#x20;

**(** **`AC`** => `accepted`, **`PE`** => `pending`, **`DE`** => `denied`**)**

it also returns the `offer_id` and the `demand_id.`
{% endhint %}

#### `An example of a get request on the request_board endpoint.`

![](https://2024038863-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwmhcyiDwr6i4voPxEn%2F-LyY-YSNO9bTdDvc9WGr%2F-LyY6EjKRHESGByHP8l2%2Fboard_request_get.png?alt=media\&token=a34abdce-5a6c-4f57-b2a7-7a36a73348c0)

## get status of a specific trip&#x20;

<mark style="color:blue;">`GET`</mark> `https://carpoolingbackend.herokuapp.com/v1/apis/request_board/{id}`

Filter the trip\_request response based on id's.&#x20;

#### Path Parameters

| Name          | Type   | Description                                       |
| ------------- | ------ | ------------------------------------------------- |
| Authorization | string | The `auth_token` of the currently logged in user. |

#### Query Parameters

| Name | Type    | Description           |
| ---- | ------- | --------------------- |
| id   | integer | The request\_board id |

{% tabs %}
{% tab title="200 Successful get\_request " %}

```
{
  "id": 2,
  "status": "PE",
  "offer": 2,
  "demand": 2
}
```

{% endtab %}
{% endtabs %}

####

#### An example of a get request on the board\_request endpoint filtered by id.

![](https://2024038863-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwmhcyiDwr6i4voPxEn%2F-LyY-YSNO9bTdDvc9WGr%2F-LyY6IBqLeAudt2OKFXP%2Fboard_request_get_individual.png?alt=media\&token=e208bc8a-3fab-4ea5-a1c0-81c2d1ba558c)

## post\_trip\_status

<mark style="color:green;">`POST`</mark> `https://carpoolingbackend.herokuapp.com/v1/apis/request_board`

Accept a demand on a trip offer.

#### Path Parameters

| Name          | Type   | Description                                       |
| ------------- | ------ | ------------------------------------------------- |
| Authorization | string | The `auth_token` of the currently logged in user. |

#### Request Body

| Name   | Type    | Description                                       |
| ------ | ------- | ------------------------------------------------- |
| status | string  | The status of the trip, either (`AC`, `PE`, `DE`) |
| offer  | integer | the offer id                                      |
| demand | integer | the demand id                                     |

{% tabs %}
{% tab title="200 A successful change of status to accepted ( AC ) on offer\_id 1 and demand\_id 1." %}

```
{
  "id": 1,
  "status": "AC",
  "offer": 1,
  "demand": 1
}
```

{% endtab %}

{% tab title="400 The error message on a bad request" %}

```
{
  "status": "400",
  "message": "User already has an existing request.Cancel requet to make another",
  "request_board": {
    "id": "1",
    "status": "PE",
    "offer": "1",
    "demand": "1"
  }
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
Pass the `offer_id` and the `demand_id` to be accepted on the offer.
{% endhint %}

#### An example of a post request on the request\_board endpoint

![](https://2024038863-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwmhcyiDwr6i4voPxEn%2F-LyY-YSNO9bTdDvc9WGr%2F-LyY4xohV7Qch52OZs9A%2Frequest_board_post_201.png?alt=media\&token=0a5acda9-eef9-4a6c-bcf3-df9ccfa2e48f)

## update trip status

<mark style="color:purple;">`PATCH`</mark> `https://carpoolingbackend.herokuapp.com/v1/apis/request_board/{id}`

Update the status of the trip

#### Path Parameters

| Name          | Type   | Description                                       |
| ------------- | ------ | ------------------------------------------------- |
| Authorization | string | The `auth_token` of the currently logged in user. |

#### Query Parameters

| Name | Type    | Description                           |
| ---- | ------- | ------------------------------------- |
| id   | integer | The `board_request id` to be updated. |

#### Request Body

| Name   | Type   | Description                                                 |
| ------ | ------ | ----------------------------------------------------------- |
| status | string | The status of the trip..choices are  ( `AC`, `PE` or `DE`). |

{% tabs %}
{% tab title="200 " %}

```
{
  "id": 1,
  "status": "PE",
  "offer": 1,
  "demand": 1
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
You **DO NOT** have to `provide offer_id` and `demand_id` when making a patch request to this endpoint.
{% endhint %}

#### An example of a patch\_request on the request\_board endpoint

![patch\_request\_board](https://2024038863-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwmhcyiDwr6i4voPxEn%2F-LyY-YSNO9bTdDvc9WGr%2F-LyY8V1MWSoOTgLgZjWv%2Frequest_board_patch_200.png?alt=media\&token=4a01c708-11f6-437b-9934-c6b94e0ac597)
