akeneo / api-php-client

PHP client of Akeneo PIM API
https://packagist.org/packages/akeneo/api-php-client
Other
90 stars 57 forks source link

Ability to extend PHP API Client #71

Open syno-dlr opened 6 years ago

syno-dlr commented 6 years ago

Hello Akeneo Team,

We created a custom entry point on Akeneo 2.0. Today, I would like to use php api client to work with this entry point but it seems that the client is "closed" to Akeneo services.

It could be cool to add the ability to extend the API with something like AkeneoPimClientBuilder::addEntryPoint(....) ? Or with some configuration files...

Best Regards,

Dam'.

LevFlavien commented 2 years ago

This is not a planned feature, but extending the client can be achieved by simply extending AkeneoPimClient class.

final class CustomPimClient extends AkeneoPimClient
{
    private CustomApi $customApi;

    public function __construct(
        Authentication $authentication,
        ProductApiInterface $productApi,
        /* ... */
        CustomApi $customApi
    ) {
        parent::__construct(
            $authentication,
            $productApi,
            /* ... */
        );

        $this->customApi = $customApi;
    }

    public function customApi(): CustomApi
    {
        return $this->customApi;
    }
}