mollie / laravel-mollie

Mollie API client wrapper for Laravel & Mollie Connect provider for Laravel Socialite
https://www.mollie.com/
MIT License
326 stars 62 forks source link

Future request: parity with Mollie core client #70

Closed sandervanhooft closed 4 years ago

sandervanhooft commented 6 years ago

Expected Behavior

Laravel wrapper should behave the same as the Mollie core client. For example:

$mollie->payments->create(...); // core client
$mollie->payments->create(...); // Laravel client

This way it's possible to use the same examples in the docs for both.

Current Behavior

$mollie->payments->create(...); // core client
$mollie->payments()->create(...); // Laravel client is different

Possible Solution

We could implement a magic getter function on the wrapper to proxy the endpoints.

This way,

$mollie->payments

would then become an alias for

$mollie->payments()

Context

Consistency -> happy dev 😄

sandervanhooft commented 6 years ago

Inspiration (link):

    /**
     * Handle dynamic property calls.
     *
     * @param  string $property
     * @return mixed
     */
    public function __get($property)
    {
        if (method_exists($this, $property)) {
            return call_user_func([$this, $property]);
        }

        $message = '%s does not respond to the "%s" property or method.';

        throw new Exception(
            sprintf($message, static::class, $property)
        );
    }
sandervanhooft commented 4 years ago

✅ @jubeki worked his magic into this package.

It's now possible to use the same calls as in mollie/mollie-api-php.

For clarity it's best to update the code samples in the documentation as well, to match Mollie's docs. @Jubeki would you be willing to take a stab at this? Otherwise I'll pick it up.

@vernondegoede could you modify the header image / provide a new one?

I don't have a source file for this.

sandervanhooft commented 4 years ago

Thanks for solving this issue @jubeki, much appreciated!