@@ -27,6 +27,18 @@ protected function getProvider(array $config): Provider
2727 {
2828 $ httplug = $ config ['httplug_client ' ] ?: $ this ->httpClient ?? HttpClientDiscovery::find ();
2929
30+ if (empty ($ config ['app_key ' ]) && empty ($ config ['app_id ' ]) && empty ($ config ['app_code ' ])) {
31+ throw new \InvalidArgumentException ('No authentication key provided. Here requires app_key or app_code and app_id. ' );
32+ }
33+
34+ if (!empty ($ config ['app_key ' ])) {
35+ if (!method_exists (Here::class, 'createUsingApiKey ' )) {
36+ throw new \InvalidArgumentException ('Here provider has no support for `creatingUsingApiKey` method. ' );
37+ }
38+
39+ return Here::createUsingApiKey ($ httplug , $ config ['app_key ' ], $ config ['use_cit ' ]);
40+ }
41+
3042 return new Here ($ httplug , $ config ['app_id ' ], $ config ['app_code ' ], $ config ['use_cit ' ]);
3143 }
3244
@@ -35,10 +47,15 @@ protected static function configureOptionResolver(OptionsResolver $resolver)
3547 $ resolver ->setDefaults ([
3648 'httplug_client ' => null ,
3749 'use_cit ' => false ,
50+ 'app_key ' => null ,
51+ 'app_id ' => null ,
52+ 'app_code ' => null ,
3853 ]);
3954
4055 $ resolver ->setAllowedTypes ('httplug_client ' , ['object ' , 'null ' ]);
56+ $ resolver ->setAllowedTypes ('app_key ' , ['string ' , 'null ' ]);
57+ $ resolver ->setAllowedTypes ('app_id ' , ['string ' , 'null ' ]);
58+ $ resolver ->setAllowedTypes ('app_code ' , ['string ' , 'null ' ]);
4159 $ resolver ->setAllowedTypes ('use_cit ' , ['bool ' , 'false ' ]);
42- $ resolver ->setRequired (['app_id ' , 'app_code ' ]);
4360 }
4461}
0 commit comments