|
| 1 | +<?php |
| 2 | +/* |
| 3 | + * This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony). |
| 4 | + * |
| 5 | + * Copyright (C) 2019 - 2026 Jan Böhmer (https://github.com/jbtronics) |
| 6 | + * |
| 7 | + * This program is free software: you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU Affero General Public License as published |
| 9 | + * by the Free Software Foundation, either version 3 of the License, or |
| 10 | + * (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU Affero General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU Affero General Public License |
| 18 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 19 | + */ |
| 20 | + |
| 21 | +declare(strict_types=1); |
| 22 | + |
| 23 | + |
| 24 | +namespace App\Settings\InfoProviderSystem; |
| 25 | + |
| 26 | +use Symfony\Contracts\Translation\TranslatableInterface; |
| 27 | +use Symfony\Contracts\Translation\TranslatorInterface; |
| 28 | + |
| 29 | +enum ConradShopIDs: string implements TranslatableInterface |
| 30 | +{ |
| 31 | + case COM_B2B = 'HP_COM_B2B'; |
| 32 | + case DE_B2B = 'CQ_DE_B2B'; |
| 33 | + case AT_B2C = 'CQ_AT_B2C'; |
| 34 | + case CH_B2C = 'CQ_CH_B2C'; |
| 35 | + case SE_B2B = 'HP_SE_B2B'; |
| 36 | + case HU_B2C = 'CQ_HU_B2C'; |
| 37 | + case CZ_B2B = 'HP_CZ_B2B'; |
| 38 | + case SI_B2B = 'HP_SI_B2B'; |
| 39 | + case SK_B2B = 'HP_SK_B2B'; |
| 40 | + case BE_B2B = 'HP_BE_B2B'; |
| 41 | + case DE_B2C = 'CQ_DE_B2C'; |
| 42 | + case PL_B2B = 'HP_PL_B2B'; |
| 43 | + case NL_B2B = 'CQ_NL_B2B'; |
| 44 | + case DK_B2B = 'HP_DK_B2B'; |
| 45 | + case IT_B2B = 'HP_IT_B2B'; |
| 46 | + case NL_B2C = 'CQ_NL_B2C'; |
| 47 | + case FR_B2B = 'HP_FR_B2B'; |
| 48 | + case AT_B2B = 'CQ_AT_B2B'; |
| 49 | + case HR_B2B = 'HP_HR_B2B'; |
| 50 | + |
| 51 | + |
| 52 | + public function trans(TranslatorInterface $translator, ?string $locale = null): string |
| 53 | + { |
| 54 | + return match ($this) { |
| 55 | + self::DE_B2B => "conrad.de (B2B)", |
| 56 | + self::AT_B2C => "conrad.at (B2C)", |
| 57 | + self::CH_B2C => "conrad.ch (B2C)", |
| 58 | + self::SE_B2B => "conrad.se (B2B)", |
| 59 | + self::HU_B2C => "conrad.hu (B2C)", |
| 60 | + self::CZ_B2B => "conrad.cz (B2B)", |
| 61 | + self::SI_B2B => "conrad.si (B2B)", |
| 62 | + self::SK_B2B => "conrad.sk (B2B)", |
| 63 | + self::BE_B2B => "conrad.be (B2B)", |
| 64 | + self::DE_B2C => "conrad.de (B2C)", |
| 65 | + self::PL_B2B => "conrad.pl (B2B)", |
| 66 | + self::NL_B2B => "conrad.nl (B2B)", |
| 67 | + self::DK_B2B => "conrad.dk (B2B)", |
| 68 | + self::IT_B2B => "conrad.it (B2B)", |
| 69 | + self::NL_B2C => "conrad.nl (B2C)", |
| 70 | + self::FR_B2B => "conrad.fr (B2B)", |
| 71 | + self::COM_B2B => "conrad.com (B2B)", |
| 72 | + self::AT_B2B => "conrad.at (B2B)", |
| 73 | + self::HR_B2B => "conrad.hr (B2B)", |
| 74 | + }; |
| 75 | + } |
| 76 | + |
| 77 | + public function getDomain(): string |
| 78 | + { |
| 79 | + return 'conrad.' . $this->getDomainEnd(); |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * Retrieves the API root URL for this shop ID. e.g. https://api.conrad.de |
| 84 | + * @return string |
| 85 | + */ |
| 86 | + public function getAPIRoot(): string |
| 87 | + { |
| 88 | + return 'https://api.' . $this->getDomain(); |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * Returns the shop ID value used in the API requests. e.g. 'CQ_DE_B2B' |
| 93 | + * @return string |
| 94 | + */ |
| 95 | + public function getShopID(): string |
| 96 | + { |
| 97 | + return $this->value; |
| 98 | + } |
| 99 | + |
| 100 | + public function getDomainEnd(): string |
| 101 | + { |
| 102 | + return match ($this) { |
| 103 | + self::DE_B2B, self::DE_B2C => 'de', |
| 104 | + self::AT_B2B, self::AT_B2C => 'at', |
| 105 | + self::CH_B2C => 'ch', |
| 106 | + self::SE_B2B => 'se', |
| 107 | + self::HU_B2C => 'hu', |
| 108 | + self::CZ_B2B => 'cz', |
| 109 | + self::SI_B2B => 'si', |
| 110 | + self::SK_B2B => 'sk', |
| 111 | + self::BE_B2B => 'be', |
| 112 | + self::PL_B2B => 'pl', |
| 113 | + self::NL_B2B, self::NL_B2C => 'nl', |
| 114 | + self::DK_B2B => 'dk', |
| 115 | + self::IT_B2B => 'it', |
| 116 | + self::FR_B2B => 'fr', |
| 117 | + self::COM_B2B => 'com', |
| 118 | + self::HR_B2B => 'hr', |
| 119 | + }; |
| 120 | + } |
| 121 | + |
| 122 | + public function getLanguage(): string |
| 123 | + { |
| 124 | + return match ($this) { |
| 125 | + self::DE_B2B, self::DE_B2C, self::AT_B2B, self::AT_B2C => 'de', |
| 126 | + self::CH_B2C => 'de', |
| 127 | + self::SE_B2B => 'sv', |
| 128 | + self::HU_B2C => 'hu', |
| 129 | + self::CZ_B2B => 'cs', |
| 130 | + self::SI_B2B => 'sl', |
| 131 | + self::SK_B2B => 'sk', |
| 132 | + self::BE_B2B => 'nl', |
| 133 | + self::PL_B2B => 'pl', |
| 134 | + self::NL_B2B, self::NL_B2C => 'nl', |
| 135 | + self::DK_B2B => 'da', |
| 136 | + self::IT_B2B => 'it', |
| 137 | + self::FR_B2B => 'fr', |
| 138 | + self::COM_B2B => 'en', |
| 139 | + self::HR_B2B => 'hr', |
| 140 | + }; |
| 141 | + } |
| 142 | + |
| 143 | + /** |
| 144 | + * Retrieves the customer type for this shop ID. e.g. 'b2b' or 'b2c' |
| 145 | + * @return string 'b2b' or 'b2c' |
| 146 | + */ |
| 147 | + public function getCustomerType(): string |
| 148 | + { |
| 149 | + return match ($this) { |
| 150 | + self::DE_B2B, self::AT_B2B, self::SE_B2B, self::CZ_B2B, self::SI_B2B, |
| 151 | + self::SK_B2B, self::BE_B2B, self::PL_B2B, self::NL_B2B, self::DK_B2B, |
| 152 | + self::IT_B2B, self::FR_B2B, self::COM_B2B, self::HR_B2B => 'b2b', |
| 153 | + self::DE_B2C, self::AT_B2C, self::CH_B2C, self::HU_B2C, self::NL_B2C => 'b2c', |
| 154 | + }; |
| 155 | + } |
| 156 | +} |
0 commit comments