From b165953b12fa093ac0aaa9d7e7a0145076975e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C5=A0pa=C4=8Dek?= Date: Fri, 24 Nov 2023 01:39:42 +0100 Subject: [PATCH] Revert "I don't understand why but for this 'res' source, the country code is returned as "1", yes a string, instead of "cz", so let's deal with that" This reverts commit 8524ef3e57e2f6806f5a6142f9168cd9dd9a87b1 from #244 which was a fix for #242 --- site/app/CompanyInfo/CompanyRegisterAres.php | 21 ++------------------ 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/site/app/CompanyInfo/CompanyRegisterAres.php b/site/app/CompanyInfo/CompanyRegisterAres.php index 9adabe8fa..3659a47d2 100644 --- a/site/app/CompanyInfo/CompanyRegisterAres.php +++ b/site/app/CompanyInfo/CompanyRegisterAres.php @@ -61,9 +61,8 @@ public function getDetails(string $companyId): CompanyInfoDetails 'psc' => Expect::int(), 'kodStatu' => Expect::string(), ])->otherItems(), - 'primarniZdroj' => Expect::string(), ])->otherItems(); - /** @var object{ico:string, dic:string|null, obchodniJmeno:string, sidlo:object{nazevObce:string, nazevUlice:string, cisloDomovni:int, cisloOrientacni:int, cisloOrientacniPismeno:string, psc:int, kodStatu:string}, primarniZdroj:string|null} $data */ + /** @var object{ico:string, dic:string|null, obchodniJmeno:string, sidlo:object{nazevObce:string, nazevUlice:string, cisloDomovni:int, cisloOrientacni:int, cisloOrientacniPismeno:string, psc:int, kodStatu:string}} $data */ $data = $this->schemaProcessor->process($schema, Json::decode($content)); } catch (JsonException | ValidationException $e) { throw new CompanyInfoException($e->getMessage(), previous: $e); @@ -85,7 +84,7 @@ public function getDetails(string $companyId): CompanyInfoDetails $streetAndNumber, $data->sidlo->nazevObce, (string)$data->sidlo->psc, - $this->resolveCountryCode($data->primarniZdroj, $data->sidlo->kodStatu, $companyId), + strtolower($data->sidlo->kodStatu), ); } @@ -123,20 +122,4 @@ private function formatStreet(?string $city, ?string $street, ?int $houseNumber, return $result; } - - /** - * @throws CompanyInfoException - */ - private function resolveCountryCode(?string $source, string $code, string $companyId): string - { - if ($source === 'res') { - if ($code === '1') { - return 'cz'; - } else { - throw new CompanyInfoException("Invalid country code {$code} from source {$source} for company {$companyId}"); - } - } - return strtolower($code); - } - }