Created
October 21, 2008 04:10
-
-
Save matschaffer/18247 to your computer and use it in GitHub Desktop.
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
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