UNPKG

24.1 kBJavaScriptView Raw
1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("lodash"),require("@angular/common/http"),require("core-js/fn/object"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("ngx-restangular",["exports","@angular/core","lodash","@angular/common/http","core-js/fn/object","rxjs","rxjs/operators"],t):t(e["ngx-restangular"]={},e.ng.core,null,e.ng.common.http,null,e.rxjs,e.rxjs.operators)}(this,function(e,t,B,o,V,G,s){"use strict";function i(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,s,a=r.call(e),i=[];try{for(;(void 0===t||0<t--)&&!(n=a.next()).done;)i.push(n.value)}catch(o){s={error:o}}finally{try{n&&!n.done&&(r=a["return"])&&r.call(a)}finally{if(s)throw s.error}}return i}function a(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(i(arguments[t]));return e}var n=new t.InjectionToken("restangularWithConfig");function u(e){var t=i(e,2),r=t[0],n=t[1],s=[],a=r;return B.isArray(r)&&(s=r,a=n),{fn:a,arrServices:s}}var r=function(){function i(){}return i.createRequest=function(e){var t=i.createRequestQueryParams(e.params),r=i.createRequestHeaders(e.headers),n=e.method.toUpperCase(),s=e.withCredentials||!1,a=new o.HttpRequest(n,e.url,e.data,{headers:r,params:t,responseType:e.responseType,withCredentials:s});return 0<=["GET","DELETE","HEAD","JSONP","OPTIONS"].indexOf(n)&&(a=new o.HttpRequest(n,e.url,{headers:r,params:t,responseType:e.responseType,withCredentials:s})),a},i.createRequestQueryParams=function(e){var r=V.assign({},e),n=new o.HttpParams,t=function(t){var e=r[t];Array.isArray(e)?e.forEach(function(e){n=n.append(t,e)}):("object"==typeof e&&(e=JSON.stringify(e)),n=n.append(t,e))};for(var s in r)t(s);return n},i.createRequestHeaders=function(e){for(var t in e){void 0===e[t]&&delete e[t]}return new o.HttpHeaders(V.assign({},e))},i}(),l=function(){function e(e){this.http=e}return e.prototype.createRequest=function(e){var t=r.createRequest(e);return this.request(t)},e.prototype.request=function(t){var r=this;return this.http.handle(t).pipe(s.filter(function(e){return e instanceof o.HttpResponse}),s.map(function(e){return e.ok?e:G.throwError(new o.HttpErrorResponse(e))}),s.map(function(e){return e.config={params:t},e}),s.catchError(function(e){return e.request=t,e.data=e.error,e.repeatRequest=function(e){return r.request(e||t)},G.throwError(e)}))},e.decorators=[{type:t.Injectable}],e.ctorParameters=function(){return[{type:o.HttpBackend}]},e}();function k(i,p){i.configuration=p;var t=["get","head","options","trace","getlist"];p.isSafe=function(e){return B.includes(t,e.toLowerCase())};var r=/^https?:\/\//i;p.isAbsoluteUrl=function(e){return B.isUndefined(p.absoluteUrl)||B.isNull(p.absoluteUrl)?e&&r.test(e):p.absoluteUrl},p.absoluteUrl=!!B.isUndefined(p.absoluteUrl)||p.absoluteUrl,i.setSelfLinkAbsoluteUrl=function(e){p.absoluteUrl=e},p.baseUrl=B.isUndefined(p.baseUrl)?"":p.baseUrl,i.setBaseUrl=function(e){return p.baseUrl=/\/$/.test(e)?e.substring(0,e.length-1):e,this},p.extraFields=p.extraFields||[],i.setExtraFields=function(e){return p.extraFields=e,this},p.defaultHttpFields=p.defaultHttpFields||{},i.setDefaultHttpFields=function(e){return p.defaultHttpFields=e,this},p.plainByDefault=p.plainByDefault||!1,i.setPlainByDefault=function(e){return p.plainByDefault=!0===e,this},p.withHttpValues=function(e,t){return B.defaults(t,e,p.defaultHttpFields)},p.encodeIds=!!B.isUndefined(p.encodeIds)||p.encodeIds,i.setEncodeIds=function(e){p.encodeIds=e},p.defaultRequestParams=p.defaultRequestParams||{get:{},post:{},put:{},remove:{},common:{}},i.setDefaultRequestParams=function(e,t){var r=[],n=t||e;return B.isUndefined(t)?r.push("common"):B.isArray(e)?r=e:r.push(e),B.each(r,function(e){p.defaultRequestParams[e]=n}),this},i.requestParams=p.defaultRequestParams,p.defaultHeaders=p.defaultHeaders||{},i.setDefaultHeaders=function(e){return p.defaultHeaders=e,i.defaultHeaders=p.defaultHeaders,this},i.defaultHeaders=p.defaultHeaders,p.defaultResponseMethod=p.defaultResponseMethod||"promise",i.setDefaultResponseMethod=function(e){return p.defaultResponseMethod=e,i.defaultResponseMethod=p.defaultResponseMethod,this},i.defaultResponseMethod=p.defaultResponseMethod,p.methodOverriders=p.methodOverriders||[],i.setMethodOverriders=function(e){var t=B.extend([],e);return p.isOverridenMethod("delete",t)&&t.push("remove"),p.methodOverriders=t,this},p.jsonp=!B.isUndefined(p.jsonp)&&p.jsonp,i.setJsonp=function(e){p.jsonp=e},p.isOverridenMethod=function(t,e){var r=e||p.methodOverriders;return!B.isUndefined(B.find(r,function(e){return e.toLowerCase()===t.toLowerCase()}))},p.urlCreator=p.urlCreator||"path",i.setUrlCreator=function(e){if(!B.has(p.urlCreatorFactory,e))throw new Error("URL Path selected isn't valid");return p.urlCreator=e,this},p.restangularFields=p.restangularFields||{id:"id",route:"route",parentResource:"parentResource",restangularCollection:"restangularCollection",cannonicalId:"__cannonicalId",etag:"restangularEtag",selfLink:"href",get:"get",getList:"getList",put:"put",post:"post",remove:"remove",head:"head",trace:"trace",options:"options",patch:"patch",getRestangularUrl:"getRestangularUrl",getRequestedUrl:"getRequestedUrl",putElement:"putElement",addRestangularMethod:"addRestangularMethod",getParentList:"getParentList",clone:"clone",ids:"ids",httpConfig:"_$httpConfig",reqParams:"reqParams",one:"one",all:"all",several:"several",oneUrl:"oneUrl",allUrl:"allUrl",customPUT:"customPUT",customPATCH:"customPATCH",customPOST:"customPOST",customDELETE:"customDELETE",customGET:"customGET",customGETLIST:"customGETLIST",customOperation:"customOperation",doPUT:"doPUT",doPATCH:"doPATCH",doPOST:"doPOST",doDELETE:"doDELETE",doGET:"doGET",doGETLIST:"doGETLIST",fromServer:"fromServer",withConfig:"withConfig",withHttpConfig:"withHttpConfig",singleOne:"singleOne",plain:"plain",save:"save",restangularized:"restangularized"},i.setRestangularFields=function(e){return p.restangularFields=B.extend({},p.restangularFields,e),this},p.isRestangularized=function(e){return!!e[p.restangularFields.restangularized]},p.setFieldToElem=function(e,t,r){var n=e.split("."),s=t;B.each(B.initial(n),function(e){s[e]={},s=s[e]});var a=B.last(n);return s[a]=r,this},p.getFieldFromElem=function(e,t){var r=e.split("."),n=t;return B.each(r,function(e){n&&(n=n[e])}),B.clone(n)},p.setIdToElem=function(e,t){return p.setFieldToElem(p.restangularFields.id,e,t),this},p.getIdFromElem=function(e){return p.getFieldFromElem(p.restangularFields.id,e)},p.isValidId=function(e){return""!==e&&!B.isUndefined(e)&&!B.isNull(e)},p.setUrlToElem=function(e,t){return p.setFieldToElem(p.restangularFields.selfLink,e,t),this},p.getUrlFromElem=function(e){return p.getFieldFromElem(p.restangularFields.selfLink,e)},p.useCannonicalId=!B.isUndefined(p.useCannonicalId)&&p.useCannonicalId,i.setUseCannonicalId=function(e){return p.useCannonicalId=e,this},p.getCannonicalIdFromElem=function(e){var t=e[p.restangularFields.cannonicalId];return p.isValidId(t)?t:p.getIdFromElem(e)},p.responseInterceptors=p.responseInterceptors?a(p.responseInterceptors):[],p.defaultResponseInterceptor=function(e){return e||{}},p.responseExtractor=function(e,t,r,n,s,a){var i=B.clone(p.responseInterceptors);i.push(p.defaultResponseInterceptor);var o=e;return B.each(i,function(e){o=e(o,t,r,n,s,a)}),o},i.addResponseInterceptor=function(e){return p.responseInterceptors.push(e),this},p.errorInterceptors=p.errorInterceptors?a(p.errorInterceptors):[],i.addErrorInterceptor=function(e){return p.errorInterceptors=a([e],p.errorInterceptors),this},i.setResponseInterceptor=i.addResponseInterceptor,i.setResponseExtractor=i.addResponseInterceptor,i.setErrorInterceptor=i.addErrorInterceptor,p.requestInterceptors=p.requestInterceptors?a(p.requestInterceptors):[],p.defaultInterceptor=function(e,t,r,n,s,a,i){return{element:e,headers:s,params:a,httpConfig:i}},p.fullRequestInterceptor=function(e,n,s,a,t,r,i){var o=B.clone(p.requestInterceptors),u=p.defaultInterceptor(e,n,s,a,t,r,i);return B.reduce(o,function(e,t){var r=t(e.element,n,s,a,e.headers,e.params,e.httpConfig);return B.extend(e,r)},u)},i.addRequestInterceptor=function(o){return p.requestInterceptors.push(function(e,t,r,n,s,a,i){return{headers:s,params:a,element:o(e,t,r,n),httpConfig:i}}),this},i.setRequestInterceptor=i.addRequestInterceptor,i.addFullRequestInterceptor=function(e){return p.requestInterceptors.push(e),this},i.setFullRequestInterceptor=i.addFullRequestInterceptor,p.onBeforeElemRestangularized=p.onBeforeElemRestangularized||function(e){return e},i.setOnBeforeElemRestangularized=function(e){return p.onBeforeElemRestangularized=e,this},i.setRestangularizePromiseInterceptor=function(e){return p.restangularizePromiseInterceptor=e,this},p.onElemRestangularized=p.onElemRestangularized||function(e){return e},i.setOnElemRestangularized=function(e){return p.onElemRestangularized=e,this},p.shouldSaveParent=p.shouldSaveParent||function(){return!0},i.setParentless=function(t){return B.isArray(t)?p.shouldSaveParent=function(e){return!B.includes(t,e)}:B.isBoolean(t)&&(p.shouldSaveParent=function(){return!t}),this},p.suffix=B.isUndefined(p.suffix)?null:p.suffix,i.setRequestSuffix=function(e){return p.suffix=e,this},p.transformers=p.transformers||{},i.addElementTransformer=function(e,t,r){var n=null,s=null;2===arguments.length?s=t:(s=r,n=t);var a=p.transformers[e];return a||(a=p.transformers[e]=[]),a.push(function(e,t){return B.isNull(n)||e===n?s(t):t}),i},i.extendCollection=function(e,t){return i.addElementTransformer(e,!0,t)},i.extendModel=function(e,t){return i.addElementTransformer(e,!1,t)},p.transformElem=function(e,t,r,n,s){if(!s&&!p.transformLocalElements&&!e[p.restangularFields.fromServer])return e;var a=p.transformers[r],i=e;return a&&B.each(a,function(e){i=e(t,i)}),p.onElemRestangularized(i,t,r,n)},p.transformLocalElements=!B.isUndefined(p.transformLocalElements)&&p.transformLocalElements,i.setTransformOnlyServerElements=function(e){p.transformLocalElements=!e},p.fullResponse=!B.isUndefined(p.fullResponse)&&p.fullResponse,i.setFullResponse=function(e){return p.fullResponse=e,this},p.urlCreatorFactory={};var e=function(){};e.prototype.setConfig=function(e){return this.config=e,this},e.prototype.parentsArray=function(e){for(var t=[];e;)t.push(e),e=e[this.config.restangularFields.parentResource];return t.reverse()},e.prototype.resource=function(e,t,r,n,s,a,i,o){var u=B.defaults(s||{},this.config.defaultRequestParams.common),l=B.defaults(n||{},this.config.defaultHeaders);i&&(p.isSafe(o)?l["If-None-Match"]=i:l["If-Match"]=i);var d=this.base(e);if(a){var c="";/\/$/.test(d)||(c+="/"),d+=c+=a}return this.config.suffix&&-1===d.indexOf(this.config.suffix,d.length-this.config.suffix.length)&&!this.config.getUrlFromElem(e)&&(d+=this.config.suffix),e[this.config.restangularFields.httpConfig]=undefined,function f(t,n,s,a){var i={};return B.each(B.keys(a),function(e){var r=a[e];r.params=B.extend({},r.params,t.defaultRequestParams[r.method.toLowerCase()]),B.isEmpty(r.params)&&delete r.params,t.isSafe(r.method)?i[e]=function(){var e=B.extend(r,{url:s});return n.createRequest(e)}:i[e]=function(e){var t=B.extend(r,{url:s,data:e});return n.createRequest(t)}}),i}(this.config,t,d,{getList:this.config.withHttpValues(r,{method:"GET",params:u,headers:l}),get:this.config.withHttpValues(r,{method:"GET",params:u,headers:l}),jsonp:this.config.withHttpValues(r,{method:"jsonp",params:u,headers:l}),put:this.config.withHttpValues(r,{method:"PUT",params:u,headers:l}),post:this.config.withHttpValues(r,{method:"POST",params:u,headers:l}),remove:this.config.withHttpValues(r,{method:"DELETE",params:u,headers:l}),head:this.config.withHttpValues(r,{method:"HEAD",params:u,headers:l}),trace:this.config.withHttpValues(r,{method:"TRACE",params:u,headers:l}),options:this.config.withHttpValues(r,{method:"OPTIONS",params:u,headers:l}),patch:this.config.withHttpValues(r,{method:"PATCH",params:u,headers:l})})};var n=function(){};(n.prototype=new e).normalizeUrl=function(e){var t=/((?:http[s]?:)?\/\/)?(.*)?/.exec(e);return t[2]=t[2].replace(/[\\\/]+/g,"/"),"undefined"!=typeof t[1]?t[1]+t[2]:t[2]},n.prototype.base=function(e){var i=this;return B.reduce(this.parentsArray(e),function(e,t){var r,n=i.config.getUrlFromElem(t);if(n){if(i.config.isAbsoluteUrl(n))return n;r=n}else if(r=t[i.config.restangularFields.route],t[i.config.restangularFields.restangularCollection]){var s=t[i.config.restangularFields.ids];s&&(r+="/"+s.join(","))}else{var a=void 0;a=i.config.useCannonicalId?i.config.getCannonicalIdFromElem(t):i.config.getIdFromElem(t),p.isValidId(a)&&!t.singleOne&&(r+="/"+(i.config.encodeIds?encodeURIComponent(a):a))}return e=e.replace(/\/$/,"")+"/"+r,i.normalizeUrl(e)},this.config.baseUrl)},n.prototype.fetchUrl=function(e,t){var r=this.base(e);return t&&(r+="/"+t),r},n.prototype.fetchRequestedUrl=function(e,t){var r=this.fetchUrl(e,t),n=e[p.restangularFields.reqParams];function s(e,t){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,t?"%20":"+")}if(!n)return r+(this.config.suffix||"");var a=[];return function i(e,t,r){for(var n=function a(e){var t=[];for(var r in e)e.hasOwnProperty(r)&&t.push(r);return t.sort()}(e),s=0;s<n.length;s++)t.call(r,e[n[s]],n[s]);return n}(n,function(e,t){null!==e&&e!==undefined&&(B.isArray(e)||(e=[e]),B.forEach(e,function(e){B.isObject(e)&&(e=JSON.stringify(e)),a.push(s(t)+"="+s(e))}))}),r+(this.config.suffix||"")+(-1===r.indexOf("?")?"?":"&")+a.join("&")},p.urlCreatorFactory.path=n}var d=function(){function e(e,t,r){this.configObj=e,this.injector=t,this.http=r,this.provider=new c(r);var n=this.provider.$get();V.assign(this,n),this.setDefaultConfig()}return e.prototype.setDefaultConfig=function(){var e,t=this;if(this.configObj&&B.isFunction(this.configObj.fn)){var r=B.map(this.configObj.arrServices,function(e){return t.injector.get(e)});(e=this.configObj).fn.apply(e,a([this.provider],r))}},e.decorators=[{type:t.Injectable}],e.ctorParameters=function(){return[{type:undefined,decorators:[{type:t.Optional},{type:t.Inject,args:[n]}]},{type:t.Injector},{type:l}]},e}();function c(D){var e={};k(this,e),this.$get=function t(){return function n(b){var E={};var R=new b.urlCreatorFactory[b.urlCreator];R.setConfig(b);function u(e,t,r,n,s){if(t[b.restangularFields.route]=r,t[b.restangularFields.getRestangularUrl]=B.bind(R.fetchUrl,R,t),t[b.restangularFields.getRequestedUrl]=B.bind(R.fetchRequestedUrl,R,t),t[b.restangularFields.addRestangularMethod]=B.bind(A,t),t[b.restangularFields.clone]=B.bind(h,t),t[b.restangularFields.reqParams]=B.isEmpty(n)?null:n,t[b.restangularFields.withHttpConfig]=B.bind(w,t),t[b.restangularFields.plain]=B.bind(C,t,t),t[b.restangularFields.restangularized]=!0,t[b.restangularFields.one]=B.bind(l,t,t),t[b.restangularFields.all]=B.bind(d,t,t),t[b.restangularFields.several]=B.bind(c,t,t),t[b.restangularFields.oneUrl]=B.bind(f,t,t),t[b.restangularFields.allUrl]=B.bind(p,t,t),t[b.restangularFields.fromServer]=!!s,e&&b.shouldSaveParent(r)){var a=b.getIdFromElem(e),i=b.getUrlFromElem(e),o=B.union(B.values(B.pick(b.restangularFields,["route","singleOne","parentResource"])),b.extraFields),u=B.pick(e,o);b.isValidId(a)&&b.setIdToElem(u,a,r),b.isValidId(i)&&b.setUrlToElem(u,i,r),t[b.restangularFields.parentResource]=u}else t[b.restangularFields.parentResource]=null;return t}function l(e,t,r,n){var s;if(B.isNumber(t)||B.isNumber(e))throw s="You're creating a Restangular entity with the number ",s+="instead of the route or the parent. For example, you can't call .one(12).",new Error(s);if(B.isUndefined(t))throw s="You're creating a Restangular entity either without the path. ",s+="For example you can't call .one(). Please check if your arguments are valid.",new Error(s);var a={};return b.setIdToElem(a,r,t),b.setFieldToElem(b.restangularFields.singleOne,a,n),U(e,a,t,!1)}function d(e,t){return m(e,[],t,!1)}function c(e,t){var r=[];return r[b.restangularFields.ids]=Array.prototype.splice.call(arguments,2),m(e,r,t,!1)}function f(e,t,r){if(!t)throw new Error("Route is mandatory when creating new Restangular objects.");var n={};return b.setUrlToElem(n,r,t),U(e,n,t,!1)}function p(e,t,r){if(!t)throw new Error("Route is mandatory when creating new Restangular objects.");var n={};return b.setUrlToElem(n,r,t),m(e,n,t,!1)}function I(e,t,r){return e.pipe(s.filter(function(e){return!!e}))}function y(e,t,r,n){B.extend(n,r),b.fullResponse?e.next(B.extend(t,{data:r})):e.next(r),e.complete()}function C(e){if(B.isArray(e)){var t=[];return B.each(e,function(e){t.push(b.isRestangularized(e)?C(e):e)}),t}return B.omit(e,B.values(B.omit(b.restangularFields,"id")))}function g(s){s[b.restangularFields.customOperation]=B.bind(z,s);var t={get:z,"delete":z};B.each(["put","patch","post"],function(e){t[e]=function(e,t,r,n,s){return B.bind(z,this)(e,r,n,s,t)}}),B.each(t,function(t,r){var n="delete"===r?"remove":r;B.each(["do","custom"],function(e){s[e+r.toUpperCase()]=B.bind(t,s,n)})}),s[b.restangularFields.customGETLIST]=B.bind(F,s),s[b.restangularFields.doGETLIST]=s[b.restangularFields.customGETLIST]}function h(e,t){void 0===t&&(t={});var r=V.assign(t,e);return U(r[b.restangularFields.parentResource],r,r[b.restangularFields.route],!0)}function U(e,t,r,n,s,a){var i=b.onBeforeElemRestangularized(t,!1,r),o=u(e,i,r,a,n);return b.useCannonicalId&&(o[b.restangularFields.cannonicalId]=b.getIdFromElem(o)),s&&(o[b.restangularFields.getParentList]=function(){return s}),o[b.restangularFields.restangularCollection]=!1,o[b.restangularFields.get]=B.bind(P,o),o[b.restangularFields.getList]=B.bind(F,o),o[b.restangularFields.put]=B.bind(H,o),o[b.restangularFields.post]=B.bind(O,o),o[b.restangularFields.remove]=B.bind(x,o),o[b.restangularFields.head]=B.bind(j,o),o[b.restangularFields.trace]=B.bind(S,o),o[b.restangularFields.options]=B.bind(L,o),o[b.restangularFields.patch]=B.bind(M,o),o[b.restangularFields.save]=B.bind(q,o),g(o),b.transformElem(o,!1,r,E,!0)}function m(e,t,r,n,s){var a=b.onBeforeElemRestangularized(t,!0,r),i=u(e,a,r,s,n);return i[b.restangularFields.restangularCollection]=!0,i[b.restangularFields.post]=B.bind(O,i,null),i[b.restangularFields.remove]=B.bind(x,i),i[b.restangularFields.head]=B.bind(j,i),i[b.restangularFields.trace]=B.bind(S,i),i[b.restangularFields.putElement]=B.bind(v,i),i[b.restangularFields.options]=B.bind(L,i),i[b.restangularFields.patch]=B.bind(M,i),i[b.restangularFields.get]=B.bind(o,i),i[b.restangularFields.getList]=B.bind(F,i,null),g(i),b.transformElem(i,!0,r,E,!0)}function e(t,e,r){var n=m(t,e,r,!1);return B.each(n,function(e){e&&U(t,e,r,!1)}),n}function o(e,t,r){return this.customGET(e.toString(),t,r)}function v(r,e,t){var n=this,s=this[r],a=new G.BehaviorSubject(null),i=[];return i=b.transformElem(i,!0,s[b.restangularFields.route],E),s.put(e,t).subscribe(function(e){var t=h(n);t[r]=e,i=t,a.next(t)},function(e){a.error(e)},function(){a.complete()}),I(a,!0,i)}function T(e,t,r,n,s,a){var i=b.responseExtractor(e,t,r,n,s,a),o=s.headers.get("ETag");return i&&o&&(i[b.restangularFields.etag]=o),i}function F(a,e,t){var i=this,o=new G.BehaviorSubject(null),u="getList",l=R.fetchUrl(this,a),d=a||i[b.restangularFields.route],r=b.fullRequestInterceptor(null,u,d,l,t||{},e||{},this[b.restangularFields.httpConfig]||{}),c=[];c=b.transformElem(c,!0,d,E);var n="getList";b.jsonp&&(n="jsonp");var s=function(e){var t=e.body,r=e.config.params,n=T(t,u,d,l,e,o);if((B.isUndefined(n)||""===n)&&(n=[]),!B.isArray(n))throw new Error("Response for getList SHOULD be an array and not an object or something else");if(!0===b.plainByDefault)return y(o,e,n,c);var s=B.map(n,function(e){return i[b.restangularFields.restangularCollection]?U(i[b.restangularFields.parentResource],e,i[b.restangularFields.route],!0,n):U(i,e,a,!0,n)});s=B.extend(n,s),i[b.restangularFields.restangularCollection]?y(o,e,m(i[b.restangularFields.parentResource],s,i[b.restangularFields.route],!0,r),c):y(o,e,m(i,s,a,!0,r),c)};return R.resource(this,D,r.httpConfig,r.headers,r.params,a,this[b.restangularFields.etag],u)[n]().subscribe(s,function(t){304===t.status&&i[b.restangularFields.restangularCollection]?y(o,t,i,c):B.every(b.errorInterceptors,function(e){return!1!==e(t,o,s)})&&o.error(t)}),I(o,!0,c)}function w(e){return this[b.restangularFields.httpConfig]=e,this}function q(e,t){return this[b.restangularFields.fromServer]?this[b.restangularFields.put](e,t):B.bind(a,this)("post",undefined,e,undefined,t)}function a(a,e,t,r,n){var i=this,o=new G.BehaviorSubject(null),s=t||{},u=e||this[b.restangularFields.route],l=R.fetchUrl(this,e),d=r||this,c=d[b.restangularFields.etag]||("post"!==a?this[b.restangularFields.etag]:null);B.isObject(d)&&b.isRestangularized(d)&&(d=C(d));var f=b.fullRequestInterceptor(d,a,u,l,n||{},s||{},this[b.restangularFields.httpConfig]||{}),p={};p=b.transformElem(p,!1,u,E);var g=function(e){var t=B.get(e,"body"),r=B.get(e,"config.params"),n=T(t,a,u,l,e,o);if(n){var s=void 0;if(!0===b.plainByDefault)return y(o,e,n,p);"post"!==a||i[b.restangularFields.restangularCollection]?(s=U(i[b.restangularFields.parentResource],n,i[b.restangularFields.route],!0,null,r))[b.restangularFields.singleOne]=i[b.restangularFields.singleOne]:s=U(i[b.restangularFields.parentResource],n,u,!0,null,r),y(o,e,s,p)}else y(o,e,undefined,p)},h=function(t){304===t.status&&b.isSafe(a)?y(o,t,i,p):B.every(b.errorInterceptors,function(e){return!1!==e(t,o,g)})&&o.error(t)},m=a,v=B.extend({},f.headers),F=b.isOverridenMethod(a);return F?(m="post",v=B.extend(v,{"X-HTTP-Method-Override":"remove"===a?"DELETE":a.toUpperCase()})):b.jsonp&&"get"===m&&(m="jsonp"),b.isSafe(a)?F?R.resource(this,D,f.httpConfig,v,f.params,e,c,m)[m]({}).subscribe(g,h):R.resource(this,D,f.httpConfig,v,f.params,e,c,m)[m]().subscribe(g,h):R.resource(this,D,f.httpConfig,v,f.params,e,c,m)[m](f.element).subscribe(g,h),I(o,!1,p)}function P(e,t){return B.bind(a,this)("get",undefined,e,undefined,t)}function x(e,t){return B.bind(a,this)("remove",undefined,e,undefined,t)}function H(e,t){return B.bind(a,this)("put",undefined,e,undefined,t)}function O(e,t,r,n){return B.bind(a,this)("post",e,r,t,n)}function j(e,t){return B.bind(a,this)("head",undefined,e,undefined,t)}function S(e,t){return B.bind(a,this)("trace",undefined,e,undefined,t)}function L(e,t){return B.bind(a,this)("options",undefined,e,undefined,t)}function M(e,t,r){return B.bind(a,this)("patch",undefined,t,e,r)}function z(e,t,r,n,s){return B.bind(a,this)(e,t,r,s,n)}function A(e,t,r,s,a,i){var o;o="getList"===t?B.bind(F,this,r):B.bind(z,this,t,r);var n=function(e,t,r){var n=B.defaults({params:e,headers:t,elem:r},{params:s,headers:a,elem:i});return o(n.params,n.headers,n.elem)};b.isSafe(t)?this[e]=n:this[e]=function(e,t,r){return n(t,r,e)}}function t(e){var t=B.clone(B.omit(b,"configuration"));return k(t,t),e(t),n(t)}function r(e,t){var r=B.values(b.restangularFields),n={},s=(t||E).all(e);for(var a in n.one=B.bind(l,t||E,t,e),n.all=B.bind(s.all,s),n.post=B.bind(s.post,s),n.getList=B.bind(s.getList,s),n.withHttpConfig=B.bind(s.withHttpConfig,s),n.get=B.bind(s.get,s),s)s.hasOwnProperty(a)&&B.isFunction(s[a])&&!B.includes(r,a)&&(n[a]=B.bind(s[a],s));return n}k(E,b);E.copy=B.bind(h,E);E.service=B.bind(r,E);E.withConfig=B.bind(t,E);E.one=B.bind(l,E,null);E.all=B.bind(d,E,null);E.several=B.bind(c,E,null);E.oneUrl=B.bind(f,E,null);E.allUrl=B.bind(p,E,null);E.stripRestangular=B.bind(C,E);E.restangularizeElement=B.bind(U,E);E.restangularizeCollection=B.bind(e,E);return E}(e)}}var f=new t.InjectionToken("configObj"),p=function(){function r(e){if(e)throw new Error("RestangularModule is already loaded. Import it in the AppModule only")}return r.forRoot=function(e,t){return{ngModule:r,providers:[{provide:f,useValue:[e,t]},{provide:n,useFactory:u,deps:[f]}]}},r.decorators=[{type:t.NgModule,args:[{imports:[o.HttpClientModule],providers:[l,d]}]}],r.ctorParameters=function(){return[{type:r,decorators:[{type:t.Optional},{type:t.SkipSelf}]}]},r}();e.RestangularModule=p,e.Restangular=d,e.RestangularHttp=l,e.ɵb=n,e.ɵc=u,e.ɵa=f,Object.defineProperty(e,"__esModule",{value:!0})});
2//# sourceMappingURL=ngx-restangular.umd.min.js.map
\No newline at end of file