Skip to content

Commit

Permalink
Fix Incorrect value in a property id causes new property to be created
Browse files Browse the repository at this point in the history
Fixes #26
  • Loading branch information
rmeekers committed Aug 25, 2016
1 parent a4a856e commit 25ac01f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/code.gs
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,9 @@ var api = {
var starred = insertData[7];
var websiteUrl = insertData[8];
var existingPropertyId = this.getApiData(accountId, id).id;
var result = {};

if(!id || id != existingPropertyId) {
if(!id) {
return this.insertApiData(
accountId,
name,
Expand All @@ -778,6 +779,11 @@ var api = {
websiteUrl
);
}
else if(id != existingPropertyId) {
result.status = 'Fail';
result.message = 'Property does not exist. Please verify Account and/or Property ID';
return result;
}
},
},
views: {
Expand Down Expand Up @@ -1570,8 +1576,9 @@ var api = {
var type = insertData[16];
var websiteUrl = insertData[17];
var existingViewId = this.getApiData(accountId, propertyId, viewId).id;
var result = {};

if(!viewId || viewId != existingViewId) {
if(!viewId) {
return this.insertApiData(
accountId,
propertyId,
Expand Down Expand Up @@ -1608,6 +1615,11 @@ var api = {
websiteUrl
);
}
else if(viewId != existingViewId) {
result.status = 'Fail';
result.message = 'View does not exist. Please verify Account, Property and/or View ID';
return result;
}
},
},
filterLinks: {
Expand Down

0 comments on commit 25ac01f

Please sign in to comment.