ElasticEmail.WebApiClient-php icon indicating copy to clipboard operation
ElasticEmail.WebApiClient-php copied to clipboard

Reusable configuration keys

Open cmygeHm opened this issue 3 years ago • 0 comments

  1. It's not so useful to initialize client with string configuration keys, as your examples:
    $configuration = new \ElasticEmailClient\ApiConfiguration([
        'apiUrl' => 'https://api.elasticemail.com/v2/',
        'apiKey' => 'yourApiKey'
    ]);

More useful:

    $configuration = new \ElasticEmailClient\ApiConfiguration([
        \ElasticEmailClient\ApiConfiguration::API_URL => 'https://api.elasticemail.com/v2/',
        \ElasticEmailClient\ApiConfiguration::API_KEY => 'yourApiKey'
    ]);
  1. I think it is better to pass this options via setters and not to do them as required arguments of constructor:
$config = new ApiConfiguration();
$config
            ->setApiUrl($apiUrl)
            ->setApiKey($api);

If you do not agree with me I can remove this commit https://github.com/ElasticEmail/ElasticEmail.WebApiClient-php/pull/14/commits/478eb7321d555025eae0e0436313ad9ed98c61c7

cmygeHm avatar Apr 19 '21 21:04 cmygeHm