Skip to content

Commit 6cdaa12

Browse files
authored
♻️ deprecate additional field in CheckinSuccessResource (#4553)
1 parent 7d5030c commit 6cdaa12

File tree

7 files changed

+31
-25
lines changed

7 files changed

+31
-25
lines changed

API_CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Check back here regularly to stay ahead of removals.
1414

1515
| Announced | What? | Safe until | PR |
1616
|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|---------------------------------------------------------------|
17+
| 2026-03-07 | `CheckinSuccessResource.points.additional` is always `null` and deprecated | 2026-09-30 | [#4553](https://github.com/Traewelling/traewelling/pull/4553) |
1718
| 2026-03-07 | `DepartureResource.destination` is deprecated → use `direction` instead | 2026-09-30 | [#4552](https://github.com/Traewelling/traewelling/pull/4552) |
1819
| 2026-03-07 | `DepartureResource.delay` is deprecated → use `when`/`plannedWhen` difference instead | 2026-09-30 | [#4552](https://github.com/Traewelling/traewelling/pull/4552) |
1920
| 2026-03-07 | `DepartureResource` HAFAS-compat fields deprecated: `provenance`, `remarks`, `origin`, `currentTripPosition`, `loadFactor`, `stop.products`, `line.public`, `line.adminCode`, `line.productName`, `line.product`, `line.operator` | 2026-09-30 | [#4552](https://github.com/Traewelling/traewelling/pull/4552) |
@@ -33,6 +34,8 @@ Check back here regularly to stay ahead of removals.
3334

3435
# 2026-03-07
3536

37+
The `CheckinSuccessResource.points.additional` field is now **deprecated** (always `null`) and will be removed after **2026-09-30**.
38+
3639
The following fields of `DepartureResource` are now **deprecated** and will be removed after **2026-09-30**:
3740

3841
- `destination` → use `direction` for the destination name

app/Dto/PointCalculation.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ class PointCalculation
1010
{
1111
public readonly int $points;
1212

13-
public readonly int $basePoints;
13+
public readonly int $base;
1414

15-
public readonly int $distancePoints;
15+
public readonly int $distance;
1616

1717
public readonly PointReason $reason;
1818

1919
public readonly float $factor;
2020

2121
public function __construct(
2222
int $points,
23-
int $basePoints,
24-
int $distancePoints,
23+
int $base,
24+
int $distance,
2525
PointReason $reason,
2626
float $factor,
2727
) {
2828
$this->points = $points;
29-
$this->basePoints = $basePoints;
30-
$this->distancePoints = $distancePoints;
29+
$this->base = $base;
30+
$this->distance = $distance;
3131
$this->reason = $reason;
3232
$this->factor = $factor;
3333
}

app/Http/Controllers/Backend/Transport/PointsCalculationController.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,24 @@ public static function calculatePoints(
3939
$distance = ceil($distanceInMeter / 10000);
4040

4141
return self::calculatePointsWithReason(
42-
basePoints: $base,
43-
distancePoints: $distance,
42+
base: $base,
43+
distance: $distance,
4444
pointReason: self::getReason($departure, $arrival, $forceCheckin, $tripSource, $timestampOfView),
4545
);
4646
}
4747

4848
#[Pure]
4949
private static function calculatePointsWithReason(
50-
float $basePoints,
51-
float $distancePoints,
50+
float $base,
51+
float $distance,
5252
PointReason $pointReason
5353
): PointCalculation {
5454
$factor = self::getFactorByReason($pointReason);
5555

5656
return new PointCalculation(
57-
points: self::getPointsByReason($pointReason, ($basePoints + $distancePoints), $factor),
58-
basePoints: $basePoints,
59-
distancePoints: $distancePoints,
57+
points: self::getPointsByReason($pointReason, ($base + $distance), $factor),
58+
base: $base,
59+
distance: $distance,
6060
reason: $pointReason,
6161
factor: $factor,
6262
);
@@ -66,8 +66,8 @@ private static function returnZeroPoints(): PointCalculation
6666
{
6767
return new PointCalculation(
6868
points: 0,
69-
basePoints: 0,
70-
distancePoints: 0,
69+
base: 0,
70+
distance: 0,
7171
reason: PointReason::POINTS_DISABLED,
7272
factor: 0,
7373
);

app/Http/Resources/CheckinSuccessResource.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
properties: [
2626
new OA\Property(property: 'points', description: 'points', type: 'integer', example: 1),
2727
new OA\Property(property: 'calculation', ref: '#/components/schemas/PointsCalculation'),
28-
new OA\Property(property: 'additional', description: 'extra points that can be given', type: 'array', items: new OA\Items(), nullable: true),
28+
new OA\Property(property: 'additional', description: 'Deprecated. Always null.', type: 'array', items: new OA\Items(), nullable: true, deprecated: true),
2929
],
3030
)]
3131
#[OA\Schema(
@@ -56,16 +56,15 @@ public function toArray($request): array
5656
/** @var CheckinSuccessDto $this */
5757
return [
5858
'status' => new StatusResource($this->status),
59-
// ToDo: Rewrite ['points'] so the DTO will match the documented structure -> non-breaking api change
6059
'points' => [
6160
'points' => $this->pointCalculation->points,
6261
'calculation' => [
63-
'base' => $this->pointCalculation->basePoints,
64-
'distance' => $this->pointCalculation->distancePoints,
62+
'base' => $this->pointCalculation->base,
63+
'distance' => $this->pointCalculation->distance,
6564
'factor' => $this->pointCalculation->factor,
6665
'reason' => $this->pointCalculation->reason->value,
6766
],
68-
'additional' => null, // unused old attribute (not removed so this isn't breaking)
67+
'additional' => null, // @deprecated - remove after 2026-09-30
6968
],
7069
'alsoOnThisConnection' => StatusResource::collection($this->alsoOnThisConnection),
7170
];

app/Http/Resources/StationResource.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public function toArray($request): array
5252
'name' => $this->name,
5353
'latitude' => $this->latitude,
5454
'longitude' => $this->longitude,
55-
'ibnr' => null, // @deprecated - remove after 2025-09
56-
'rilIdentifier' => null, // @deprecated - remove after 2025-09
55+
'ibnr' => null, // @deprecated - remove after 2026-09-30
56+
'rilIdentifier' => null, // @deprecated - remove after 2026-09-30
5757
'areas' => AreaResource::collection($this->whenLoaded('areas')),
5858
'identifiers' => StationIdentifierResource::collection($this->whenLoaded('stationIdentifiers')),
5959
];

resources/types/Api.gen.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,10 @@ export interface Points {
737737
*/
738738
points?: number;
739739
calculation?: PointsCalculation;
740-
/** extra points that can be given */
740+
/**
741+
* Deprecated. Always null.
742+
* @deprecated
743+
*/
741744
additional?: any[] | null;
742745
}
743746

storage/api-docs/api-docs.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6517,10 +6517,11 @@
65176517
"$ref": "#/components/schemas/PointsCalculation"
65186518
},
65196519
"additional": {
6520-
"description": "extra points that can be given",
6520+
"description": "Deprecated. Always null.",
65216521
"type": "array",
65226522
"items": {},
6523-
"nullable": true
6523+
"nullable": true,
6524+
"deprecated": true
65246525
}
65256526
},
65266527
"type": "object"

0 commit comments

Comments
 (0)