Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧑‍💻 Replace user details by LightUserResource in LeaderboardUserResource #2635

Merged
merged 17 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
];
}
}
2 changes: 1 addition & 1 deletion config/l5-swagger.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@
*/
'constants' => [
'L5_SWAGGER_CONST_HOST' => env('L5_SWAGGER_CONST_HOST', 'http://localhost:8000'),
'L5_SWAGGER_CONST_ENDPOINT' => env('L5_SWAGGER_CONST_HOST', 'http://localhost:8000') . '/api/v1',
marhei marked this conversation as resolved.
Show resolved Hide resolved
'L5_SWAGGER_CONST_ENDPOINT' => env('L5_SWAGGER_CONST_HOST', 'http://localhost:8000'),
],
],
];
25 changes: 10 additions & 15 deletions storage/api-docs/api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"description": "Production Server"
},
{
"url": "https://traewelling.de/api/v1/api/v1",
"url": "http://localhost:8000",
marhei marked this conversation as resolved.
Show resolved Hide resolved
"description": "This instance"
}
],
Expand Down 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 Expand Up @@ -5967,9 +5962,9 @@
"scheme": "https",
"flows": {
"authorizationCode": {
"authorizationUrl": "https://traewelling.de/api/v1/oauth/authorize",
"tokenUrl": "https://traewelling.de/api/v1/oauth/token",
"refreshUrl": "https://traewelling.de/api/v1/auth/refresh",
"authorizationUrl": "http://localhost:8000/oauth/authorize",
"tokenUrl": "http://localhost:8000/oauth/token",
"refreshUrl": "http://localhost:8000/auth/refresh",
"scopes": {
"read-statuses": "see all statuses",
"read-notifications": "see your notifications",
Expand Down
Loading