Eldorado : Added the minimum stock threshold
It now look at all of the offers of the first page and select the one matching the criterias
This commit is contained in:
@@ -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, ",", " ");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user