//>>built
define("dstore/Rest","dojo/request dojo/when dojo/_base/lang dojo/json dojo/io-query dojo/_base/declare ./Request".split(" "),function(e,l,f,g,p,m,n){return m(n,{stringify:g.stringify,_getTarget:function(c){var a=this.target;return"/"==a.slice(-1)?a+c:a+"/"+c},get:function(c,a){a=a||{};var d=f.mixin({Accept:this.accepts},this.headers,a.headers||a),b=this;return e(this._getTarget(c),{headers:d}).then(function(a){return b._restore(b.parse(a),!0)})},autoEmitEvents:!1,put:function(c,a){a=a||{};var d=
"id"in a?a.id:this.getIdentity(c),b="undefined"!==typeof d,h=this,g="beforeId"in a?null===a.beforeId?{"Put-Default-Position":"end"}:{"Put-Before":a.beforeId}:b&&!1!==a.overwrite?null:{"Put-Default-Position":this.defaultNewToStart?"start":"end"},k=e(b?this._getTarget(d):this.target,{method:b&&!a.incremental?"PUT":"POST",data:this.stringify(c),headers:f.mixin({"Content-Type":"application/json",Accept:this.accepts,"If-Match":!0===a.overwrite?"*":null,"If-None-Match":!1===a.overwrite?"*":null},g,this.headers,
a.headers)});return k.then(function(b){var d={};"beforeId"in a&&(d.beforeId=a.beforeId);b=d.target=b&&h._restore(h.parse(b),!0)||c;l(k.response,function(a){h.emit(201===a.status?"add":"update",d)});return b})},add:function(c,a){a=a||{};a.overwrite=!1;return this.put(c,a)},remove:function(c,a){a=a||{};var d=this;return e(this._getTarget(c),{method:"DELETE",headers:f.mixin({},this.headers,a.headers)}).then(function(a){var b=a&&d.parse(a);d.emit("delete",{id:c,target:b});return a?b:!0})}})});
//# sourceMappingURL=Rest.js.map