drewm/mailchimp-api

Introduce new method isSubscribed

ulinskas opened this issue · 2 comments

It would be nice to have an method like isSubscribed which would have 2 arguments $listId and $subscriberHash and would return only boolean.

public function isSubscribed(int $listId, string $subscriberHash): bool

I support this.
But for now I do it like this:

$result = $MailChimp->get("lists/".$list_id."/members/".$subscriber_hash);
if ($result['status'] == '404') {
// No user in mailChimp database
} else {

}

I have similar solution right now.

    /**
     * Check if email is subscribed in specific audience.
     */
    private function hasStatusSubscribed(string $email, string $audienceId): bool
    {
        $response = $this->mailChimp->get(sprintf(
            'lists/%s/members/%s',
            $audienceId,
            $this->mailChimp->subscriberHash($email)
        ));

        return isset($response['status']) && $response['status'] === self::MAIL_CHIMP_USER_STATUS_SUBSCRIBED;
    }

But I would love to have this method in drewm/mailchimp-api, because now, I'm basically wrapping a wrapper