Skip to content

Instantly share code, notes, and snippets.

@Sarapulov
Created March 14, 2018 14:20
Show Gist options
  • Save Sarapulov/1df5654858d3729065e47836945f4b82 to your computer and use it in GitHub Desktop.
Save Sarapulov/1df5654858d3729065e47836945f4b82 to your computer and use it in GitHub Desktop.
Activate Zendesk brands - run in console
// 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