Created
October 13, 2015 15:20
-
-
Save YOzaz/0bac63adad60f395a830 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php namespace MyApp\Controllers\Mailer; | |
| use MailChimpAPI; | |
| class MailChimpController extends \Controller | |
| { | |
| /** | |
| * Syncs MailChimp data | |
| * | |
| * @throws \Exception | |
| */ | |
| public function sync() | |
| { | |
| if ( !Input::has('type', 'data') ) | |
| { | |
| return; | |
| // throw new \Exception('Required arguments missing.'); | |
| } | |
| $input = Input::all(); | |
| switch ( $input['type'] ) | |
| { | |
| case 'subscribe': | |
| MailChimpAPI::syncSubscribe( $input['data']['list_id'], $input['data']['email'] ); | |
| break; | |
| case 'unsubscribe': | |
| MailChimpAPI::syncUnsubscribe( $input['data']['list_id'], $input['data']['email'] ); | |
| break; | |
| case 'cleaned': | |
| MailChimpAPI::syncUnsubscribe( $input['data']['list_id'], $input['data']['email'] ); | |
| break; | |
| case 'upemail': | |
| MailChimpAPI::syncUnsubscribe( $input['data']['list_id'], $input['data']['old_email'] ); | |
| MailChimpAPI::syncSubscribe( $input['data']['list_id'], $input['data']['new_email'] ); | |
| break; | |
| default: | |
| // throw new \Exception('Unsupported request.'); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment