<?php require __DIR__ . '/../vendor/autoload.php';

use Intellex\MailChimp\Client;

// Initialize data
\Intellex\Debugger\Debugger::initHandlers();
function debug($data) {
	\Intellex\Debugger\Debugger::dump($data, 1);
}

// Set configuration and Initialize
$config = new \Intellex\MailChimp\Config('46718236c7f3c7ae7083db7c0d057901-us9');
$mailChimp = new Client($config);

// LISTS====================================================== //

//// Find all lists
//$lists = $mailChimp->lists()->getAll();
//debug($lists);

// Check if email already exists
$subscribers = $mailChimp->lists()->getSubscribers('0d14093119');
debug($subscribers);



// MEMBERS====================================================== //

//// Add a new member
//$member = $mailChimp->subscribers()->add('0d14093119', 'zudic+12@intellex.rs', 'Milan', date('Y-m-d H:i:s'));
//debug($member);



// TEMPLATES====================================================== //

//// Find all templates
//$templates = $mailChimp->templates()->getAll();
//foreach($templates as $template) {
//debug($templates);

//// Find one template
//$template = $mailChimp->templates()->get('452905');
//debug($template);

//// Find default fields in template
//$content = $mailChimp->templates()->defaultContent('453001');
//debug($content);

//// Create template
//$html = file_get_contents('http://phpmailchimp/email.html');
//$template = $mailChimp->templates()->create('New template test 4', $html);
//debug($template);

//// Edit template
//$html = file_get_contents('http://phpmailchimp/email2.html');
//$template = $mailChimp->templates()->edit('New template test 14', $html, '453037');
//debug($template);



// CAMPAIGNS====================================================== //

//// Get all Campaigns
//$campaigns = $mailChimp->campaign()->getAll();
//debug($campaigns);

//// Create Campaign
//$campaign = $mailChimp->campaign()->create('0d14093119','Test Kampanja 11', 'Subject 11', 'Deda Njuzleter 11', 'zudic@intellex.rs');
//debug($campaign);
//
//// UnSchedule Campaign
//$campaign = $mailChimp->campaign()->delete('271a7bc5ce');
//debug($campaign);

//// Edit Campaign
//$campaign = $mailChimp->campaign()->edit('af2f33a732', '0d14093119', 'Test Kampanja 4', 'Subject 4', 'Deda Njuzleter 56', 'zudic+4@intellex.rs');
//debug($campaign);

//// Content for the Campaign
//$campaign = $mailChimp->campaign()->content('af2f33a732', file_get_contents('/var/www/php-mailchimp/test/email2.html'));
//debug($campaign);

//// Schedule Campaign
//$campaign = $mailChimp->campaign()->schedule('4052ecc0db', '2017-12-20T17:45:00+00:00');
//debug($campaign);
//
//// UnSchedule Campaign
//$campaign = $mailChimp->campaign()->unschedule('4052ecc0db');
//debug($campaign);

//// Send Test email for Campaign
//$campaign = $mailChimp->campaign()->test('4052ecc0db', ['zudic@intellex.rs']);
//debug($campaign);