From a74ad0f06cbca1544573219cfc045749d948ee0d Mon Sep 17 00:00:00 2001 From: Aleksandra Kozubal <104600942+AleksandraKozubal@users.noreply.github.com> Date: Tue, 14 May 2024 09:51:09 +0200 Subject: [PATCH] - add Felyx provider (#239) add felyx Co-authored-by: Jakub Kermes <114694305+JakubKermes@users.noreply.github.com> --- app/Importers/FelyxDataImporter.php | 66 +++++++++++++++++++++++++++ app/Jobs/FelyxDataImporterJob.php | 15 ++++++ app/Services/DataImporterService.php | 2 + database/seeders/ProviderSeeder.php | 2 + public/providers/felyx.png | Bin 0 -> 2371 bytes 5 files changed, 85 insertions(+) create mode 100644 app/Importers/FelyxDataImporter.php create mode 100644 app/Jobs/FelyxDataImporterJob.php create mode 100644 public/providers/felyx.png diff --git a/app/Importers/FelyxDataImporter.php b/app/Importers/FelyxDataImporter.php new file mode 100644 index 00000000..ada2e4ef --- /dev/null +++ b/app/Importers/FelyxDataImporter.php @@ -0,0 +1,66 @@ +client->get("https://felyx.com/products/our-locations/"); + $html = $response->getBody()->getContents(); + } catch (GuzzleException) { + $this->createImportInfoDetails("400", self::getProviderName()); + $this->stopExecution = true; + + return $this; + } + + $crawler = new Crawler($html); + $this->sections = $crawler->filter("p.styles_cityName__XdcTJ"); + + if (count($this->sections) === 0) { + $this->createImportInfoDetails("204", self::getProviderName()); + + $this->stopExecution = true; + } + + return $this; + } + + public function transform(): void + { + if ($this->stopExecution) { + return; + } + + $existingCityProviders = []; + + foreach ($this->sections as $section) { + $cityName = $section->nodeValue; + $countryNode = $section->parentNode->parentNode->parentNode; + + foreach ($countryNode->childNodes as $country) { + if ($country->nodeName === "h3") { + $countryName = trim($country->nodeValue); + + $provider = $this->load($cityName, $countryName, $lat = "", $long = "", $this->services); + + if ($provider !== "") { + $existingCityProviders[] = $provider; + } + } + } + } + $this->deleteMissingProviders(self::getProviderName(), $existingCityProviders); + } +} diff --git a/app/Jobs/FelyxDataImporterJob.php b/app/Jobs/FelyxDataImporterJob.php new file mode 100644 index 00000000..aee21568 --- /dev/null +++ b/app/Jobs/FelyxDataImporterJob.php @@ -0,0 +1,15 @@ +setImportInfo($this->importInfoId)->extract()->transform(); + } +} diff --git a/app/Services/DataImporterService.php b/app/Services/DataImporterService.php index 53753e63..c147e331 100644 --- a/app/Services/DataImporterService.php +++ b/app/Services/DataImporterService.php @@ -13,6 +13,7 @@ use App\Jobs\BoltDataImporterJob; use App\Jobs\DocomoDataImporterJob; use App\Jobs\DottDataImporterJob; +use App\Jobs\FelyxDataImporterJob; use App\Jobs\GoSharingDataImporterJob; use App\Jobs\HopDataImporterJob; use App\Jobs\HoppDataImporterJob; @@ -55,6 +56,7 @@ public function run(string $whoRunsIt = "admin"): void new BitMobilityDataImporterJob($this->importInfoId), new BoltDataImporterJob($this->importInfoId), new DottDataImporterJob($this->importInfoId), + new FelyxDataImporterJob($this->importInfoId), new HulajDataImporterJob($this->importInfoId), new LimeDataImporterJob($this->importInfoId), new HoppDataImporterJob($this->importInfoId), diff --git a/database/seeders/ProviderSeeder.php b/database/seeders/ProviderSeeder.php index 786e5660..fd6aa5a4 100644 --- a/database/seeders/ProviderSeeder.php +++ b/database/seeders/ProviderSeeder.php @@ -13,6 +13,7 @@ use App\Importers\BoltDataImporter; use App\Importers\DocomoDataImporter; use App\Importers\DottDataImporter; +use App\Importers\FelyxDataImporter; use App\Importers\GoSharingDataImporter; use App\Importers\HopDataImporter; use App\Importers\HoppDataImporter; @@ -49,6 +50,7 @@ public function run(): void ["name" => BoltDataImporter::getProviderName(), "color" => "#24f0a0", "url" => "https://bolt.eu/pl-pl/scooters/", "android_url" => "https://play.google.com/store/apps/details?id=ee.mtakso.client&hl=pl&gl=US", "ios_url" => "https://apps.apple.com/pl/app/bolt-przejazdy-hulajnogi/id675033630?l=pl"], ["name" => DocomoDataImporter::getProviderName(), "color" => "#faf9f6", "url" => "https://docomo-cycle.jp/?lang=en", "android_url" => "https://play.google.com/store/apps/details?id=jp.docomo_cycle.bikeshare", "ios_url" => "https://apps.apple.com/jp/app/id1475196715"], ["name" => DottDataImporter::getProviderName(), "color" => "#f5c604", "url" => "https://ridedott.com/", "android_url" => "https://play.google.com/store/apps/details?id=com.ridedott.rider&pli=1", "ios_url" => "https://apps.apple.com/us/app/dott-unlock-your-city/id1440301673"], + ["name" => FelyxDataImporter::getProviderName(), "color" => "#044a27", "url" => "https://felyx.com/", "android_url" => "https://play.google.com/store/apps/details?id=com.felyx.android", "ios_url" => "https://apps.apple.com/us/app/felyx/id1250107307"], ["name" => GoSharingDataImporter::getProviderName(), "color" => "#81BB28", "url" => "https://nl.go-sharing.com/en/locations/", "android_url" => "https://play.google.com/store/apps/details?id=nl.gosharing.gourban.app&hl=pl&gl=US", "ios_url" => "https://apps.apple.com/pl/app/go-sharing/id1477465763?l=pl"], ["name" => HopDataImporter::getProviderName(), "color" => "#ea1821", "url" => "https://hop.bike/en/", "android_url" => "https://play.google.com/store/apps/details?id=com.hoplagit.rider&hl=pl&gl=US", "ios_url" => "https://apps.apple.com/pl/app/hop-enjoy-the-city/id1487640704?l=pl"], ["name" => HoppDataImporter::getProviderName(), "color" => "#1ce5be", "url" => "https://hopp.bike/", "android_url" => "https://play.google.com/store/apps/details?id=bike.hopp", "ios_url" => "https://apps.apple.com/us/app/hopp-scooters/id1471324642?ls=1"], diff --git a/public/providers/felyx.png b/public/providers/felyx.png new file mode 100644 index 0000000000000000000000000000000000000000..b17c74864d0070b5a5858273e9ec5adb9d7de2b2 GIT binary patch literal 2371 zcmV-J3B2}+P) z3TY)XGh4ug7Sa~CEK6_CbDO!%oq5kW@0q!C?>F8vFx-1*-uFH4`@GLt=A1L%*V88) z0f7<_=qbTwFc}c&6NnW^PznNpSf#)kj0R!_4wQmGAXX``2BU#kfdi!=5QtR@ti97{ ztyY^0&n|L!cV|ye&wWKB2*fIiUooS%TgUiB#uvP0nHx1Ksy z@j$F*c!0-exN=PLDll)#b&7bI3NH}zc$oN9o42CG^6tOW0cst!$pvC%h~>)5806ud zq!ut_ufyKQc=+TlH?cI12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