Created
March 14, 2018 14:20
-
-
Save Sarapulov/1df5654858d3729065e47836945f4b82 to your computer and use it in GitHub Desktop.
Activate Zendesk brands - run in console
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
// Activate inactive brands | |
// run in console | |
(function() { | |
function fetchAllBrandsAndActivate (url) { | |
jQuery.ajax({ | |
url: url, | |
async: false | |
}).done(function(data) { | |
jQuery.each(data.brands,function(i,v){ | |
console.log("CURRENT BRAND: " + v.name + " ::: " + v.brand_url + " ||| " + v.subdomain + " >>> " + v.help_center_state + " <<< " + v.active + " ~~~ " + v.id); | |
if (!v.active) activateBrand(v); | |
}); | |
if (data.next_page) fetchAllBrandsAndActivate(data.next_page); | |
}); | |
} | |
function activateBrand(brand) { | |
jQuery.ajax({ | |
url: brand.url, | |
method: "PUT", | |
async: false, | |
data: {"brand": { "active": true }} | |
}).done(function(data) { | |
console.log(brand.subdomain + " is now ACTIVE", data); | |
}).fail(function(data) { | |
console.log("[!] FAILED updating " + brand.subdomain, data); | |
}); | |
} | |
fetchAllBrandsAndActivate("/api/v2/brands.json"); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment