Skip to content

Instantly share code, notes, and snippets.

@matschaffer
Created October 21, 2008 04:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matschaffer/18247 to your computer and use it in GitHub Desktop.
Save matschaffer/18247 to your computer and use it in GitHub Desktop.
RALLY.JsonApi.prototype.capitalize = function(o) {
if (typeof o == "string") {
return o.charAt(0).toUpperCase() + o.substr(1).toLowerCase();
} else {
return o;
}
};
RALLY.JsonApi.prototype.capitalizedKeys = function(data) {
var newData = {};
for(var k in data) {
newData[this.capitalize(k)] = data[k];
}
return newData;
};
RALLY.JsonApi.prototype.update = function(typeName, oid, params, processor) {
var callback = { success: function(o) { processor(o); } };
var location = this.getRefUrl(typeName, oid);
var objectName = this.capitalize(typeName)
var body = {};
body[objectName] = this.capitalizedKeys(params);
for (key in this.integrationInfo.headers) { YAHOO.util.Connect.initHeader(key, this.integrationInfo.headers[key]); }
YAHOO.util.Connect.setDefaultPostHeader('text/json');
YAHOO.util.Connect.asyncRequest('POST', this.getRefUrl(typeName, oid), callback, YAHOO.lang.JSON.stringify(body));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment