MailChimp Campaigns - the Meteor way.
See also these wrappers:
- miro:mailchimp - A Meteor wrapper for the MailChimp API
miro:mailchimp-campaigns helps you to manage mailing campaigns.
Further information on the MailChimp API and its features is available at https://github.com/gomfunkel/node-mailchimp.
Use in your template (will use Session variable 'MailChimp.lists.listId' for default list):
miro:mailchimp-campaigns also exposes one template you can use out of the box:
{{> MailChimpCampaigns}}
, which will render all mailing campaign for a given
mailing list.
Install using Meteor:
meteor add miro:mailchimp-campaigns // It will add miro:mailchimp package
// if not not already installed
Use in your template:
<div id="mailChimpCampaings">
<!-- There's also another utility template
you can use to refresh the list -->
{{> MailChimpCampaignsRefresh}}
{{> MailChimpCampaigns}}
</div>
Put in your server's settings.json:
{
"private": {
"MailChimp": {
"apiKey": "<Your MailChimp API Key>",
"listId": "<ID of your default mailing list>"
}
}
}
and start your server with:
meteor --settings settings.json
MailChimpCampaigns at the moment exposes the following methods both on the server and the client:
Get the list of campaigns and their details matching the specified filters
params
Parameters to pass to the API method.callback
Callback function for returned data or errors with two parameters. The first one being an error object which is null when no error occured, the second one an object with all information retrieved as long as no error occured.
Create a new draft campaign to send
params
Parameters to pass to the API method.callback
Callback function for returned data or errors with two parameters. The first one being an error object which is null when no error occured, the second one an object with all information retrieved as long as no error occured.
Update a mailing campaign
params
Parameters to pass to the API method.callback
Callback function for returned data or errors with two parameters. The first one being an error object which is null when no error occured, the second one an object with all information retrieved as long as no error occured.
Schedule a campaign to be sent in the future
params
Parameters to pass to the API method.callback
Callback function for returned data or errors with two parameters. The first one being an error object which is null when no error occured, the second one an object with all information retrieved as long as no error occured.
Returns information on whether a campaign is ready to send
params
Parameters to pass to the API method.callback
Callback function for returned data or errors with two parameters. The first one being an error object which is null when no error occured, the second one an object with all information retrieved as long as no error occured.
Send a test of this campaign to the provided email addresses
params
Parameters to pass to the API method.callback
Callback function for returned data or errors with two parameters. The first one being an error object which is null when no error occured, the second one an object with all information retrieved as long as no error occured.
Send a given campaign immediately
params
Parameters to pass to the API method.callback
Callback function for returned data or errors with two parameters. The first one being an error object which is null when no error occured, the second one an object with all information retrieved as long as no error occured.
Unschedule a campaign that is scheduled to be sent in the future
params
Parameters to pass to the API method.callback
Callback function for returned data or errors with two parameters. The first one being an error object which is null when no error occured, the second one an object with all information retrieved as long as no error occured.
method
The method to call in the given section.params
Parameters to pass to the API method.callback
(optional server-side, required client-side) Callback function for returned data or errors with two parameters. The first one being an error object which is null when no error occured, the second one an object with all information retrieved as long as no error occured.
List all campaigns for a given list
- NEW - will refresh the list if session variable
MailChimp.lists.listId
set to-1
- REACTIVE - will re-render the template if session variable
MailChimp.lists.listId
changes
// You can as well pass different parameters on each call
var mailingCampaigns = new MailChimpCampaigns( /* apiKey, { version : '2.0' } */ );
mailingCampaigns.campaigns(
{ /*
filters: {
list_id: '<some_mailing_list_id>'
},
start: 0,
limit: 100,
sort_field: '',
sort_dir: '' */
},
// Callback beauty in action
function ( error, result ) {
if ( error ) {
console.error( '[MailChimpCampaigns][Campaigns] Error: %o', error );
} else {
// Do something with your data!
console.info( '[MailChimpCampaigns][Campaigns]: %o', result );
}
}
);
// You can as well pass different parameters on each call
var mailingCampaigns = new MailChimpCampaigns( /* apiKey, { version : '2.0' } */ );
var result = mailingCampaigns.campaigns(
{ /*
filters: {
list_id: '<some_mailing_list_id>'
},
start: 0,
limit: 100,
sort_field: '',
sort_dir: '' */
}
);
// Do something with your data!
console.info( '[MailChimpCampaigns][Campaigns]:\n', JSON.stringify( result ) );
- Update to Meteor v1.0
- On client, MailChimpCampaigns.call() now reads API Key from session variable 'MailChimp.apiKey'
- Cleanup
- Added
refresh
functionality to the list of campaigns - set session variableMailChimpOptions.listId
to-1
to initiate refresh of the same list, or new list ID for a new list
- Fixed bug: in campaigns() method,
MailChimpOptions.apiKey
was compared tonull
instead ofundefined
- On client, MailChimpCampaigns methods now read API Key from session variable
MailChimpOptions.apiKey
as well - On client, MailChimpCampaigns methods now read list ID from session variable
MailChimpOptions.listId
as well - Added reactive list of all campaigns for a given mailing list - will re-render the template if session variable 'MailChimpOptions.listId' changes
- Initial release
Copyright © 2014-2015 Miroslav Hibler
miro:mailchimp-campaigns is licensed under the MIT license.