diff --git a/app/Importers/WheeMoveDataImporter.php b/app/Importers/WheeMoveDataImporter.php new file mode 100644 index 00000000..ab8e78d6 --- /dev/null +++ b/app/Importers/WheeMoveDataImporter.php @@ -0,0 +1,67 @@ +client->get("https://www.wheemove.com/"); + $html = $response->getBody()->getContents(); + } catch (GuzzleException) { + $this->createImportInfoDetails("400", self::getProviderName()); + $this->stopExecution = true; + } + + $crawler = new Crawler($html); + + $this->sections = $crawler->filter('section[data-id="4b8f82b"], section[data-id="59def84"]'); + + if (count($this->sections) === 0) { + $this->createImportInfoDetails("204", self::getProviderName()); + + $this->stopExecution = true; + } + + return $this; + } + + public function transform(): void + { + $existingCityProviders = []; + + if ($this->stopExecution) { + return; + } + $cityNames = []; + + $firstSectionNames = $this->sections->first()->filter('span[class="elementor-icon-list-text"]'); + $lastSectionNames = $this->sections->last()->filter('span[class="elementor-icon-list-text"]'); + + foreach ([$firstSectionNames, $lastSectionNames] as $sectionNames) { + foreach ($sectionNames as $name) { + $cityNames[] = $name->nodeValue; + } + } + + foreach ($cityNames as $name) { + $provider = $this->load($name, self::COUNTRY_NAME); + + if ($provider !== "") { + $existingCityProviders[] = $provider; + } + } + + $this->deleteMissingProviders(self::getProviderName(), $existingCityProviders); + } +} diff --git a/app/Jobs/WheeMoveDataImporterJob.php b/app/Jobs/WheeMoveDataImporterJob.php new file mode 100644 index 00000000..a3d4752e --- /dev/null +++ b/app/Jobs/WheeMoveDataImporterJob.php @@ -0,0 +1,15 @@ +setImportInfo($this->importInfoId)->extract()->transform(); + } +} diff --git a/app/Services/DataImporterService.php b/app/Services/DataImporterService.php index 3305e807..50ad298d 100644 --- a/app/Services/DataImporterService.php +++ b/app/Services/DataImporterService.php @@ -22,6 +22,7 @@ use App\Jobs\UrentDataImporterJob; use App\Jobs\VeoDataImporterJob; use App\Jobs\VoiDataImporterJob; +use App\Jobs\WheeMoveDataImporterJob; use App\Jobs\WindDataImporterJob; use App\Jobs\ZwingsDataImporterJob; use App\Models\ImportInfo; @@ -60,6 +61,7 @@ public function run(string $whoRunsIt = "admin"): void new VoiDataImporterJob($this->importInfoId), new VeoDataImporterJob($this->importInfoId), new WindDataImporterJob($this->importInfoId), + new WheeMoveDataImporterJob($this->importInfoId), new ZwingsDataImporterJob($this->importInfoId), ])->finally(function (): void { ImportInfo::query()->where("id", $this->importInfoId)->update([ diff --git a/database/seeders/ProviderSeeder.php b/database/seeders/ProviderSeeder.php index 050f94c7..5796543e 100644 --- a/database/seeders/ProviderSeeder.php +++ b/database/seeders/ProviderSeeder.php @@ -22,6 +22,7 @@ use App\Importers\UrentDataImporter; use App\Importers\VeoDataImporter; use App\Importers\VoiDataImporter; +use App\Importers\WheeMoveDataImporter; use App\Importers\WindDataImporter; use App\Importers\ZwingsDataImporter; use App\Models\Provider; @@ -52,6 +53,7 @@ public function run(): void ["name" => RydeDataImporter::getProviderName(), "color" => "#4dcb1f"], ["name" => VeoDataImporter::getProviderName(), "color" => "#000000"], ["name" => WindDataImporter::getProviderName(), "color" => "#fffa00"], + ["name" => WheeMoveDataImporter::getProviderName(), "color" => "#31682d"], ]; foreach ($providers as $provider) { diff --git a/public/providers/wheemove.png b/public/providers/wheemove.png new file mode 100644 index 00000000..8fdfadf7 Binary files /dev/null and b/public/providers/wheemove.png differ diff --git a/readme.md b/readme.md index e1dc62f0..70416e36 100644 --- a/readme.md +++ b/readme.md @@ -19,6 +19,7 @@ 1. Urent 1. Veo 1. Voi +1. WheeMove 1. Zwings ### Local development