Created
July 10, 2013 18:03
-
-
Save tomwayson/5968622 to your computer and use it in GitHub Desktop.
An AMD utility module for working with ArcGIS portal items that including helper functions missing from other esri/arcgis classes (addItem, etc)
This file contains 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
define([ | |
"dojo/io-query", | |
"esri/request", | |
"esri/arcgis/utils" | |
], | |
function( | |
ioQuery, | |
esriRequest, | |
arcgisUtils | |
) { | |
return { | |
// add an item to a portal users's content | |
// assumes portal user is already logged in (using identity manager) | |
addItem: function (portalUser, content) { | |
var requestParams = { f: "json", token: portalUser.credential.token }; | |
var url = portalUser.portal.portalUrl + "content/users/" + portalUser.username + "/addItem"; | |
url += "?" + ioQuery.objectToQuery(requestParams); | |
return esriRequest({ | |
url: url, | |
content: content | |
}, { | |
usePost: true | |
}); | |
}, | |
// get item info and item data | |
// wraps arcgisUtils.getItem function to | |
// make it more generic for other portals | |
getItem: function(portal, itemId) { | |
arcgisUtils.arcgisUrl = portal.url + "/sharing/content/items"; | |
return arcgisUtils.getItem(itemId); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment