Skip to content

Commit

Permalink
feat: Added deletePalette function
Browse files Browse the repository at this point in the history
  • Loading branch information
batje committed Apr 6, 2019
1 parent afc110f commit e732f2b
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions src/Cognos.js
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ class Cognos {
if (id) {
result = me.requester
.put('bi/v1/palettes/' + id, false, palette)
.then(function(data) {
.then(function() {
me.log('saved palette ' + id);
return id;
})
Expand All @@ -762,7 +762,7 @@ class Cognos {
.then(function() {
me.log('We have been reset, savePalette again');
me.resetting = false;
return me.savePalettes(id, palette);
return me.savePalette(id, palette);
})
.catch(function() {
throw err;
Expand All @@ -771,7 +771,7 @@ class Cognos {
} else {
result = me.requester
.post('bi/v1/palettes/my', palette, true)
.then(function(data) {
.then(function() {
me.log('saved palette');
})
.catch(function(err) {
Expand All @@ -781,7 +781,7 @@ class Cognos {
.then(function() {
me.log('We have been reset, savePalette again');
me.resetting = false;
return me.savePalettes(palette, id);
return me.savePalette(palette, id);
})
.catch(function() {
throw err;
Expand All @@ -790,6 +790,37 @@ class Cognos {
}
return result;
}

deletePalette(id) {
var me = this;
var params = {
force: 'true'
};

var result = me.requester
.delete('bi/v1/palettes/' + id, params, false)
.then(function() {
me.log('deleted palette ' + id);
return id;
})
.catch(function(err) {
me.error('CognosRequest : Error in deletePalette', err);
if (err == 'Not Found') {
throw 'Palette with id ' + id + ' is not found';
}
return me
.handleError(err)
.then(function() {
me.log('We have been reset, deletePalette again');
me.resetting = false;
return me.deletePalette(id);
})
.catch(function() {
throw err;
});
});
return result;
}
}

/**
Expand Down

0 comments on commit e732f2b

Please sign in to comment.