Skip to content

Commit

Permalink
Add map vote endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbmaier committed Dec 24, 2024
1 parent 9ca2ef4 commit 5a488c1
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 0 deletions.
69 changes: 69 additions & 0 deletions docs/core/maps/set-vote.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
name: Set map vote

url: https://prod.trackmania.core.nadeo.online
method: POST
route: /maps/{mapUid}/votes

audience: NadeoServices

parameters:
path:
- name: mapUid
type: string
description: The UID of the map
required: true

---

The request body contains the vote value:

```json
{
"vote": 1
}
```

---

Sets a like/dislike vote for a map as the currently authenticated user.

---

**Remarks**:

- Because this endpoint only works for the currently authenticated user, it cannot be used by a dedicated server account.
- The `vote` field can be set to `-1` for a dislike, or `1` for a like. `0` can be used to unset the vote.

---

**Example request**:

```plain
POST https://prod.trackmania.core.nadeo.online/maps/ytKTrmjtk352Ou_7IE3xHWhyj2a/votes
```

```json
{
"vote": 1
}
```

**Example response**:

```plain
null
```

If the `mapUid` is invalid, the response will contain an error message:

```json
{
"code": "C-AA-00-03",
"correlation_id": "127bd2d9070bad276a1422d9268c2d10",
"message": "There was a validation error.",
"info": [
"mapUid: This value is too long. It should have 27 characters or less."
]
}
```
59 changes: 59 additions & 0 deletions docs/core/maps/vote.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: Get map vote

url: https://prod.trackmania.core.nadeo.online
method: GET
route: /maps/{mapUid}/votes

audience: NadeoServices

parameters:
path:
- name: mapUid
type: string
description: The UID of the map
required: true

---

Gets the currently authenticated user's vote for a map.

---

**Remarks**:

- Because this endpoint only works for the currently authenticated user, it cannot be used by a dedicated server account.
- The `vote` field can be set to `-1` for a dislike, or `1` for a like. `0` can be used to unset the vote.
- The `voteDate` field in the response contains the day of the vote (i.e. the last change to the given map's vote), but not an exact timestamp.

---

**Example request**:

```plain
GET https://prod.trackmania.core.nadeo.online/maps/ytKTrmjtk352Ou_7IE3xHWhyj2a/votes
```

**Example response**:

```json
{
"accountId": "5b4d42f4-c2de-407d-b367-cbff3fe817bc",
"mapUid": "ytKTrmjtk352Ou_7IE3xHWhyj2a",
"vote": 1,
"voteDate": "2024-12-24T00:00:00+00:00"
}
```

If the `mapUid` is invalid, the response will contain an error message:

```json
{
"code": "C-AA-00-03",
"correlation_id": "60e8a3c2c6233f9408e315b31799b56b",
"message": "There was a validation error.",
"info": [
"mapUid: This value is too long. It should have 27 characters or less."
]
}
```

0 comments on commit 5a488c1

Please sign in to comment.