|
2 | 2 |
|
3 | 3 | namespace Ang3\Component\OdooApiClient\Factory; |
4 | 4 |
|
5 | | -use InvalidArgumentException; |
| 5 | +use Ang3\Component\OdooApiClient\Exception\ClientConfigException; |
6 | 6 | use Ang3\Component\OdooApiClient\ExternalApiClient; |
7 | 7 |
|
8 | 8 | /** |
|
12 | 12 | */ |
13 | 13 | class ApiClientFactory |
14 | 14 | { |
| 15 | + /** |
| 16 | + * @deprecated This method will be removed in 3.0. Please use method "create" instead. |
| 17 | + * |
| 18 | + * @param array $parameters |
| 19 | + * @param array $options |
| 20 | + * |
| 21 | + * @return ExternalApiClient |
| 22 | + */ |
| 23 | + public function createExternalApiClient(array $parameters = [], array $options = []) |
| 24 | + { |
| 25 | + trigger_error(sprintf('The method %s:%s() is deprecated and will be removed in 3.0. Please use %s:create() instead.', __CLASS__, __METHOD__, __CLASS__), E_USER_DEPRECATED); |
| 26 | + |
| 27 | + return $this->create($parameters, $options); |
| 28 | + } |
| 29 | + |
15 | 30 | /** |
16 | 31 | * Create external API client for Odoo from config array. |
17 | 32 | * |
18 | 33 | * @param array $parameters |
19 | 34 | * @param array $options |
20 | 35 | * |
21 | | - * @throws InvalidArgumentException when a required parameter is missing |
| 36 | + * @throws ClientConfigException when a required parameter is missing |
22 | 37 | * |
23 | 38 | * @return ExternalApiClient |
24 | 39 | */ |
25 | | - public function createExternalApiClient(array $parameters = [], array $options = []) |
| 40 | + public function create(array $parameters = [], array $options = []) |
26 | 41 | { |
27 | 42 | // Si pas d'URL |
28 | 43 | if (!array_key_exists('url', $parameters)) { |
29 | | - throw new InvalidArgumentException('Missing required parameter "url".'); |
| 44 | + throw new ClientConfigException('Missing required parameter "url".'); |
30 | 45 | } |
31 | 46 |
|
32 | 47 | // Si pas de nom de base de données Odoo |
33 | 48 | if (!array_key_exists('database', $parameters)) { |
34 | | - throw new InvalidArgumentException('Missing required parameter "database".'); |
| 49 | + throw new ClientConfigException('Missing required parameter "database".'); |
35 | 50 | } |
36 | 51 |
|
37 | 52 | // Si pas d'utilisateur |
38 | 53 | if (!array_key_exists('user', $parameters)) { |
39 | | - throw new InvalidArgumentException('Missing required parameter "user".'); |
| 54 | + throw new ClientConfigException('Missing required parameter "user".'); |
40 | 55 | } |
41 | 56 |
|
42 | 57 | // Si pas de mot de passe |
43 | 58 | if (!array_key_exists('password', $parameters)) { |
44 | | - throw new InvalidArgumentException('Missing required parameter "password".'); |
| 59 | + throw new ClientConfigException('Missing required parameter "password".'); |
45 | 60 | } |
46 | 61 |
|
47 | 62 | // Récupération des options éventuelles du client |
|
0 commit comments