keepsuit / laravel-zoho-campaigns

Manage Zoho Campaigns from Laravel
MIT License
1 stars 1 forks source link

resubscribe functionality via API #20

Closed andreibaca closed 3 months ago

andreibaca commented 4 months ago

If the user is unsubscribed Zoho allows only resubscription via form. The subscription response returns true for success but the message is "Contact belongs to Do-not-mail registry." and user does not receive any confirmation emails and is not subscribed again.

To allow re-subscription a specific parameter has to be added to the request url donotmail_resub=true

With this parameter the response message is the following "This is a Donotmail contact or removed contact,So the resubscribtion email is sent to the user. User needs to confirm to successfully subscribe." And user receives a resubscription confirmation email.

With this pull request resubscribe method is added that works.

cappuc commented 4 months ago

Hi @andreibaca

Do you think it makes sense to always add the donotmail_resub=true parameter to the subscribe request?

If the subscribe response is successful even if the user is not actually subscribed, you have to check the message and then call the resubscribe method and this is not so intuitive.

If always adding the parameter is not a problem, I think that is better to add it to the subscribe request so it can handle both cases

andreibaca commented 4 months ago

I think it's better to offer more choice and document it. If someone wants to use donotmail_resub he can just use the resubscribe function instead of subscribe. I am not sure what problems could arise if we use this parameters for subscribe all the time since it is not documented, and could even change in the future which could result in errors. We can just add a parameter to the subscribe method to allow resubscription when necessary. Maybe even include the $optional_parameters in subscribe.

andreibaca commented 4 months ago

Actually I will test if it's ok to use resubscribe for new users.

andreibaca commented 4 months ago

It seems to simply work for new users when using donotmail_resub=true. May be I overengineered it. Just did not want to mess with existing functionality to make it backwards compatible.. :) But I would still add the optional parameters for any future cases. It just makes the library more flexible.

andreibaca commented 4 months ago

I just thought of a case where the developer might want to confirm that the user really wants to resubscribe then we need 2 separate methods.

andreibaca commented 3 months ago

I have added some more functionality to get the list of subscribers and to count them. I forgot to create a new branch so it's in the same pull request. Sorry for confusion and inconvenience. I have already tested it with a live zoho account and it works as expected.

cappuc commented 3 months ago

No problem!

Next week I'll review the changes and merge it.