define(["ember","emberdata","ajax"],function(a,b,c){var d=a.get;return b.RESTAdapter.extend({defaultSerializer:"-rest",find:function(a,b,c,e){var f={},c=d(e,"id"),g=a.serializerFor(b.typeKey),h=g.get("primaryKey");return f[h]=c,this.ajax(this.buildURL(b.typeKey,c,e),"POST",this._mapMethod("find",b,f))},_mapMethod:function(a,b,c){var d=b.methods[c.method||a],e=d.args||{},f={Method:d.map};for(var g in c)"method"!=g&&(e[g]?f[e[g]]=c[g]:f[g]=c[g]);return{data:f}},findAll:function(a,b){return this.ajax(this.buildURL(b.typeKey),"POST",this._mapMethod("all",b,{}))},findQuery:function(a,b,c){return this.ajax(this.buildURL(b.typeKey),"POST",this._mapMethod("query",b,c))},findMany:function(a,b,c,d){return this.ajax(this.buildURL(b.typeKey,c,d),"GET",{data:{ids:c}})},createRecord:function(a,b,c){var d={},e=a.serializerFor(b.typeKey);return e.serializeIntoHash(d,b,c,{includeId:!0}),d=d[b.typeKey],this.ajax(this.buildURL(b.typeKey,null,c),"POST",this._mapMethod("create",b,d))},updateRecord:function(a,b,c){var e={},f=d(c,"id"),g=a.serializerFor(b.typeKey);return g.serializeIntoHash(e,b,c,{includeId:!0}),e=e[b.typeKey],this.ajax(this.buildURL(b.typeKey,f,c),"POST",this._mapMethod("update",b,e))},updateHash:function(a,b,c,d){var e=a.modelFor(b),f=(a.adapterFor(e.typeKey),a.serializerFor(e.typeKey));return d[f.get("primaryKey")]=c,this.ajax("","POST",this._mapMethod("update",e,d))},deleteRecord:function(a,b,c){var e={},f=d(c,"id"),g=a.serializerFor(b.typeKey),h=g.get("primaryKey");return e[h]=f,this.ajax(this.buildURL(b.typeKey,f,c),"POST",this._mapMethod("delete",b,e))},buildURL:function(){return d(this,"host")},ajaxError:function(a){return a&&"object"==typeof a&&(a.then=null),a},ajaxSuccess:function(a,b){return b},ajax:function(a,b,d){return d.url=a,d.type=b,c.send(d)}})});