3434
3535class ApiConfiguration extends AbstractConfigProvider
3636{
37- public const XPATH_API_BASE = 'tig_postcode/api/base ' ;
37+ public const XPATH_API_NL_BASE = 'tig_postcode/api/base ' ;
3838
39- public const XPATH_API_VERSION = 'tig_postcode/api/version ' ;
39+ public const XPATH_API_NL_POSTCODE_VERSION = 'tig_postcode/api/version ' ;
4040
41- public const XPATH_API_TYPE = 'tig_postcode/api/type ' ;
41+ public const XPATH_API_NL_TYPE = 'tig_postcode/api/type ' ;
4242
4343 public const XPATH_API_BE_BASE = 'tig_postcode/api_be/base ' ;
4444
@@ -52,6 +52,12 @@ class ApiConfiguration extends AbstractConfigProvider
5252
5353 public const XPATH_API_DE_STREET_VERSION = 'tig_postcode/api_de/street_version ' ;
5454
55+ public const XPATH_API_FR_BASE = 'tig_postcode/api_fr/base ' ;
56+
57+ public const XPATH_API_FR_POSTCODE_VERSION = 'tig_postcode/api_fr/postcode_version ' ;
58+
59+ public const XPATH_API_FR_STREET_VERSION = 'tig_postcode/api_fr/street_version ' ;
60+
5561 /**
5662 * Get base Uri
5763 *
@@ -86,6 +92,19 @@ public function getDEBaseUri(string $endpoint): string
8692 return $ this ->getBase ('DE ' ) . '/ ' . $ this ->getVersion ('DE ' , $ endpoint ) . '/ ' ;
8793 }
8894
95+ /**
96+ * Get France base Uri
97+ *
98+ * @param string $endpoint
99+ *
100+ * @return string
101+ */
102+ public function getFRBaseUri (string $ endpoint ): string
103+ {
104+ return $ this ->getBase ('FR ' ) . '/ ' . $ this ->getVersion ('FR ' , $ endpoint ) . '/ ' ;
105+ }
106+
107+
89108 /**
90109 * Get base path via country and store ID
91110 *
@@ -96,15 +115,12 @@ public function getDEBaseUri(string $endpoint): string
96115 */
97116 public function getBase (string $ country = 'NL ' , int |string $ store = null ): mixed
98117 {
99- $ xpath = static ::XPATH_API_BASE ; // NL
100-
101- if ($ country == 'BE ' ) { // BE
102- $ xpath = static ::XPATH_API_BE_BASE ;
103- }
104-
105- if ($ country == 'DE ' ) { // DE
106- $ xpath = static ::XPATH_API_DE_BASE ;
107- }
118+ $ xpath = match ($ country ) {
119+ 'BE ' => static ::XPATH_API_BE_BASE ,
120+ 'DE ' => static ::XPATH_API_DE_BASE ,
121+ 'FR ' => static ::XPATH_API_FR_BASE ,
122+ default => static ::XPATH_API_NL_BASE ,
123+ };
108124
109125 return $ this ->getConfigFromXpath ($ xpath , $ store );
110126 }
@@ -120,29 +136,21 @@ public function getBase(string $country = 'NL', int|string $store = null): mixed
120136 */
121137 public function getVersion (string $ country = 'NL ' , string $ endpoint = null , int |string $ store = null ): mixed
122138 {
123- $ xpath = static ::XPATH_API_VERSION ; // NL
124-
125- if ($ country == 'BE ' ) {
126- switch ($ endpoint ) {
127- case 'zipcode-find/ ' :
128- $ xpath = static ::XPATH_API_BE_POSTCODE_VERSION ;
129- break ;
130- case 'street-find/ ' :
131- $ xpath = static ::XPATH_API_BE_STREET_VERSION ;
132- break ;
133- }
134- }
135-
136- if ($ country == 'DE ' ) {
137- switch ($ endpoint ) {
138- case 'zipcode-find/ ' :
139- $ xpath = static ::XPATH_API_DE_POSTCODE_VERSION ;
140- break ;
141- case 'street-find/ ' :
142- $ xpath = static ::XPATH_API_DE_STREET_VERSION ;
143- break ;
144- }
145- }
139+ $ xpath = match ($ country ) {
140+ 'BE ' => match ($ endpoint ) {
141+ 'zipcode-find/ ' => static ::XPATH_API_BE_POSTCODE_VERSION ,
142+ 'street-find/ ' => static ::XPATH_API_BE_STREET_VERSION ,
143+ },
144+ 'DE ' => match ($ endpoint ) {
145+ 'zipcode-find/ ' => static ::XPATH_API_DE_POSTCODE_VERSION ,
146+ 'street-find/ ' => static ::XPATH_API_DE_STREET_VERSION ,
147+ },
148+ 'FR ' => match ($ endpoint ) {
149+ 'zipcode-find/ ' => static ::XPATH_API_FR_POSTCODE_VERSION ,
150+ 'street-find/ ' => static ::XPATH_API_FR_STREET_VERSION ,
151+ },
152+ default => static ::XPATH_API_NL_POSTCODE_VERSION ,
153+ };
146154
147155 return $ this ->getConfigFromXpath ($ xpath , $ store );
148156 }
@@ -156,6 +164,6 @@ public function getVersion(string $country = 'NL', string $endpoint = null, int|
156164 */
157165 public function getType (int |string $ store = null ): mixed
158166 {
159- return $ this ->getConfigFromXpath (static ::XPATH_API_TYPE , $ store );
167+ return $ this ->getConfigFromXpath (static ::XPATH_API_NL_TYPE , $ store );
160168 }
161169}
0 commit comments