mailerlite-api-v2-php-sdk icon indicating copy to clipboard operation
mailerlite-api-v2-php-sdk copied to clipboard

[Feature Request] More fluent syntax for common use cases

Open bkuhl opened this issue 5 years ago • 0 comments

I'm a new user of the SDK, but it looks like this snippet is the best way to determine if an email is currently subscribed or not:

$subscription = $this->mailerLite->subscribers()->find($user->email);
if (property_exists($subscription, 'error') && $subscription->error->code === 123) {
   
}

This isn't very readable, and I was only able to obtain the 123 error code through trial & error as I didn't come across it in the documentation. It'd be great if there was a class constant representing this error code or if a shorthand helper method could be added such as if ($this->mailerLite->subscribers()->isSubscribed($email) that either returned a bool or threw an exception on error (e.g. 404).

bkuhl avatar Jan 12 '20 19:01 bkuhl