Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new method isSubscribed #285

Open
ulinskas opened this issue Nov 7, 2019 · 2 comments
Open

Introduce new method isSubscribed #285

ulinskas opened this issue Nov 7, 2019 · 2 comments

Comments

@ulinskas
Copy link

ulinskas commented Nov 7, 2019

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

@Mujan84
Copy link

Mujan84 commented Nov 18, 2019

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 {

}

@ulinskas
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants