Guest User

Untitled

a guest
Feb 20th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. RALLY.JsonApi.prototype.capitalize = function(o) {
  2. if (typeof o == "string") {
  3. return o.charAt(0).toUpperCase() + o.substr(1).toLowerCase();
  4. } else {
  5. return o;
  6. }
  7. };
  8.  
  9. RALLY.JsonApi.prototype.capitalizedKeys = function(data) {
  10. var newData = {};
  11. for(var k in data) {
  12. newData[this.capitalize(k)] = data[k];
  13. }
  14. return newData;
  15. };
  16.  
  17. RALLY.JsonApi.prototype.update = function(typeName, oid, params, processor) {
  18. var callback = { success: function(o) { processor(o); } };
  19. var location = this.getRefUrl(typeName, oid);
  20. var objectName = this.capitalize(typeName)
  21. var body = {};
  22. body[objectName] = this.capitalizedKeys(params);
  23.  
  24. for (key in this.integrationInfo.headers) { YAHOO.util.Connect.initHeader(key, this.integrationInfo.headers[key]); }
  25. YAHOO.util.Connect.setDefaultPostHeader('text/json');
  26. YAHOO.util.Connect.asyncRequest('POST', this.getRefUrl(typeName, oid), callback, YAHOO.lang.JSON.stringify(body));
  27. };
Add Comment
Please, Sign In to add comment