# Cart

## Create cart

<mark style="color:green;">`POST`</mark> `https://api.voordemensen.nl/v1/:client_name/cart/`

A `POST` HTTP request is sent. A shopping cart is created. The `Location` header is used to link to the newly created resource (the cart) in order for the client to be able to access it without querying anew. Save the cart\_id to the session if you want to access it again.

#### Path Parameters

| Name         | Type   | Description                                                        |
| ------------ | ------ | ------------------------------------------------------------------ |
| client\_name | string | the short name identifying you as a VdM client e.g. demo or fringe |

{% tabs %}
{% tab title="201 Cart created" %}

```
{"cart_id":"4DSMDACyPo8wLr8vFnTVUR6HzWC5tWGi"}
```

{% endtab %}
{% endtabs %}

## Put seat(s) in the cart

<mark style="color:green;">`POST`</mark> `https://api.voordemensen.nl/v1/:client_name/cart/:cart_id`

A `POST` HTTP request is used to put a seat in the cart. The event\_id, number of tickets and discount\_id is sent as part of the request body. The reply contains all cart data in order not to force the client to query again for it.

#### Path Parameters

| Name         | Type   | Description                                                        |
| ------------ | ------ | ------------------------------------------------------------------ |
| cart\_id     | string | the cart\_id identifying this cart                                 |
| client\_name | string | the short name identifying you as a VdM client e.g. demo or fringe |

#### Request Body

| Name            | Type    | Description                             |
| --------------- | ------- | --------------------------------------- |
| discount\_id    | string  | the id of the ticket type (or discount) |
| numberoftickets | integer | the number of tickets to add            |
| event\_id       | integer | the sub\_event id                       |

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

```
[{
	"seat_id": "azL0bNZdD1",
	"seat_row_nr": "0",
	"seat_nr": "0",
	"pmp_name": null,
	"event_id": 95,
	"event_name": "VoordeMensen Demo Event",
	"location_name": "Bellevue Grote Zaal",
	"event_date": "01-04-2022",
	"event_view_end": "00-00-0000",
	"event_time": "20:30",
	"recommand": [],
	"numberoftickets": 1,
	"seat_price": "24.50",
	"category_name": "standaard",
	"discount_id": "2ePdA8q3BN",
	"discount_name": "Standaard"
}, {
	"totalprice": "24.50"
}]
```

{% endtab %}
{% endtabs %}

## Get items in cart

<mark style="color:blue;">`GET`</mark> `https://api.voordemensen.nl/v1/:client_name/cart/:cart_id`

Get a list of items in the cart

#### Path Parameters

| Name         | Type   | Description                                                        |
| ------------ | ------ | ------------------------------------------------------------------ |
| client\_name | string | the short name identifying you as a VdM client e.g. demo or fringe |
| cart\_id     | string | the cart\_id identifying this cart                                 |

{% tabs %}
{% tab title="200 A list of items in the cart, otherwise the response is \[{"cart":0}]" %}

```
[{
	"seat_id": "azL0bNZdD1",
	"seat_row_nr": "0",
	"seat_nr": "0",
	"pmp_name": null,
	"event_id": 95,
	"event_name": "VoordeMensen Demo Event",
	"location_name": "Bellevue Grote Zaal",
	"event_date": "01-04-2022",
	"event_view_end": "00-00-0000",
	"event_time": "20:30",
	"recommand": [],
	"numberoftickets": 1,
	"seat_price": "24.50",
	"category_name": "standaard",
	"discount_id": "2ePdA8q3BN",
	"discount_name": "Standaard"
}, {
	"totalprice": "24.50"
}]
```

{% endtab %}
{% endtabs %}

The response is a list of items in the cart, followed by the calculated total price of the cart.

{% hint style="info" %}
If the Recommendation Extension is activated the response contains an array of other events the user can visit before or after this event, links to those events and even the 🚲cycle-distance between venues.
{% endhint %}

## Delete seat from cart

<mark style="color:red;">`DELETE`</mark> `https://api.voordemensen.nl/v1/:client_name/cart/:cart_id/:seat_id`

Remove a seat from the cart

#### Path Parameters

| Name         | Type   | Description                                                        |
| ------------ | ------ | ------------------------------------------------------------------ |
| seat\_id     | string | the seat\_id identifying the seat to be removed                    |
| cart\_id     | string | the cart\_id identifying this cart                                 |
| client\_name | string | the short name identifying you as a VdM client e.g. demo or fringe |

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

```
```

{% endtab %}
{% endtabs %}
