Skip to content

Commit

Permalink
🧑‍💻 Replace user details by LightUserResource in `LeaderboardUserRe…
Browse files Browse the repository at this point in the history
…source` (#2635)
  • Loading branch information
marhei authored Jul 3, 2024
1 parent 9ce6bdd commit 81e2708
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
14 changes: 13 additions & 1 deletion API_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,25 @@ In this we try to keep track of changes to the API.
Primarily this should document changes that are not backwards compatible or belongs to already documented endpoints.
This is to help you keep track of the changes and to help you update your code accordingly.

# 2024-06-28

The `LeaderboardUserResource` is now returning the whole `LightUserResource` for the user who created it in the `user` field.
Thus the following fields of the `LeaderboardUserResource` are now **marked as deprecated and will be removed after August 2024**.

- `id`
- `displayName`
- `username`
- `profilePicture`

This data is also available in the `user` field.

## 2024-06-01

Changed `/operator` to `/operators`

## 2024-05-31

The `StatusResource` is now returning the whole `UserResource` for the user who created it in the `userDetails` field.
The `StatusResource` is now returning the whole `LightUserResource` for the user who created it in the `userDetails` field.
Thus the following fields of the `StatusResource` are now **marked as deprecated and will be removed after August 2024**.

- `user`
Expand Down
12 changes: 7 additions & 5 deletions app/Http/Resources/LeaderboardUserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
/**
* @OA\Schema(
* title="LeaderboardUserResource",
* @OA\Property(property="username", type="string", description="username of user", example="Gertrud123"),
* @OA\Property(property="profilePicture", type="string", description="URL of the profile picture of the user", example="https://traewelling.de/@Gertrud123/picture"),
* @OA\Property(property="user", ref="#/components/schemas/LightUserResource"),
* @OA\Property(property="totalDuration", type="integer", description="duration travelled in minutes", example=6),
* @OA\Property(property="totalDistance", type="integer", description="distance travelled in meters", example=12345),
* @OA\Property(property="points", type="integer", description="points of user")
Expand All @@ -19,13 +18,16 @@ class LeaderboardUserResource extends JsonResource
{
public function toArray($request): array {
return [
'username' => $this->user->username,
'profilePicture' => ProfilePictureController::getUrl($this->user),
'id' => (int) $this->user->id, // @deprecated: remove after 2024-08
'displayName' => (string) $this->user->name, // @deprecated: remove after 2024-08
'username' => (string) $this->user->username, // @deprecated: remove after 2024-08
'profilePicture' => ProfilePictureController::getUrl($this->user), // @deprecated: remove after 2024-08
'trainDuration' => (int) $this->duration, // @deprecated: remove after 2024-08
'trainDistance' => (float) $this->distance, // @deprecated: remove after 2024-08
'user' => new LightUserResource($this->user),
'totalDuration' => (int) $this->duration,
'totalDistance' => (float) $this->distance,
'points' => (int) $this->points
'points' => (int) $this->points,
];
}
}
17 changes: 6 additions & 11 deletions storage/api-docs/api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4491,7 +4491,8 @@
"ferry",
"subway",
"tram",
"taxi"
"taxi",
"plane"
],
"example": "suburban"
},
Expand Down Expand Up @@ -4554,7 +4555,8 @@
"ferry",
"subway",
"tram",
"taxi"
"taxi",
"plane"
],
"example": "suburban"
},
Expand Down Expand Up @@ -4645,15 +4647,8 @@
"LeaderboardUserResource": {
"title": "LeaderboardUserResource",
"properties": {
"username": {
"description": "username of user",
"type": "string",
"example": "Gertrud123"
},
"profilePicture": {
"description": "URL of the profile picture of the user",
"type": "string",
"example": "https://traewelling.de/@Gertrud123/picture"
"user": {
"$ref": "#/components/schemas/LightUserResource"
},
"totalDuration": {
"description": "duration travelled in minutes",
Expand Down

0 comments on commit 81e2708

Please sign in to comment.