DynamoMTL/spree_chimpy — pull request #14 by johanb (2013-05-19 06:28:43+00:00)
Title: Segmenting does not work as expected when using double opt-in

I just noticed an issue with the segmenting code. Apparently Mailchimp does not allow you to segment users that have not yet confirmed their mailinglist subscription. So if you have the double opt-in enabled (where Mailchimp sends you an email to confirm the subscribtion), the user that just created an account with the store will never get segmented.

Mailchimp will return the following response in this case:

```
"success"=>0, "errors"=>[{"email"=>"klaas@hans.nl", "code"=>232, "msg"=>"There is no record of \"klaas@hans.nl\" in the database"}]}
```
There is a few ways we can tackle this:

* Document it in the readme, and leave it like it is.
* Create a rake task that can be run from a cron to segment the users in the database
* Re-segment users when they create an order
* In case of sidekiq we could just throw an exception in this case, which would re-enqueue the job. This seems dirty though.

The most robust solution would be to do option 1 + 2. Users that don't use double opt-in have no issue with this. Users that do use it, can set up a cron. The only downside would be the extra set-up for a cron but that's not such a big deal.

I'd love your feedback on this @joshnuss before I whip up a PR.

Relevant API docs:
http://apidocs.mailchimp.com/api/1.3/liststaticsegmentmembersadd.func.php