!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("axios"),require("lodash.defaults"),require("odd-error_object"),require("odd-fetching_data_options_service")):"function"==typeof define&&define.amd?define("odd-resource_model",["axios","lodash.defaults","odd-error_object","odd-fetching_data_options_service"],t):"object"==typeof exports?exports["odd-resource_model"]=t(require("axios"),require("lodash.defaults"),require("odd-error_object"),require("odd-fetching_data_options_service")):e["odd-resource_model"]=t(e.axios,e["lodash.defaults"],e["odd-error_object"],e["odd-fetching_data_options_service"])}("undefined"!=typeof self?self:this,function(e,t,r,o){return function(e){function t(o){if(r[o])return r[o].exports;var i=r[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,r){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),u=r(1),a=o(u),s=r(2),d=o(s),c=r(3),f=o(c),l=r(4),h=o(l),p=new WeakMap,v={apiPath:"/api",apiVersion:"v1",scope:"web",resourceType:"resources",attributes:[],editableAttributes:[]},y=function(){function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,e),p.set(this,(0,d.default)(r,v)),p.get(this).attributes.forEach(function(e){t[e]=o[e]}),this.errors=new f.default}return n(e,[{key:"save",value:function(){return this.isNewRecord()?a.default.post(this.apiBasePath(),this.requestBody()):a.default.put(this.apiBasePath()+"/"+this.id,this.requestBody())}},{key:"destroy",value:function(){return a.default.delete(this.apiBasePath()+"/"+this.id)}},{key:"apiBasePath",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{withResourceType:!0},t=p.get(this).apiPath+"/"+p.get(this).apiVersion+"/"+p.get(this).scope;return e.withResourceType&&(t+="/"+p.get(this).resourceType),t}},{key:"attributes",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r={};return t.all?p.get(this).attributes.forEach(function(t){r[t]=e[t]}):p.get(this).editableAttributes.forEach(function(t){r[t]=e[t]}),r}},{key:"isNewRecord",value:function(){return void 0===this.id}},{key:"isDataLoaded",value:function(){return"string"==typeof this.id}},{key:"requestBody",value:function(){return{data:{type:p.get(this).resourceType,attributes:this.attributes()}}}}],[{key:"all",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a.default.get((new this).apiBasePath()+"?"+h.default.call(e))}},{key:"find",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return a.default.get((new this).apiBasePath()+"/"+e+"?"+h.default.call(t))}}]),e}();t.default=y,e.exports=t.default},function(t,r){t.exports=e},function(e,r){e.exports=t},function(e,t){e.exports=r},function(e,t){e.exports=o}])});