Skip to content

Commit 54ea0f3

Browse files
committed
Update public cocktail schema
1 parent 2234e74 commit 54ea0f3

File tree

4 files changed

+101
-76
lines changed

4 files changed

+101
-76
lines changed

app/Http/Resources/Public/CocktailResource.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
new OAT\Property(property: 'glass', type: 'string', nullable: true, example: 'Highball glass', description: 'Type of glass used for the cocktail'),
3232
new OAT\Property(property: 'utensils', type: 'array', items: new OAT\Items(type: 'string'), description: 'Utensils used for preparing the cocktail'),
3333
new OAT\Property(property: 'method', type: 'string', nullable: true, example: 'Shaken', description: 'Method of preparation for the cocktail'),
34+
new OAT\Property(property: 'method_dilution_percentage', type: 'number', nullable: true, example: '12', description: 'Dilution percentage associated with the preparation method'),
35+
new OAT\Property(property: 'volume_ml', type: 'number', nullable: true, example: '120', description: 'Total volume of the cocktail in milliliters'),
3436
new OAT\Property(property: 'created_at', type: 'string', format: 'date-time', example: '2023-10-01T12:00:00Z', description: 'Date and time when the cocktail was created'),
37+
new OAT\Property(property: 'in_bar_shelf', type: 'boolean', example: true, description: 'Indicates if the cocktail can be made in the current bar'),
3538
new OAT\Property(property: 'abv', type: 'number', format: 'float', nullable: true, example: 0.15, description: 'Alcohol by volume percentage of the cocktail'),
3639
new OAT\Property(property: 'year', type: 'integer', nullable: true, example: 2023, description: 'Year the cocktail was created or published'),
3740
new OAT\Property(
@@ -98,7 +101,10 @@ public function toArray($request)
98101
'glass' => $this->glass->name ?? null,
99102
'utensils' => $this->utensils->pluck('name'),
100103
'method' => $this->method->name ?? null,
104+
'method_dilution_percentage' => $this->method->dilution_percentage ?? null,
105+
'volume_ml' => $this->getVolume(),
101106
'created_at' => $this->created_at->toAtomString(),
107+
'in_bar_shelf' => $this->inBarShelf(),
102108
'abv' => $this->abv,
103109
'year' => $this->year,
104110
'ingredients' => $this->ingredients->map(function (CocktailIngredient $cocktailIngredient) {

app/Models/ValueObjects/AmountValueObject.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function convertTo(UnitValueObject $toUnits): self
3232
$convertedMaxAmount = Converter::convertAmount(AmountValue::from($this->amountMax), $fromUnitsEnum, $toUnitsEnum);
3333
}
3434

35-
return new self($convertedMinAmount->getValue(), $toUnits, $convertedMaxAmount?->getValue());
35+
return new self(round($convertedMinAmount->getValue(), 4), $toUnits, $convertedMaxAmount?->getValue());
3636
}
3737

3838
public function __toString(): string

0 commit comments

Comments
 (0)