Skip to content

Instantly share code, notes, and snippets.

@shaundon
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shaundon/10404109 to your computer and use it in GitHub Desktop.
Save shaundon/10404109 to your computer and use it in GitHub Desktop.
/*
Call start() on console to run program.
May be a little rough around the edges, I'm trying to remember the
jQuery API from memory as my home internet's too slow to Google stuff.
Oh and it requires jQuery, because everything requires jQuery!
*/
function start() {
// Ask the API for campaigns.
$.ajax({
method: 'GET',
url: '/tm-api-ajax/campaign',
async: false,
success: function(campaigns) {
var idsToDelete = [];
// Go through each campaign.
$.each(campaign, function(index, campaign) {
// Store the ID. Note, this might be campaign.id instead of
// campaign.campaignId. Check with Sam.
idsToDelete.push(campaign.campaignId);
});
// Do the deletion.
doDeletion(idsToDelete);
}
});
}
function doDeletion(ids) {
$.each(ids, function(index, idToDelete) {
$.ajax({
url: '/tm-api-ajax/campaign',
method: 'DELETE',
async: false,
params: {
id: idToDelete
},
success: function() {
console.log(id + ' was deleted successfully');
},
error: function() {
console.log(id + ' was not deleted successfully');
}
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment