/////////////////////////////////////////////////////////////////////////////////////////////
function getWS(wsName ){
// return either the cached value or jqXHR object wrapped Promise
return $.when(
$.ajax({
url: cache["baseurl"] +'workspaces/search', //goto get the indexer to work - ?name=' +wsName,
type: 'get',
headers: {
'X-Auth-Token':cache[ "Token" ],
'Content-Type': 'application/json'
},
dataType: 'json',
success: function( resp ){
debugger;
var temp = resp.data.filter(function(item) {
return item.name == wsName;
});
cache[ "ws_name" ] =wsName;
cache[ "ws_id" ] = temp[0].id;
console.log("getWS:success");
},
failure: function( resp ){
console.log("getWS:failure");
console.log(resp);
}
})
);
}
/////////////////////////////////////////////////////////////////////////////////////////////
/*
access levels
"no_access", "read", "read_write", "full_access"
what are the possible values for user types?
"user" or "group"
*/
function addWSToMyMatters(){
return $.when(
$.ajax({
url: cache["baseurl"] + 'folders/my-matters/subfolders',
type: 'post',
headers: {
'X-Auth-Token':cache[ "Token" ],
'Content-Type': 'application/json'
},
dataType: 'json',
data: JSON.stringify({ "name":cache[ "ws_name" ],
"target":
{ "database":"Blah",
"id":cache[ "ws_id" ],
"subtype":"work",
"wstype":"workspace"}
}),
success: function( resp ){
debugger;
//user_type
// cache[ "doc_id" ] = resp.data[0].id;
console.log("addWSToMyMatters:success");
},
failure: function( resp ){
console.log("addWSToMyMatters:failure");
console.log(resp);
}
})
);
}
/////////////////////////////////////////////////////////////////////////////////////////////
getToken().then(getWS("11Blah)"))
.then(addWSToMyMatters());
No comments:
Post a Comment