UNPKG

@shareactor/shareactor-sdk

Version:
1 lines 40.3 kB
var ShareActor=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=21)}([function(t,e,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},i=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),s=r(7),u=r(1),a=function(){function t(e){var r=this;if(function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.constructor===t)throw new u.AbstractClass;this.id=null,"string"==typeof e?this.id=e:(o(this,e),e&&!e.id&&e._id&&e._id.$oid&&(this.id=e._id.$oid));var i=function(t,e,i,s){var u=t.body;if(i||null===e)return s(null,u,t);if(Array.isArray(u)){var a=[];return u.forEach(function(t){e?a.push(new e(t)):a.push(new r.constructor(t))}),s(null,a,t)}return"object"===(void 0===u?"undefined":n(u))?e?s(null,new e(u),t):(!r.id&&u._id&&u._id.$oid&&(r.id=u._id.$oid),s(null,o(r,u),t)):s(null,u,t)};this.simpleQuery=function(t,e){var n=t.type,o=void 0===n?"get":n,a=t.id,c=void 0===a?"":a,l=t.resource,p=void 0===l?"":l,f=t.urlParams,h=void 0===f?{}:f,y=t.body,d=t.apiPath,b=t.ResConstructor,m=t.json;if(null===c)return e(new u.MethodNeedsId);var v=c&&"/"!==c[0]?"/"+c:c,_=p&&"/"!==p[0]?"/"+p:p,w=d||r.apiPath,g=m;s().query({type:o,resource:""+w+v+_,urlParams:h,body:y},function(t,r){return t||!r.ok?e(t,null,r):i(r,b,g,e)})},this.buildQuery=function(t,e){return s().query(t,function(r,n){return r||!n.ok?e(r,null,n):i(n,t.ResConstructor,t.json,e)})}}return i(t,[{key:"getAll",value:function(t,e){var r=t.urlParams,n=t.json,o=void 0!==n&&n;return this.simpleQuery({type:"get",urlParams:r,json:o},e)}},{key:"get",value:function(t,e){var r=t.urlParams,n=t.json,o=void 0!==n&&n;return this.simpleQuery({type:"get",id:this.id,urlParams:r,json:o},e)}},{key:"refresh",value:function(t,e){var r=t.urlParams,n=t.json,o=void 0!==n&&n;return this.get({urlParams:r,json:o},e)}},{key:"update",value:function(t,e){var r=t.body,n=t.urlParams,o=t.json,i=void 0!==o&&o;return this.simpleQuery({type:"put",id:this.id,urlParams:n,body:r,json:i},e)}},{key:"del",value:function(t,e){var r=t.urlParams,n=t.json,o=void 0!==n&&n;return this.simpleQuery({type:"del",id:this.id,urlParams:r,json:o},e)}},{key:"create",value:function(t,e){var r=t.body,n=t.urlParams,o=t.json,i=void 0!==o&&o;return this.simpleQuery({type:"post",urlParams:n,body:r,json:i},e)}}]),t}();t.exports=a},function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var s=function(t){function e(t){n(this,e);var r=o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return r.message=t,r.name=r.constructor.name,r}return i(e,Error),e}(),u=function(t){function e(){return n(this,e),o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,"You need to construct this object with an ID to access that method"))}return i(e,s),e}(),a=function(t){function e(t){return n(this,e),o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,'This method requires the argument "'+t+'" to be executed'))}return i(e,s),e}(),c=function(t){function e(){return n(this,e),o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,"This method is not implemented for this Object"))}return i(e,s),e}(),l=function(t){function e(){return n(this,e),o(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,"Cannot construct Abstract instances"))}return i(e,s),e}();t.exports={MethodNeedsId:u,AbstractClass:l,MethodNeedsArg:a,NotImplemented:c}},function(t,e,r){"use strict";var n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},o=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),i=r(0),s=r(5),u=function(t){function e(t){!function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this);var r=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return r.apiPath="users",r.id||(r.id="me"),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,i),o(e,[{key:"create",value:function(t,e){var r=t.body,n=t.urlParams,o=t.json,i=void 0!==o&&o;return this.simpleQuery({type:"post",apiPath:"v2/users",urlParams:n,body:r,json:i},e)}},{key:"login",value:function(t,e){var r=t.body,n=t.urlParams,o=t.json,i=void 0!==o&&o;return this.create({body:r,urlParams:n,json:i},e)}},{key:"getOrders",value:function(t,e){var r=t.urlParams,n=t.json,o=void 0!==n&&n;return this.simpleQuery({type:"get",id:this.id,resource:"orders",urlParams:r,ResConstructor:s,json:o},e)}},{key:"getRating",value:function(t,e){var r=t.urlParams;return this.simpleQuery({type:"get",id:this.id,resource:"ratings",urlParams:r,ResConstructor:null},e)}},{key:"rate",value:function(t,e){var r=t.body,n=t.urlParams;return this.simpleQuery({type:"put",id:this.id,resource:"ratings",body:r,urlParams:n,ResConstructor:null},e)}},{key:"search",value:function(t,e){var r=t.query,o=t.urlParams,i=t.json,s=void 0!==i&&i;return this.simpleQuery({type:"get",resource:"search",urlParams:n({},o,{query:r}),json:s},e)}},{key:"updateAddresses",value:function(t,e){var r=t.body,n=t.urlParams;return this.simpleQuery({type:"put",id:this.id,resource:"addresses",body:r,urlParams:n,ResConstructor:null},e)}}]),e}();t.exports=u},function(t,e,r){"use strict";var n=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),o=r(2),i=r(1),s=function(t){function e(t){!function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this);var r=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return r.apiPath="providers",r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,o),n(e,[{key:"create",value:function(t,e){var r=t.body,n=t.urlParams,o=t.json,i=void 0!==o&&o;return this.simpleQuery({type:"post",apiPath:"v2/providers",urlParams:n,body:r,json:i},e)}},{key:"find",value:function(t,e){var r=t.urlParams,n=t.json,o=void 0!==n&&n;return this.simpleQuery({type:"get",resource:"find",urlParams:r,json:o},e)}},{key:"getAvailableCount",value:function(t,e){var r=t.urlParams;return this.simpleQuery({type:"get",resource:"available-count",urlParams:r,ResConstructor:null},e)}},{key:"getAllReports",value:function(t,e){var r=t.urlParams;return this.simpleQuery({type:"get",resource:"reports-count",urlParams:r,ResConstructor:null},e)}},{key:"getReports",value:function(t,e){var r=t.urlParams;return this.simpleQuery({type:"get",id:this.id,resource:"reports-count",urlParams:r,ResConstructor:null},e)}},{key:"getAvailableOverview",value:function(t,e){var r=t.urlParams;return this.simpleQuery({type:"get",id:this.id,resource:"available-overview",urlParams:r,ResConstructor:null},e)}},{key:"getSchedule",value:function(t,e){var r=t.urlParams;return this.simpleQuery({type:"get",id:this.id,resource:"schedule",urlParams:r,ResConstructor:null},e)}},{key:"getAvailability",value:function(t,e){var r=t.urlParams;return this.simpleQuery({type:"get",id:this.id,resource:"availability",urlParams:r,ResConstructor:null},e)}},{key:"getAvailableAt",value:function(t,e){var r=t.urlParams;return this.simpleQuery({type:"get",id:this.id,resource:"available-at",urlParams:r,ResConstructor:null},e)}},{key:"getProducts",value:function(t,e){var r=t.urlParams,n=t.json,o=void 0!==n&&n;return this.simpleQuery({type:"get",id:this.id,resource:"products",urlParams:r,json:o},e)}},{key:"postProducts",value:function(t,e){var r=t.body,n=t.urlParams,o=t.json,i=void 0!==o&&o;return this.simpleQuery({type:"post",id:this.id,resource:"products",body:r,urlParams:n,json:i},e)}},{key:"updateAddresses",value:function(t,e){return t.body,t.urlParams,e(new i.NotImplemented)}}]),e}();t.exports=s},function(t,e,r){"use strict";var n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},o=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),i=r(0),s=function(t){function e(t){!function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this);var r=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return r.apiPath="products",r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,i),o(e,[{key:"search",value:function(t,e){var r=t.query,o=t.urlParams,i=t.json,s=void 0!==i&&i;return this.simpleQuery({type:"get",resource:"search",urlParams:n({},o,{query:r}),json:s},e)}}]),e}();t.exports=s},function(t,e,r){"use strict";var n=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),o=r(0),i=r(1),s=function(t){function e(t){!function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this);var r=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return r.apiPath="orders",r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,o),n(e,[{key:"getDeliveries",value:function(t,e){var r=t.urlParams;return this.simpleQuery({type:"get",id:this.id,resource:"deliveries",urlParams:r,ResConstructor:null},e)}},{key:"pay",value:function(t,e){var r=t.body,n=t.urlParams,o=t.json,i=void 0!==o&&o;return this.simpleQuery({type:"post",id:this.id,resource:"pay",body:r,urlParams:n,json:i},e)}},{key:"cancel",value:function(t,e){var r=t.body,n=t.urlParams,o=t.json,i=void 0!==o&&o;return this.simpleQuery({type:"post",id:this.id,resource:"cancel",body:r,urlParams:n,json:i},e)}},{key:"createDelivery",value:function(t,e){var r=t.body,n=t.urlParams;return this.simpleQuery({type:"post",id:this.id,resource:"deliveries",body:r,urlParams:n,ResConstructor:null},e)}},{key:"triggerDeliveryAction",value:function(t,e){var r=t.body,n=t.deliveryId,o=t.urlParams;if(!this.id)return e(new i.MethodNeedsId);if(!n)return e(new i.MethodNeedsArg("deliveryId"));var s={type:"post",resource:this.apiPath+"/"+this.id+"/deliveries/"+n,body:r,urlParams:o,ResConstructor:null};return this.buildQuery(s,e)}}]),e}();t.exports=s},function(t,e,r){"use strict";t.exports=function(t){return null!==t&&"object"==typeof t}},function(t,e,r){"use strict";var n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},o=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),i=r(19),s=void 0,u=function(){function t(e,r){!function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),this.headers=r,this.endpoint=e}return o(t,[{key:"updateHeaders",value:function(t){this.headers=t}},{key:"query",value:function(e,r){var o=e.type,s=void 0===o?"get":o,u=e.resource,a=void 0===u?"":u,c=e.urlParams,l=void 0===c?{}:c,p=e.body,f=void 0===p?null:p,h=e.headers,y=void 0===h?{}:h,d=e.endpoint,b=void 0===d?this.endpoint:d;i[s](""+b+a+t.serialize(l)).set(n({},this.headers,y,{"Content-Type":"application/json"})).send(JSON.stringify(f)).end(r)}}],[{key:"serialize",value:function(t){var e=[];return Object.keys(t).forEach(function(r){e.push(encodeURIComponent(r)+"="+encodeURIComponent(t[r]))}),e.length?"?"+e.join("&"):""}}]),t}();t.exports=function(t,e){return s||(s=new u(t,e)),s}},function(t,e,r){"use strict";var n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},o=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),i=r(0),s=function(t){function e(t){!function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this);var r=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return r.apiPath="resources",r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,i),o(e,[{key:"createBulk",value:function(t,e){var r=t.body,o=t.urlParams,i=t.json;return this.simpleQuery({type:"post",resource:"bulk",urlParams:n({},o),body:r,json:i},e)}}]),e}();t.exports=s},function(t,e,r){"use strict";var n=r(0),o=function(t){function e(t){!function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this);var r=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return r.apiPath="payment_methods",r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,n),e}();t.exports=o},function(t,e,r){"use strict";var n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},o=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),i=r(0),s=function(t){function e(t){!function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this);var r=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return r.apiPath="payments",r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,i),o(e,[{key:"search",value:function(t,e){var r=t.query,o=t.urlParams,i=t.json;return this.simpleQuery({type:"get",resource:"search",urlParams:n({},o,{query:r}),json:i},e)}}]),e}();t.exports=s},function(t,e,r){"use strict";var n=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),o=r(0),i=r(1),s=function(t){function e(t){!function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this);var r=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return r.apiPath="companies",r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,o),n(e,[{key:"getProperties",value:function(t,e){var r=t.urlParams;return this.simpleQuery({type:"get",resource:"properties",urlParams:r,ResConstructor:null},e)}},{key:"get",value:function(t,e){var r=t.urlParams,n=t.json,o=void 0!==n&&n;return this.getAll({urlParams:r,json:o},e)}},{key:"create",value:function(t,e){throw t.body,t.urlParams,new i.NotImplemented}},{key:"update",value:function(t,e){throw t.body,t.urlParams,new i.NotImplemented}},{key:"del",value:function(t,e){throw t.body,t.urlParams,new i.NotImplemented}}]),e}();t.exports=s},function(t,e,r){"use strict";var n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},o=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),i=r(0),s=r(4),u=r(3),a=function(t){function e(t){!function(t,r){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this);var r=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return r.apiPath="tags",r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,i),o(e,[{key:"search",value:function(t,e){var r=t.query,o=t.urlParams,i=t.json,s=void 0!==i&&i;return this.simpleQuery({type:"get",resource:"search",urlParams:n({},o,{query:r}),json:s},e)}},{key:"getProducts",value:function(t,e){var r=t.urlParams,n=t.json,o=void 0!==n&&n;return this.simpleQuery({type:"get",id:this.id,resource:"products",urlParams:r,json:o,ResConstructor:s},e)}},{key:"getProviders",value:function(t,e){var r=t.urlParams,n=t.json,o=void 0!==n&&n;return this.simpleQuery({type:"get",id:this.id,resource:"providers",urlParams:r,json:o,ResConstructor:u},e)}}]),e}();t.exports=a},function(t,e){function r(){this._defaults=[]}["use","on","once","set","query","type","accept","auth","withCredentials","sortQuery","retry","ok","redirects","timeout","buffer","serialize","parse","ca","key","pfx","cert"].forEach(function(t){r.prototype[t]=function(){return this._defaults.push({fn:t,arguments:arguments}),this}}),r.prototype._setDefaults=function(t){this._defaults.forEach(function(e){t[e.fn].apply(t,e.arguments)})},t.exports=r},function(t,e,r){"use strict";e.type=function(t){return t.split(/ *; */).shift()},e.params=function(t){return t.split(/ *; */).reduce(function(t,e){var r=e.split(/ *= */),n=r.shift(),o=r.shift();return n&&o&&(t[n]=o),t},{})},e.parseLinks=function(t){return t.split(/ *, */).reduce(function(t,e){var r=e.split(/ *; */),n=r[0].slice(1,-1);return t[r[1].split(/ *= */)[1].slice(1,-1)]=n,t},{})},e.cleanHeader=function(t,e){return delete t["content-type"],delete t["content-length"],delete t["transfer-encoding"],delete t.host,e&&(delete t.authorization,delete t.cookie),t}},function(t,e,r){"use strict";var n=r(14);function o(t){if(t)return function(t){for(var e in o.prototype)t[e]=o.prototype[e];return t}(t)}t.exports=o,o.prototype.get=function(t){return this.header[t.toLowerCase()]},o.prototype._setHeaderProperties=function(t){var e=t["content-type"]||"";this.type=n.type(e);var r=n.params(e);for(var o in r)this[o]=r[o];this.links={};try{t.link&&(this.links=n.parseLinks(t.link))}catch(t){}},o.prototype._setStatusProperties=function(t){var e=t/100|0;this.status=this.statusCode=t,this.statusType=e,this.info=1==e,this.ok=2==e,this.redirect=3==e,this.clientError=4==e,this.serverError=5==e,this.error=(4==e||5==e)&&this.toError(),this.created=201==t,this.accepted=202==t,this.noContent=204==t,this.badRequest=400==t,this.unauthorized=401==t,this.notAcceptable=406==t,this.forbidden=403==t,this.notFound=404==t,this.unprocessableEntity=422==t}},function(t,e,r){"use strict";var n=r(6);function o(t){if(t)return function(t){for(var e in o.prototype)t[e]=o.prototype[e];return t}(t)}t.exports=o,o.prototype.clearTimeout=function(){return clearTimeout(this._timer),clearTimeout(this._responseTimeoutTimer),delete this._timer,delete this._responseTimeoutTimer,this},o.prototype.parse=function(t){return this._parser=t,this},o.prototype.responseType=function(t){return this._responseType=t,this},o.prototype.serialize=function(t){return this._serializer=t,this},o.prototype.timeout=function(t){if(!t||"object"!=typeof t)return this._timeout=t,this._responseTimeout=0,this;for(var e in t)switch(e){case"deadline":this._timeout=t.deadline;break;case"response":this._responseTimeout=t.response;break;default:console.warn("Unknown timeout option",e)}return this},o.prototype.retry=function(t,e){return 0!==arguments.length&&!0!==t||(t=1),t<=0&&(t=0),this._maxRetries=t,this._retries=0,this._retryCallback=e,this};var i=["ECONNRESET","ETIMEDOUT","EADDRINFO","ESOCKETTIMEDOUT"];o.prototype._shouldRetry=function(t,e){if(!this._maxRetries||this._retries++>=this._maxRetries)return!1;if(this._retryCallback)try{var r=this._retryCallback(t,e);if(!0===r)return!0;if(!1===r)return!1}catch(t){console.error(t)}if(e&&e.status&&e.status>=500&&501!=e.status)return!0;if(t){if(t.code&&~i.indexOf(t.code))return!0;if(t.timeout&&"ECONNABORTED"==t.code)return!0;if(t.crossDomain)return!0}return!1},o.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this._end()},o.prototype.then=function(t,e){if(!this._fullfilledPromise){var r=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(t,e){r.end(function(r,n){r?e(r):t(n)})})}return this._fullfilledPromise.then(t,e)},o.prototype.catch=function(t){return this.then(void 0,t)},o.prototype.use=function(t){return t(this),this},o.prototype.ok=function(t){if("function"!=typeof t)throw Error("Callback required");return this._okCallback=t,this},o.prototype._isResponseOK=function(t){return!!t&&(this._okCallback?this._okCallback(t):t.status>=200&&t.status<300)},o.prototype.get=function(t){return this._header[t.toLowerCase()]},o.prototype.getHeader=o.prototype.get,o.prototype.set=function(t,e){if(n(t)){for(var r in t)this.set(r,t[r]);return this}return this._header[t.toLowerCase()]=e,this.header[t]=e,this},o.prototype.unset=function(t){return delete this._header[t.toLowerCase()],delete this.header[t],this},o.prototype.field=function(t,e){if(null===t||void 0===t)throw new Error(".field(name, val) name can not be empty");if(this._data&&console.error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()"),n(t)){for(var r in t)this.field(r,t[r]);return this}if(Array.isArray(e)){for(var o in e)this.field(t,e[o]);return this}if(null===e||void 0===e)throw new Error(".field(name, val) val can not be empty");return"boolean"==typeof e&&(e=""+e),this._getFormData().append(t,e),this},o.prototype.abort=function(){return this._aborted?this:(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req&&this.req.abort(),this.clearTimeout(),this.emit("abort"),this)},o.prototype._auth=function(t,e,r,n){switch(r.type){case"basic":this.set("Authorization","Basic "+n(t+":"+e));break;case"auto":this.username=t,this.password=e;break;case"bearer":this.set("Authorization","Bearer "+t)}return this},o.prototype.withCredentials=function(t){return void 0==t&&(t=!0),this._withCredentials=t,this},o.prototype.redirects=function(t){return this._maxRedirects=t,this},o.prototype.maxResponseSize=function(t){if("number"!=typeof t)throw TypeError("Invalid argument");return this._maxResponseSize=t,this},o.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}},o.prototype.send=function(t){var e=n(t),r=this._header["content-type"];if(this._formData&&console.error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()"),e&&!this._data)Array.isArray(t)?this._data=[]:this._isHost(t)||(this._data={});else if(t&&this._data&&this._isHost(this._data))throw Error("Can't merge these send calls");if(e&&n(this._data))for(var o in t)this._data[o]=t[o];else"string"==typeof t?(r||this.type("form"),r=this._header["content-type"],this._data="application/x-www-form-urlencoded"==r?this._data?this._data+"&"+t:t:(this._data||"")+t):this._data=t;return!e||this._isHost(t)?this:(r||this.type("json"),this)},o.prototype.sortQuery=function(t){return this._sort=void 0===t||t,this},o.prototype._finalizeQueryString=function(){var t=this._query.join("&");if(t&&(this.url+=(this.url.indexOf("?")>=0?"&":"?")+t),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(e>=0){var r=this.url.substring(e+1).split("&");"function"==typeof this._sort?r.sort(this._sort):r.sort(),this.url=this.url.substring(0,e)+"?"+r.join("&")}}},o.prototype._appendQueryString=function(){console.trace("Unsupported")},o.prototype._timeoutError=function(t,e,r){if(!this._aborted){var n=new Error(t+e+"ms exceeded");n.timeout=e,n.code="ECONNABORTED",n.errno=r,this.timedout=!0,this.abort(),this.callback(n)}},o.prototype._setTimeouts=function(){var t=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){t._timeoutError("Timeout of ",t._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){t._timeoutError("Response timeout of ",t._responseTimeout,"ETIMEDOUT")},this._responseTimeout))}},function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}t.exports=n,n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var o=0;o<n.length;o++)if((r=n[o])===e||r.fn===e){n.splice(o,1);break}return this},n.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),r=this._callbacks["$"+t];if(r)for(var n=0,o=(r=r.slice(0)).length;n<o;++n)r[n].apply(this,e);return this},n.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},n.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e,r){var n;"undefined"!=typeof window?n=window:"undefined"!=typeof self?n=self:(console.warn("Using browser-only version of superagent in non-browser environment"),n=this);var o=r(17),i=r(16),s=r(6),u=r(15),a=r(13);function c(){}var l=e=t.exports=function(t,r){return"function"==typeof r?new e.Request("GET",t).end(r):1==arguments.length?new e.Request("GET",t):new e.Request(t,r)};e.Request=m,l.getXHR=function(){if(!(!n.XMLHttpRequest||n.location&&"file:"==n.location.protocol&&n.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(t){}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(t){}throw Error("Browser-only version of superagent could not find XHR")};var p="".trim?function(t){return t.trim()}:function(t){return t.replace(/(^\s*|\s*$)/g,"")};function f(t){if(!s(t))return t;var e=[];for(var r in t)h(e,r,t[r]);return e.join("&")}function h(t,e,r){if(null!=r)if(Array.isArray(r))r.forEach(function(r){h(t,e,r)});else if(s(r))for(var n in r)h(t,e+"["+n+"]",r[n]);else t.push(encodeURIComponent(e)+"="+encodeURIComponent(r));else null===r&&t.push(encodeURIComponent(e))}function y(t){for(var e,r,n={},o=t.split("&"),i=0,s=o.length;i<s;++i)-1==(r=(e=o[i]).indexOf("="))?n[decodeURIComponent(e)]="":n[decodeURIComponent(e.slice(0,r))]=decodeURIComponent(e.slice(r+1));return n}function d(t){return/[\/+]json($|[^-\w])/.test(t)}function b(t){this.req=t,this.xhr=this.req.xhr,this.text="HEAD"!=this.req.method&&(""===this.xhr.responseType||"text"===this.xhr.responseType)||void 0===this.xhr.responseType?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText;var e=this.xhr.status;1223===e&&(e=204),this._setStatusProperties(e),this.header=this.headers=function(t){for(var e,r,n,o,i=t.split(/\r?\n/),s={},u=0,a=i.length;u<a;++u)-1!==(e=(r=i[u]).indexOf(":"))&&(n=r.slice(0,e).toLowerCase(),o=p(r.slice(e+1)),s[n]=o);return s}(this.xhr.getAllResponseHeaders()),this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),null===this.text&&t._responseType?this.body=this.xhr.response:this.body="HEAD"!=this.req.method?this._parseBody(this.text?this.text:this.xhr.response):null}function m(t,e){var r=this;this._query=this._query||[],this.method=t,this.url=e,this.header={},this._header={},this.on("end",function(){var t,e=null,n=null;try{n=new b(r)}catch(t){return(e=new Error("Parser is unable to parse the response")).parse=!0,e.original=t,r.xhr?(e.rawResponse=void 0===r.xhr.responseType?r.xhr.responseText:r.xhr.response,e.status=r.xhr.status?r.xhr.status:null,e.statusCode=e.status):(e.rawResponse=null,e.status=null),r.callback(e)}r.emit("response",n);try{r._isResponseOK(n)||(t=new Error(n.statusText||"Unsuccessful HTTP response"))}catch(e){t=e}t?(t.original=e,t.response=n,t.status=n.status,r.callback(t,n)):r.callback(null,n)})}function v(t,e,r){var n=l("DELETE",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}l.serializeObject=f,l.parseString=y,l.types={html:"text/html",json:"application/json",xml:"text/xml",urlencoded:"application/x-www-form-urlencoded",form:"application/x-www-form-urlencoded","form-data":"application/x-www-form-urlencoded"},l.serialize={"application/x-www-form-urlencoded":f,"application/json":JSON.stringify},l.parse={"application/x-www-form-urlencoded":y,"application/json":JSON.parse},u(b.prototype),b.prototype._parseBody=function(t){var e=l.parse[this.type];return this.req._parser?this.req._parser(this,t):(!e&&d(this.type)&&(e=l.parse["application/json"]),e&&t&&(t.length||t instanceof Object)?e(t):null)},b.prototype.toError=function(){var t=this.req,e=t.method,r=t.url,n="cannot "+e+" "+r+" ("+this.status+")",o=new Error(n);return o.status=this.status,o.method=e,o.url=r,o},l.Response=b,o(m.prototype),i(m.prototype),m.prototype.type=function(t){return this.set("Content-Type",l.types[t]||t),this},m.prototype.accept=function(t){return this.set("Accept",l.types[t]||t),this},m.prototype.auth=function(t,e,r){return 1===arguments.length&&(e=""),"object"==typeof e&&null!==e&&(r=e,e=""),r||(r={type:"function"==typeof btoa?"basic":"auto"}),this._auth(t,e,r,function(t){if("function"==typeof btoa)return btoa(t);throw new Error("Cannot use basic auth, btoa is not a function")})},m.prototype.query=function(t){return"string"!=typeof t&&(t=f(t)),t&&this._query.push(t),this},m.prototype.attach=function(t,e,r){if(e){if(this._data)throw Error("superagent can't mix .send() and .attach()");this._getFormData().append(t,e,r||e.name)}return this},m.prototype._getFormData=function(){return this._formData||(this._formData=new n.FormData),this._formData},m.prototype.callback=function(t,e){if(this._shouldRetry(t,e))return this._retry();var r=this._callback;this.clearTimeout(),t&&(this._maxRetries&&(t.retries=this._retries-1),this.emit("error",t)),r(t,e)},m.prototype.crossDomainError=function(){var t=new Error("Request has been terminated\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.");t.crossDomain=!0,t.status=this.status,t.method=this.method,t.url=this.url,this.callback(t)},m.prototype.buffer=m.prototype.ca=m.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},m.prototype.pipe=m.prototype.write=function(){throw Error("Streaming is not supported in browser version of superagent")},m.prototype._isHost=function(t){return t&&"object"==typeof t&&!Array.isArray(t)&&"[object Object]"!==Object.prototype.toString.call(t)},m.prototype.end=function(t){return this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=t||c,this._finalizeQueryString(),this._end()},m.prototype._end=function(){var t=this,e=this.xhr=l.getXHR(),r=this._formData||this._data;this._setTimeouts(),e.onreadystatechange=function(){var r=e.readyState;if(r>=2&&t._responseTimeoutTimer&&clearTimeout(t._responseTimeoutTimer),4==r){var n;try{n=e.status}catch(t){n=0}if(!n){if(t.timedout||t._aborted)return;return t.crossDomainError()}t.emit("end")}};var n=function(e,r){r.total>0&&(r.percent=r.loaded/r.total*100),r.direction=e,t.emit("progress",r)};if(this.hasListeners("progress"))try{e.onprogress=n.bind(null,"download"),e.upload&&(e.upload.onprogress=n.bind(null,"upload"))}catch(t){}try{this.username&&this.password?e.open(this.method,this.url,!0,this.username,this.password):e.open(this.method,this.url,!0)}catch(t){return this.callback(t)}if(this._withCredentials&&(e.withCredentials=!0),!this._formData&&"GET"!=this.method&&"HEAD"!=this.method&&"string"!=typeof r&&!this._isHost(r)){var o=this._header["content-type"],i=this._serializer||l.serialize[o?o.split(";")[0]:""];!i&&d(o)&&(i=l.serialize["application/json"]),i&&(r=i(r))}for(var s in this.header)null!=this.header[s]&&this.header.hasOwnProperty(s)&&e.setRequestHeader(s,this.header[s]);return this._responseType&&(e.responseType=this._responseType),this.emit("request",this),e.send(void 0!==r?r:null),this},l.agent=function(){return new a},["GET","POST","OPTIONS","PATCH","PUT","DELETE"].forEach(function(t){a.prototype[t.toLowerCase()]=function(e,r){var n=new l.Request(t,e);return this._setDefaults(n),r&&n.end(r),n}}),a.prototype.del=a.prototype.delete,l.get=function(t,e,r){var n=l("GET",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},l.head=function(t,e,r){var n=l("HEAD",t);return"function"==typeof e&&(r=e,e=null),e&&n.query(e),r&&n.end(r),n},l.options=function(t,e,r){var n=l("OPTIONS",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},l.del=v,l.delete=v,l.patch=function(t,e,r){var n=l("PATCH",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},l.post=function(t,e,r){var n=l("POST",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n},l.put=function(t,e,r){var n=l("PUT",t);return"function"==typeof e&&(r=e,e=null),e&&n.send(e),r&&n.end(r),n}},function(t,e,r){"use strict";var n=void 0;t.exports=(n||(n=r(18)),n)},function(t,e,r){"use strict";var n=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),o=r(7),i=r(1),s=r(5),u=r(4),a=r(3),c=r(12),l=r(2),p=r(11),f=r(10),h=r(9),y=r(8),d=void 0,b=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.apiKey,n=e.bearerToken,b=e.endpoint;if(function(e,r){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this),d)return d;if(!b)throw new i.MethodNeedsArg("endpoint");if(!r)throw new i.MethodNeedsArg("apiKey");this.endpoint=b,this.apiKey=r,this.bearerToken=n,o(this.endpoint,this._constructHeaders()),this.product=function(t){return new u(t)},this.provider=function(t){return new a(t)},this.user=function(t){return new l(t)},this.order=function(t){return new s(t)},this.tag=function(t){return new c(t)},this.company=function(t){return new p(t)},this.payment=function(t){return new f(t)},this.paymentMethod=function(t){return new h(t)},this.resource=function(t){return new y(t)},d=this}return n(t,[{key:"refreshBearerToken",value:function(t){this.bearerToken=t,o().updateHeaders(this._constructHeaders())}},{key:"_constructHeaders",value:function(){var t={"X-Share-API-Key":this.apiKey};return this.bearerToken&&(t.Authorization="Bearer "+this.bearerToken),t}}]),t}();t.exports=b},function(t,e,r){t.exports=r(20)}]);