Eldorado : Added the minimum stock threshold
All checks were successful
Test, build and push image to registry / phpunit-tests (push) Successful in 3m25s
Test, build and push image to registry / build-image (push) Successful in 2m59s

It now look at all of the offers of the first page and select the one matching the criterias
This commit is contained in:
2025-12-20 16:20:07 +01:00
parent 48fdc2f6f0
commit 5e6164016c
5 changed files with 223 additions and 48 deletions

View File

@@ -7,14 +7,18 @@ use App\Notification\NotificationBody;
class EldoradoRobuxPriceNotificationBody extends NotificationBody {
private float $price;
private float $threshold;
private float $priceThreshold;
private int $stock;
private int|null $stockThreshold;
private string $link;
public function __construct(float $price, float $threshold, string $link) {
public function __construct(float $price, float $priceThreshold, int $stock, int|null $stockThreshold, string $link) {
parent::__construct();
$this->price = $price;
$this->threshold = $threshold;
$this->priceThreshold = $priceThreshold;
$this->stock = $stock;
$this->stockThreshold = $stockThreshold;
$this->link = $link;
}
@@ -22,13 +26,21 @@ class EldoradoRobuxPriceNotificationBody extends NotificationBody {
* @inheritDoc
*/
public function toMarkdownString(): string {
return "Le prix des Robux sur Eldorado est actuellement de **" . number_format($this->price, 5, ",", " ") . " €**/Robux, ce qui est inférieur ou égal au seuil de **" . number_format($this->threshold, 5, ",", " ") . " €**.\n\n[Voir l'offre sur Eldorado]( " . $this->link . " )";
return "Le prix des Robux sur Eldorado est actuellement de **" . $this->floatFormat($this->price) . " €**/Robux, ce qui est inférieur ou égal au seuil de **" . $this->floatFormat($this->priceThreshold) . " €**.\nLe stock est de **" . $this->intFormat($this->stock) . "**" . ($this->stockThreshold !== null ? " (seuil : **" . $this->intFormat($this->stockThreshold) . "**)" : "") . "\n[Voir l'offre sur Eldorado]( " . $this->link . " )";
}
/**
* @inheritDoc
*/
public function toString(): string {
return "Le prix des Robux sur Eldorado est actuellement de " . number_format($this->price, 5, ",", " ") . " €/Robux, ce qui est inférieur ou égal au seuil de " . number_format($this->threshold, 5, ",", " ") . " €.\n\nVoir l'offre sur Eldorado : " . $this->link;
return "Le prix des Robux sur Eldorado est actuellement de " . $this->floatFormat($this->price) . " €/Robux, ce qui est inférieur ou égal au seuil de " . $this->floatFormat($this->priceThreshold) . " €.\nLe stock est de " . $this->intFormat($this->stock) . ($this->stockThreshold !== null ? " (seuil : " . $this->intFormat($this->stockThreshold) . ")" : "") . "\nVoir l'offre sur Eldorado : " . $this->link;
}
private function floatFormat(float $number): string {
return number_format($number, 5, ",", " ");
}
private function intFormat(int $number): string {
return number_format($number, 0, ",", " ");
}
}