Skip to content

Orders_get

Luigi Minardi edited this page Mar 3, 2022 · 1 revision

Return to Orders

Get all orders

Return all the orders of the database.

Endpoint: /
Request:

After being logged in as an administrator, go to the endpoint and you'll get the response.

This endpoint is Admin Only.

If you're using postman or insomnia to check the API remember to put the token of the logged user on the header, as Authorization: Bearer <token>.

Response Body:
Response code: 200
[
    {
        "id": 1,
        "price": 5,
        "movieId": 2,
        "userId": 1,
        "date": "2022-02-24T14:42:47.000Z",
        "createdAt": "2022-02-27T11:27:02.000Z",
        "updatedAt": "2022-02-27T11:27:02.000Z"
    },
    {
        "id": 2,
        "price": 5,
        "movieId": 2,
        "userId": 1,
        "date": "2022-02-24T14:42:47.000Z",
        "createdAt": "2022-02-27T11:27:02.000Z",
        "updatedAt": "2022-02-27T11:27:02.000Z"
    },
    {
        "id": 3,
        "price": 5,
        "movieId": 2,
        "userId": 2,
        "date": "2022-02-24T14:42:47.000Z",
        "createdAt": "2022-02-27T11:40:10.000Z",
        "updatedAt": "2022-02-27T11:40:10.000Z"
    }
]

Get orders with rating > 6

Return the orders with movies that have a rating > 6, its rate and name, the users that made the order, his nickname and email.

Endpoint: /top-rated
Request:

After being logged in as an administrator, go to the endpoint and you'll get the response.

This endpoint is Admin Only.

If you're using postman or insomnia to check the API remember to put the token of the logged user on the header, as Authorization: Bearer <token>.

Response Body:
Response code: 200
[
	{
		"customer": "Adult",
		"nick": "adult",
		"mail": "[email protected]",
		"movie": "My SFW Movie",
		"rating": 7
	},
	{
		"customer": "Adult",
		"nick": "adult",
		"mail": "[email protected]",
		"movie": "My SFW Movie",
		"rating": 7
	},
	{
		"customer": "Underage",
		"nick": "kid",
		"mail": "[email protected]",
		"movie": "My SFW Movie",
		"rating": 7
	}
]

Get order with given pk

Return the order with the passed pk.

Endpoint: /:pk
Request:

After being logged in, go to the endpoint and you'll get the response.

If you're using postman or insomnia to check the API remember to put the token of the logged user on the header, as Authorization: Bearer <token>.

Response Body:
Response code: 200
{
    "id": 1,
    "price": 5,
    "movieId": 2,
    "userId": 1,
    "date": "2022-02-24T14:42:47.000Z",
    "createdAt": "2022-02-27T11:27:02.000Z",
    "updatedAt": "2022-02-27T11:27:02.000Z"
}